1 | /* $Id: ClpObjective.hpp 1825 2011-11-20 16:02:57Z forrest $ */ |
---|
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 | //############################################################################# |
---|
11 | class ClpSimplex; |
---|
12 | class ClpModel; |
---|
13 | |
---|
14 | /** Objective Abstract Base Class |
---|
15 | |
---|
16 | Abstract Base Class for describing an objective function |
---|
17 | |
---|
18 | */ |
---|
19 | class ClpObjective { |
---|
20 | |
---|
21 | public: |
---|
22 | |
---|
23 | ///@name Stuff |
---|
24 | //@{ |
---|
25 | |
---|
26 | /** Returns gradient. If Linear then solution may be NULL, |
---|
27 | also returns an offset (to be added to current one) |
---|
28 | If refresh is false then uses last solution |
---|
29 | Uses model for scaling |
---|
30 | includeLinear 0 - no, 1 as is, 2 as feasible |
---|
31 | */ |
---|
32 | virtual double * gradient(const ClpSimplex * model, |
---|
33 | const double * solution, |
---|
34 | double & offset, bool refresh, |
---|
35 | int includeLinear = 2) = 0; |
---|
36 | /** Returns reduced gradient.Returns an offset (to be added to current one). |
---|
37 | */ |
---|
38 | virtual double reducedGradient(ClpSimplex * model, double * region, |
---|
39 | bool useFeasibleCosts) = 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 & currentObj, |
---|
51 | double & predictedObj, |
---|
52 | double & thetaObj) = 0; |
---|
53 | /// Return objective value (without any ClpModel offset) (model may be NULL) |
---|
54 | virtual double objectiveValue(const ClpSimplex * model, const double * solution) const = 0; |
---|
55 | /// Resize objective |
---|
56 | virtual void resize(int newNumberColumns) = 0; |
---|
57 | /// Delete columns in objective |
---|
58 | virtual void deleteSome(int numberToDelete, const int * which) = 0; |
---|
59 | /// Scale objective |
---|
60 | virtual void reallyScale(const double * columnScale) = 0; |
---|
61 | /** Given a zeroed array sets nonlinear columns to 1. |
---|
62 | Returns number of nonlinear columns |
---|
63 | */ |
---|
64 | virtual int markNonlinear(char * which); |
---|
65 | /// Say we have new primal solution - so may need to recompute |
---|
66 | virtual void newXValues() {} |
---|
67 | //@} |
---|
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 | return type_; |
---|
100 | } |
---|
101 | /// Sets type (above 63 is extra information) |
---|
102 | inline void setType(int value) { |
---|
103 | type_ = value; |
---|
104 | } |
---|
105 | /// Whether activated |
---|
106 | inline int activated() const { |
---|
107 | return activated_; |
---|
108 | } |
---|
109 | /// Set whether activated |
---|
110 | inline void setActivated(int value) { |
---|
111 | activated_ = value; |
---|
112 | } |
---|
113 | |
---|
114 | /// Objective offset |
---|
115 | inline double nonlinearOffset () const { |
---|
116 | return offset_; |
---|
117 | } |
---|
118 | //@} |
---|
119 | |
---|
120 | //--------------------------------------------------------------------------- |
---|
121 | |
---|
122 | protected: |
---|
123 | ///@name Protected member data |
---|
124 | //@{ |
---|
125 | /// Value of non-linear part of objective |
---|
126 | double offset_; |
---|
127 | /// Type of objective - linear is 1 |
---|
128 | int type_; |
---|
129 | /// Whether activated |
---|
130 | int activated_; |
---|
131 | //@} |
---|
132 | }; |
---|
133 | |
---|
134 | #endif |
---|