1 | /* $Id: ClpAmplObjective.hpp 1173 2009-06-04 09:44:10Z forrest $ */ |
---|
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 ClpAmplObjective_H |
---|
7 | #define ClpAmplObjective_H |
---|
8 | |
---|
9 | #include "ClpObjective.hpp" |
---|
10 | #include "CoinPackedMatrix.hpp" |
---|
11 | |
---|
12 | //############################################################################# |
---|
13 | |
---|
14 | /** Ampl Objective Class |
---|
15 | |
---|
16 | */ |
---|
17 | |
---|
18 | class ClpAmplObjective : public ClpObjective { |
---|
19 | |
---|
20 | public: |
---|
21 | |
---|
22 | ///@name Stuff |
---|
23 | //@{ |
---|
24 | |
---|
25 | /** Returns gradient. If Ampl then solution may be NULL, |
---|
26 | also returns an offset (to be added to current one) |
---|
27 | If refresh is false then uses last solution |
---|
28 | Uses model for scaling |
---|
29 | includeLinear 0 - no, 1 as is, 2 as feasible |
---|
30 | */ |
---|
31 | virtual double * gradient(const ClpSimplex * model, |
---|
32 | const double * solution, double & offset, bool refresh, |
---|
33 | int includeLinear = 2); |
---|
34 | /// Resize objective |
---|
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 | /** Returns step length which gives minimum of objective for |
---|
40 | solution + theta * change vector up to maximum theta. |
---|
41 | |
---|
42 | arrays are numberColumns+numberRows |
---|
43 | Also sets current objective, predicted and at maximumTheta |
---|
44 | */ |
---|
45 | virtual double stepLength(ClpSimplex * model, |
---|
46 | const double * solution, |
---|
47 | const double * change, |
---|
48 | double maximumTheta, |
---|
49 | double & currentObj, |
---|
50 | double & predictedObj, |
---|
51 | double & thetaObj); |
---|
52 | /// Return objective value (without any ClpModel offset) (model may be NULL) |
---|
53 | virtual double objectiveValue(const ClpSimplex * model, const double * solution) const ; |
---|
54 | virtual void resize(int newNumberColumns) ; |
---|
55 | /// Delete columns in objective |
---|
56 | virtual void deleteSome(int numberToDelete, const int * which) ; |
---|
57 | /// Scale objective |
---|
58 | virtual void reallyScale(const double * columnScale) ; |
---|
59 | /** Given a zeroed array sets nonlinear columns to 1. |
---|
60 | Returns number of nonlinear columns |
---|
61 | */ |
---|
62 | virtual int markNonlinear(char * which); |
---|
63 | |
---|
64 | /// Say we have new primal solution - so may need to recompute |
---|
65 | virtual void newXValues() ; |
---|
66 | //@} |
---|
67 | |
---|
68 | |
---|
69 | ///@name Constructors and destructors |
---|
70 | //@{ |
---|
71 | /// Default Constructor |
---|
72 | ClpAmplObjective(); |
---|
73 | |
---|
74 | /// Constructor from ampl info |
---|
75 | ClpAmplObjective(void * amplInfo); |
---|
76 | |
---|
77 | /** Copy constructor . |
---|
78 | */ |
---|
79 | ClpAmplObjective(const ClpAmplObjective & rhs); |
---|
80 | |
---|
81 | /// Assignment operator |
---|
82 | ClpAmplObjective & operator=(const ClpAmplObjective& rhs); |
---|
83 | |
---|
84 | /// Destructor |
---|
85 | virtual ~ClpAmplObjective (); |
---|
86 | |
---|
87 | /// Clone |
---|
88 | virtual ClpObjective * clone() const; |
---|
89 | |
---|
90 | //@} |
---|
91 | ///@name Gets and sets |
---|
92 | //@{ |
---|
93 | /// Linear objective |
---|
94 | double * linearObjective() const; |
---|
95 | //@} |
---|
96 | |
---|
97 | //--------------------------------------------------------------------------- |
---|
98 | |
---|
99 | private: |
---|
100 | ///@name Private member data |
---|
101 | /// Saved offset |
---|
102 | double offset_; |
---|
103 | /// Ampl info |
---|
104 | void * amplObjective_; |
---|
105 | /// Objective |
---|
106 | double * objective_; |
---|
107 | /// Gradient |
---|
108 | double * gradient_; |
---|
109 | //@} |
---|
110 | }; |
---|
111 | |
---|
112 | #endif |
---|
113 | |
---|