ClpSolve.hpp
Go to the documentation of this file.
1 /* $Id: ClpSolve.hpp 1525 2010-02-26 17:27:59Z mjs $ */
2 // Copyright (C) 2003, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 
5 /*
6  Authors
7 
8  John Forrest
9 
10  */
11 #ifndef ClpSolve_H
12 #define ClpSolve_H
13 
20 class ClpSolve {
21 
22 public:
23 
25  enum SolveType {
26  useDual = 0,
33  };
34  enum PresolveType {
39  };
40 
43  ClpSolve ( );
46  ClpSolve ( SolveType method, PresolveType presolveType,
47  int numberPasses, int options[6],
48  int extraInfo[6], int independentOptions[3]);
50  void generateCpp(FILE * fp);
52  ClpSolve(const ClpSolve &);
54  ClpSolve & operator=(const ClpSolve & rhs);
56  ~ClpSolve ( );
58 
103  void setSpecialOption(int which, int value, int extraInfo = -1);
104  int getSpecialOption(int which) const;
105 
107  void setSolveType(SolveType method, int extraInfo = -1);
109 
110  // Presolve types
111  void setPresolveType(PresolveType amount, int extraInfo = -1);
113  int getPresolvePasses() const;
115  int getExtraInfo(int which) const;
118  void setInfeasibleReturn(bool trueFalse);
119  inline bool infeasibleReturn() const {
120  return independentOptions_[0] != 0;
121  }
123  inline bool doDual() const {
124  return (independentOptions_[1] & 1) == 0;
125  }
126  inline void setDoDual(bool doDual_) {
127  if (doDual_) independentOptions_[1] &= ~1;
128  else independentOptions_[1] |= 1;
129  }
131  inline bool doSingleton() const {
132  return (independentOptions_[1] & 2) == 0;
133  }
134  inline void setDoSingleton(bool doSingleton_) {
135  if (doSingleton_) independentOptions_[1] &= ~2;
136  else independentOptions_[1] |= 2;
137  }
139  inline bool doDoubleton() const {
140  return (independentOptions_[1] & 4) == 0;
141  }
142  inline void setDoDoubleton(bool doDoubleton_) {
143  if (doDoubleton_) independentOptions_[1] &= ~4;
144  else independentOptions_[1] |= 4;
145  }
147  inline bool doTripleton() const {
148  return (independentOptions_[1] & 8) == 0;
149  }
150  inline void setDoTripleton(bool doTripleton_) {
151  if (doTripleton_) independentOptions_[1] &= ~8;
152  else independentOptions_[1] |= 8;
153  }
155  inline bool doTighten() const {
156  return (independentOptions_[1] & 16) == 0;
157  }
158  inline void setDoTighten(bool doTighten_) {
159  if (doTighten_) independentOptions_[1] &= ~16;
160  else independentOptions_[1] |= 16;
161  }
163  inline bool doForcing() const {
164  return (independentOptions_[1] & 32) == 0;
165  }
166  inline void setDoForcing(bool doForcing_) {
167  if (doForcing_) independentOptions_[1] &= ~32;
168  else independentOptions_[1] |= 32;
169  }
171  inline bool doImpliedFree() const {
172  return (independentOptions_[1] & 64) == 0;
173  }
174  inline void setDoImpliedFree(bool doImpliedfree) {
175  if (doImpliedfree) independentOptions_[1] &= ~64;
176  else independentOptions_[1] |= 64;
177  }
179  inline bool doDupcol() const {
180  return (independentOptions_[1] & 128) == 0;
181  }
182  inline void setDoDupcol(bool doDupcol_) {
183  if (doDupcol_) independentOptions_[1] &= ~128;
184  else independentOptions_[1] |= 128;
185  }
187  inline bool doDuprow() const {
188  return (independentOptions_[1] & 256) == 0;
189  }
190  inline void setDoDuprow(bool doDuprow_) {
191  if (doDuprow_) independentOptions_[1] &= ~256;
192  else independentOptions_[1] |= 256;
193  }
195  inline bool doSingletonColumn() const {
196  return (independentOptions_[1] & 512) == 0;
197  }
198  inline void setDoSingletonColumn(bool doSingleton_) {
199  if (doSingleton_) independentOptions_[1] &= ~512;
200  else independentOptions_[1] |= 512;
201  }
203  inline int presolveActions() const {
204  return independentOptions_[1] & 0xffff;
205  }
206  inline void setPresolveActions(int action) {
207  independentOptions_[1] = (independentOptions_[1] & 0xffff0000) | (action & 0xffff);
208  }
210  inline int substitution() const {
211  return independentOptions_[2];
212  }
213  inline void setSubstitution(int value) {
214  independentOptions_[2] = value;
215  }
217 
219 private:
220 
231  int options_[7];
233  int extraInfo_[7];
241 };
242 
245 
246 public:
247 
248 
251  ClpSimplexProgress ( );
253 
255  ClpSimplexProgress ( ClpSimplex * model );
256 
259 
265  void reset();
267  void fillFromModel ( ClpSimplex * model );
268 
270 
276  int looping ( );
278  void startCheck();
280  int cycle(int in, int out, int wayIn, int wayOut);
281 
283  double lastObjective(int back = 1) const;
285  void setInfeasibility(double value);
287  double lastInfeasibility(int back = 1) const;
289  void modifyObjective(double value);
291  int lastIterationNumber(int back = 1) const;
293  void clearIterationNumbers();
295  inline void newOddState() {
296  oddState_ = - oddState_ - 1;
297  }
298  inline void endOddState() {
299  oddState_ = abs(oddState_);
300  }
301  inline void clearOddState() {
302  oddState_ = 0;
303  }
304  inline int oddState() const {
305  return oddState_;
306  }
308  inline int badTimes() const {
309  return numberBadTimes_;
310  }
311  inline void clearBadTimes() {
312  numberBadTimes_ = 0;
313  }
315  inline int reallyBadTimes() const {
316  return numberReallyBadTimes_;
317  }
318  inline void incrementReallyBadTimes() {
320  }
322  inline int timesFlagged() const {
323  return numberTimesFlagged_;
324  }
325  inline void clearTimesFlagged() {
327  }
328  inline void incrementTimesFlagged() {
330  }
331 
333 
334 #define CLP_PROGRESS 5
335  //#define CLP_PROGRESS_WEIGHT 10
337  double objective_[CLP_PROGRESS];
343 #ifdef CLP_PROGRESS_WEIGHT
344  double objectiveWeight_[CLP_PROGRESS_WEIGHT];
347  double infeasibilityWeight_[CLP_PROGRESS_WEIGHT];
349  double realInfeasibilityWeight_[CLP_PROGRESS_WEIGHT];
351  double drop_;
353  double best_;
354 #endif
355  double initialWeight_;
357 #define CLP_CYCLE 12
358  //double obj_[CLP_CYCLE];
369 #ifdef CLP_PROGRESS_WEIGHT
370  int numberInfeasibilitiesWeight_[CLP_PROGRESS_WEIGHT];
373  int iterationNumberWeight_[CLP_PROGRESS_WEIGHT];
374 #endif
375  int numberTimes_;
386 };
387 #endif