1 | /* $Id: ClpConstraintAmpl.hpp 1899 2013-04-09 18:12:08Z forrest $ */ |
---|
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 | |
---|
21 | ///@name Stuff |
---|
22 | //@{ |
---|
23 | |
---|
24 | |
---|
25 | /** Fills gradient. If Ampl then solution may be NULL, |
---|
26 | also returns true value of function and offset so we can use x not deltaX in constraint |
---|
27 | If refresh is false then uses last solution |
---|
28 | Uses model for scaling |
---|
29 | Returns non-zero if gradient udefined at current solution |
---|
30 | */ |
---|
31 | virtual int gradient(const ClpSimplex * model, |
---|
32 | const double * solution, |
---|
33 | double * gradient, |
---|
34 | double & functionValue , |
---|
35 | double & offset, |
---|
36 | bool useScaling = false, |
---|
37 | bool refresh = true) const ; |
---|
38 | /// Resize constraint |
---|
39 | virtual void resize(int newNumberColumns) ; |
---|
40 | /// Delete columns in constraint |
---|
41 | virtual void deleteSome(int numberToDelete, const int * which) ; |
---|
42 | /// Scale constraint |
---|
43 | virtual void reallyScale(const double * columnScale) ; |
---|
44 | /** Given a zeroed array sets nonampl columns to 1. |
---|
45 | Returns number of nonampl columns |
---|
46 | */ |
---|
47 | virtual int markNonlinear(char * which) const ; |
---|
48 | /** Given a zeroed array sets possible nonzero coefficients to 1. |
---|
49 | Returns number of nonzeros |
---|
50 | */ |
---|
51 | virtual int markNonzero(char * which) const; |
---|
52 | /// Say we have new primal solution - so may need to recompute |
---|
53 | virtual void newXValues() ; |
---|
54 | //@} |
---|
55 | |
---|
56 | |
---|
57 | ///@name Constructors and destructors |
---|
58 | //@{ |
---|
59 | /// Default Constructor |
---|
60 | ClpConstraintAmpl(); |
---|
61 | |
---|
62 | /// Constructor from ampl |
---|
63 | ClpConstraintAmpl(int row, void * amplInfo); |
---|
64 | |
---|
65 | /** Copy constructor . |
---|
66 | */ |
---|
67 | ClpConstraintAmpl(const ClpConstraintAmpl & rhs); |
---|
68 | |
---|
69 | /// Assignment operator |
---|
70 | ClpConstraintAmpl & operator=(const ClpConstraintAmpl& rhs); |
---|
71 | |
---|
72 | /// Destructor |
---|
73 | virtual ~ClpConstraintAmpl (); |
---|
74 | |
---|
75 | /// Clone |
---|
76 | virtual ClpConstraint * clone() const; |
---|
77 | //@} |
---|
78 | ///@name Gets and sets |
---|
79 | //@{ |
---|
80 | /// Number of coefficients |
---|
81 | virtual int numberCoefficients() const; |
---|
82 | /// Columns |
---|
83 | inline const int * column() const { |
---|
84 | return column_; |
---|
85 | } |
---|
86 | /// Coefficients |
---|
87 | inline const double * coefficient() const { |
---|
88 | return coefficient_; |
---|
89 | } |
---|
90 | //@} |
---|
91 | |
---|
92 | //--------------------------------------------------------------------------- |
---|
93 | |
---|
94 | private: |
---|
95 | ///@name Private member data |
---|
96 | /// Ampl info |
---|
97 | void * amplInfo_; |
---|
98 | /// Column |
---|
99 | int * column_; |
---|
100 | /// Coefficients |
---|
101 | double * coefficient_; |
---|
102 | /// Number of coefficients in gradient |
---|
103 | int numberCoefficients_; |
---|
104 | //@} |
---|
105 | }; |
---|
106 | |
---|
107 | #endif |
---|
108 | |
---|