1 | /* $Id: ClpConstraintAmpl.hpp 1173 2009-06-04 09:44:10Z forrest $ */ |
---|
2 | // Copyright (C) 2007, International Business Machines |
---|
3 | // Corporation and others. All Rights Reserved. |
---|
4 | #ifndef ClpConstraintAmpl_H |
---|
5 | #define ClpConstraintAmpl_H |
---|
6 | |
---|
7 | #include "ClpConstraint.hpp" |
---|
8 | |
---|
9 | //############################################################################# |
---|
10 | |
---|
11 | /** Ampl Constraint Class |
---|
12 | |
---|
13 | */ |
---|
14 | |
---|
15 | class ClpConstraintAmpl : public ClpConstraint { |
---|
16 | |
---|
17 | public: |
---|
18 | |
---|
19 | ///@name Stuff |
---|
20 | //@{ |
---|
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 | |
---|
55 | ///@name Constructors and destructors |
---|
56 | //@{ |
---|
57 | /// Default Constructor |
---|
58 | ClpConstraintAmpl(); |
---|
59 | |
---|
60 | /// Constructor from ampl |
---|
61 | ClpConstraintAmpl(int row, void * amplInfo); |
---|
62 | |
---|
63 | /** Copy constructor . |
---|
64 | */ |
---|
65 | ClpConstraintAmpl(const ClpConstraintAmpl & rhs); |
---|
66 | |
---|
67 | /// Assignment operator |
---|
68 | ClpConstraintAmpl & operator=(const ClpConstraintAmpl& rhs); |
---|
69 | |
---|
70 | /// Destructor |
---|
71 | virtual ~ClpConstraintAmpl (); |
---|
72 | |
---|
73 | /// Clone |
---|
74 | virtual ClpConstraint * clone() const; |
---|
75 | //@} |
---|
76 | ///@name Gets and sets |
---|
77 | //@{ |
---|
78 | /// Number of coefficients |
---|
79 | virtual int numberCoefficients() const; |
---|
80 | /// Columns |
---|
81 | inline const int * column() const { |
---|
82 | return column_; |
---|
83 | } |
---|
84 | /// Coefficients |
---|
85 | inline const double * coefficient() const { |
---|
86 | return coefficient_; |
---|
87 | } |
---|
88 | //@} |
---|
89 | |
---|
90 | //--------------------------------------------------------------------------- |
---|
91 | |
---|
92 | private: |
---|
93 | ///@name Private member data |
---|
94 | /// Ampl info |
---|
95 | void * amplInfo_; |
---|
96 | /// Column |
---|
97 | int * column_; |
---|
98 | /// Coefficients |
---|
99 | double * coefficient_; |
---|
100 | /// Number of coefficients in gradient |
---|
101 | int numberCoefficients_; |
---|
102 | //@} |
---|
103 | }; |
---|
104 | |
---|
105 | #endif |
---|