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