1 | /* $Id: ClpConstraintQuadratic.hpp 2385 2019-01-06 19:43:06Z stefan $ */ |
---|
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 ClpConstraintQuadratic_H |
---|
7 | #define ClpConstraintQuadratic_H |
---|
8 | |
---|
9 | #include "ClpConstraint.hpp" |
---|
10 | |
---|
11 | //############################################################################# |
---|
12 | |
---|
13 | /** Quadratic Constraint Class |
---|
14 | |
---|
15 | */ |
---|
16 | |
---|
17 | class ClpConstraintQuadratic : public ClpConstraint { |
---|
18 | |
---|
19 | public: |
---|
20 | ///@name Stuff |
---|
21 | //@{ |
---|
22 | |
---|
23 | /** Fills gradient. If Quadratic 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 nonquadratic columns to 1. |
---|
43 | Returns number of nonquadratic 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 | //@} |
---|
51 | |
---|
52 | ///@name Constructors and destructors |
---|
53 | //@{ |
---|
54 | /// Default Constructor |
---|
55 | ClpConstraintQuadratic(); |
---|
56 | |
---|
57 | /// Constructor from quadratic |
---|
58 | ClpConstraintQuadratic(int row, int numberQuadraticColumns, int numberColumns, |
---|
59 | const CoinBigIndex *start, |
---|
60 | const int *column, const double *element); |
---|
61 | |
---|
62 | /** Copy constructor . |
---|
63 | */ |
---|
64 | ClpConstraintQuadratic(const ClpConstraintQuadratic &rhs); |
---|
65 | |
---|
66 | /// Assignment operator |
---|
67 | ClpConstraintQuadratic &operator=(const ClpConstraintQuadratic &rhs); |
---|
68 | |
---|
69 | /// Destructor |
---|
70 | virtual ~ClpConstraintQuadratic(); |
---|
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 | /// Number of columns in constraint |
---|
80 | inline int numberColumns() const |
---|
81 | { |
---|
82 | return numberColumns_; |
---|
83 | } |
---|
84 | /// Column starts |
---|
85 | inline CoinBigIndex *start() const |
---|
86 | { |
---|
87 | return start_; |
---|
88 | } |
---|
89 | /// Columns |
---|
90 | inline const int *column() const |
---|
91 | { |
---|
92 | return column_; |
---|
93 | } |
---|
94 | /// Coefficients |
---|
95 | inline const double *coefficient() const |
---|
96 | { |
---|
97 | return coefficient_; |
---|
98 | } |
---|
99 | //@} |
---|
100 | |
---|
101 | //--------------------------------------------------------------------------- |
---|
102 | |
---|
103 | private: |
---|
104 | ///@name Private member data |
---|
105 | /// Column starts |
---|
106 | CoinBigIndex *start_; |
---|
107 | /// Column (if -1 then linear coefficient) |
---|
108 | int *column_; |
---|
109 | /// Coefficients |
---|
110 | double *coefficient_; |
---|
111 | /// Useful to have number of columns about |
---|
112 | int numberColumns_; |
---|
113 | /// Number of coefficients in gradient |
---|
114 | int numberCoefficients_; |
---|
115 | /// Number of quadratic columns |
---|
116 | int numberQuadraticColumns_; |
---|
117 | //@} |
---|
118 | }; |
---|
119 | |
---|
120 | #endif |
---|
121 | |
---|
122 | /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 |
---|
123 | */ |
---|