1 | /* $Id: ClpConstraintLinear.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 ClpConstraintLinear_H |
---|
7 | #define ClpConstraintLinear_H |
---|
8 | |
---|
9 | #include "ClpConstraint.hpp" |
---|
10 | |
---|
11 | //############################################################################# |
---|
12 | |
---|
13 | /** Linear Constraint Class |
---|
14 | |
---|
15 | */ |
---|
16 | |
---|
17 | class ClpConstraintLinear : public ClpConstraint { |
---|
18 | |
---|
19 | public: |
---|
20 | ///@name Stuff |
---|
21 | //@{ |
---|
22 | |
---|
23 | /** Fills gradient. If Linear 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 nonlinear columns to 1. |
---|
43 | Returns number of nonlinear 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 | ClpConstraintLinear(); |
---|
56 | |
---|
57 | /// Constructor from constraint |
---|
58 | ClpConstraintLinear(int row, int numberCoefficients, int numberColumns, |
---|
59 | const int *column, const double *element); |
---|
60 | |
---|
61 | /** Copy constructor . |
---|
62 | */ |
---|
63 | ClpConstraintLinear(const ClpConstraintLinear &rhs); |
---|
64 | |
---|
65 | /// Assignment operator |
---|
66 | ClpConstraintLinear &operator=(const ClpConstraintLinear &rhs); |
---|
67 | |
---|
68 | /// Destructor |
---|
69 | virtual ~ClpConstraintLinear(); |
---|
70 | |
---|
71 | /// Clone |
---|
72 | virtual ClpConstraint *clone() const; |
---|
73 | //@} |
---|
74 | ///@name Gets and sets |
---|
75 | //@{ |
---|
76 | /// Number of coefficients |
---|
77 | virtual int numberCoefficients() const; |
---|
78 | /// Number of columns in linear constraint |
---|
79 | inline int numberColumns() const |
---|
80 | { |
---|
81 | return numberColumns_; |
---|
82 | } |
---|
83 | /// Columns |
---|
84 | inline const int *column() const |
---|
85 | { |
---|
86 | return column_; |
---|
87 | } |
---|
88 | /// Coefficients |
---|
89 | inline const double *coefficient() const |
---|
90 | { |
---|
91 | return coefficient_; |
---|
92 | } |
---|
93 | //@} |
---|
94 | |
---|
95 | //--------------------------------------------------------------------------- |
---|
96 | |
---|
97 | private: |
---|
98 | ///@name Private member data |
---|
99 | /// Column |
---|
100 | int *column_; |
---|
101 | /// Coefficients |
---|
102 | double *coefficient_; |
---|
103 | /// Useful to have number of columns about |
---|
104 | int numberColumns_; |
---|
105 | /// Number of coefficients |
---|
106 | int numberCoefficients_; |
---|
107 | //@} |
---|
108 | }; |
---|
109 | |
---|
110 | #endif |
---|
111 | |
---|
112 | /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 |
---|
113 | */ |
---|