1 | /* $Id: ClpConstraintAmpl.hpp 2464 2019-01-03 19:03:23Z unxusr $ */ |
---|
2 | // Copyright (C) 2007, International Business Machines |
---|
3 | // Corporation and others. All Rights Reserved. |
---|
4 | // This code is licensed under the terms of the Eclipse Public License (EPL). |
---|
5 | |
---|
6 | #ifndef ClpConstraintAmpl_H |
---|
7 | #define ClpConstraintAmpl_H |
---|
8 | |
---|
9 | #include "ClpConstraint.hpp" |
---|
10 | |
---|
11 | //############################################################################# |
---|
12 | |
---|
13 | /** Ampl Constraint Class |
---|
14 | |
---|
15 | */ |
---|
16 | |
---|
17 | class ClpConstraintAmpl : public ClpConstraint { |
---|
18 | |
---|
19 | public: |
---|
20 | ///@name Stuff |
---|
21 | //@{ |
---|
22 | |
---|
23 | /** Fills gradient. If Ampl then solution may be NULL, |
---|
24 | also returns true value of function and offset so we can use x not deltaX in constraint |
---|
25 | If refresh is false then uses last solution |
---|
26 | Uses model for scaling |
---|
27 | Returns non-zero if gradient udefined at current solution |
---|
28 | */ |
---|
29 | virtual int gradient(const ClpSimplex *model, |
---|
30 | const double *solution, |
---|
31 | double *gradient, |
---|
32 | double &functionValue, |
---|
33 | double &offset, |
---|
34 | bool useScaling = false, |
---|
35 | bool refresh = true) const; |
---|
36 | /// Resize constraint |
---|
37 | virtual void resize(int newNumberColumns); |
---|
38 | /// Delete columns in constraint |
---|
39 | virtual void deleteSome(int numberToDelete, const int *which); |
---|
40 | /// Scale constraint |
---|
41 | virtual void reallyScale(const double *columnScale); |
---|
42 | /** Given a zeroed array sets nonampl columns to 1. |
---|
43 | Returns number of nonampl columns |
---|
44 | */ |
---|
45 | virtual int markNonlinear(char *which) const; |
---|
46 | /** Given a zeroed array sets possible nonzero coefficients to 1. |
---|
47 | Returns number of nonzeros |
---|
48 | */ |
---|
49 | virtual int markNonzero(char *which) const; |
---|
50 | /// Say we have new primal solution - so may need to recompute |
---|
51 | virtual void newXValues(); |
---|
52 | //@} |
---|
53 | |
---|
54 | ///@name Constructors and destructors |
---|
55 | //@{ |
---|
56 | /// Default Constructor |
---|
57 | ClpConstraintAmpl(); |
---|
58 | |
---|
59 | /// Constructor from ampl |
---|
60 | ClpConstraintAmpl(int row, void *amplInfo); |
---|
61 | |
---|
62 | /** Copy constructor . |
---|
63 | */ |
---|
64 | ClpConstraintAmpl(const ClpConstraintAmpl &rhs); |
---|
65 | |
---|
66 | /// Assignment operator |
---|
67 | ClpConstraintAmpl &operator=(const ClpConstraintAmpl &rhs); |
---|
68 | |
---|
69 | /// Destructor |
---|
70 | virtual ~ClpConstraintAmpl(); |
---|
71 | |
---|
72 | /// Clone |
---|
73 | virtual ClpConstraint *clone() const; |
---|
74 | //@} |
---|
75 | ///@name Gets and sets |
---|
76 | //@{ |
---|
77 | /// Number of coefficients |
---|
78 | virtual int numberCoefficients() const; |
---|
79 | /// Columns |
---|
80 | inline const int *column() const |
---|
81 | { |
---|
82 | return column_; |
---|
83 | } |
---|
84 | /// Coefficients |
---|
85 | inline const double *coefficient() const |
---|
86 | { |
---|
87 | return coefficient_; |
---|
88 | } |
---|
89 | //@} |
---|
90 | |
---|
91 | //--------------------------------------------------------------------------- |
---|
92 | |
---|
93 | private: |
---|
94 | ///@name Private member data |
---|
95 | /// Ampl info |
---|
96 | void *amplInfo_; |
---|
97 | /// Column |
---|
98 | int *column_; |
---|
99 | /// Coefficients |
---|
100 | double *coefficient_; |
---|
101 | /// Number of coefficients in gradient |
---|
102 | int numberCoefficients_; |
---|
103 | //@} |
---|
104 | }; |
---|
105 | |
---|
106 | #endif |
---|