1 | /* $Id: ClpObjective.hpp 2385 2019-01-06 19:43:06Z stefan $ */ |
---|
2 | // Copyright (C) 2002, 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 ClpObjective_H |
---|
7 | #define ClpObjective_H |
---|
8 | |
---|
9 | //############################################################################# |
---|
10 | class ClpSimplex; |
---|
11 | class ClpModel; |
---|
12 | |
---|
13 | /** Objective Abstract Base Class |
---|
14 | |
---|
15 | Abstract Base Class for describing an objective function |
---|
16 | |
---|
17 | */ |
---|
18 | class ClpObjective { |
---|
19 | |
---|
20 | public: |
---|
21 | ///@name Stuff |
---|
22 | //@{ |
---|
23 | |
---|
24 | /** Returns gradient. If Linear then solution may be NULL, |
---|
25 | also returns an offset (to be added to current one) |
---|
26 | If refresh is false then uses last solution |
---|
27 | Uses model for scaling |
---|
28 | includeLinear 0 - no, 1 as is, 2 as feasible |
---|
29 | */ |
---|
30 | virtual double *gradient(const ClpSimplex *model, |
---|
31 | const double *solution, |
---|
32 | double &offset, bool refresh, |
---|
33 | int includeLinear = 2) |
---|
34 | = 0; |
---|
35 | /** Returns reduced gradient.Returns an offset (to be added to current one). |
---|
36 | */ |
---|
37 | virtual double reducedGradient(ClpSimplex *model, double *region, |
---|
38 | bool useFeasibleCosts) |
---|
39 | = 0; |
---|
40 | /** Returns step length which gives minimum of objective for |
---|
41 | solution + theta * change vector up to maximum theta. |
---|
42 | |
---|
43 | arrays are numberColumns+numberRows |
---|
44 | Also sets current objective, predicted and at maximumTheta |
---|
45 | */ |
---|
46 | virtual double stepLength(ClpSimplex *model, |
---|
47 | const double *solution, |
---|
48 | const double *change, |
---|
49 | double maximumTheta, |
---|
50 | double ¤tObj, |
---|
51 | double &predictedObj, |
---|
52 | double &thetaObj) |
---|
53 | = 0; |
---|
54 | /// Return objective value (without any ClpModel offset) (model may be NULL) |
---|
55 | virtual double objectiveValue(const ClpSimplex *model, const double *solution) const = 0; |
---|
56 | /// Resize objective |
---|
57 | virtual void resize(int newNumberColumns) = 0; |
---|
58 | /// Delete columns in objective |
---|
59 | virtual void deleteSome(int numberToDelete, const int *which) = 0; |
---|
60 | /// Scale objective |
---|
61 | virtual void reallyScale(const double *columnScale) = 0; |
---|
62 | /** Given a zeroed array sets nonlinear columns to 1. |
---|
63 | Returns number of nonlinear columns |
---|
64 | */ |
---|
65 | virtual int markNonlinear(char *which); |
---|
66 | /// Say we have new primal solution - so may need to recompute |
---|
67 | virtual void newXValues() {} |
---|
68 | //@} |
---|
69 | |
---|
70 | ///@name Constructors and destructors |
---|
71 | //@{ |
---|
72 | /// Default Constructor |
---|
73 | ClpObjective(); |
---|
74 | |
---|
75 | /// Copy constructor |
---|
76 | ClpObjective(const ClpObjective &); |
---|
77 | |
---|
78 | /// Assignment operator |
---|
79 | ClpObjective &operator=(const ClpObjective &rhs); |
---|
80 | |
---|
81 | /// Destructor |
---|
82 | virtual ~ClpObjective(); |
---|
83 | |
---|
84 | /// Clone |
---|
85 | virtual ClpObjective *clone() const = 0; |
---|
86 | /** Subset clone. Duplicates are allowed |
---|
87 | and order is as given. |
---|
88 | Derived classes need not provide this as it may not always make |
---|
89 | sense */ |
---|
90 | virtual ClpObjective *subsetClone(int numberColumns, |
---|
91 | const int *whichColumns) const; |
---|
92 | |
---|
93 | //@} |
---|
94 | |
---|
95 | ///@name Other |
---|
96 | //@{ |
---|
97 | /// Returns type (above 63 is extra information) |
---|
98 | inline int type() const |
---|
99 | { |
---|
100 | return type_; |
---|
101 | } |
---|
102 | /// Sets type (above 63 is extra information) |
---|
103 | inline void setType(int value) |
---|
104 | { |
---|
105 | type_ = value; |
---|
106 | } |
---|
107 | /// Whether activated |
---|
108 | inline int activated() const |
---|
109 | { |
---|
110 | return activated_; |
---|
111 | } |
---|
112 | /// Set whether activated |
---|
113 | inline void setActivated(int value) |
---|
114 | { |
---|
115 | activated_ = value; |
---|
116 | } |
---|
117 | |
---|
118 | /// Objective offset |
---|
119 | inline double nonlinearOffset() const |
---|
120 | { |
---|
121 | return offset_; |
---|
122 | } |
---|
123 | //@} |
---|
124 | |
---|
125 | //--------------------------------------------------------------------------- |
---|
126 | |
---|
127 | protected: |
---|
128 | ///@name Protected member data |
---|
129 | //@{ |
---|
130 | /// Value of non-linear part of objective |
---|
131 | double offset_; |
---|
132 | /// Type of objective - linear is 1 |
---|
133 | int type_; |
---|
134 | /// Whether activated |
---|
135 | int activated_; |
---|
136 | //@} |
---|
137 | }; |
---|
138 | |
---|
139 | #endif |
---|
140 | |
---|
141 | /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 |
---|
142 | */ |
---|