Clp  1.15.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ClpSolve.hpp
Go to the documentation of this file.
1 /* $Id: ClpSolve.hpp 1928 2013-04-06 12:54:16Z stefan $ */
2 // Copyright (C) 2003, 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  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 bool doKillSmall() const {
204  return (independentOptions_[1] & 1024) == 0;
205  }
206  inline void setDoKillSmall(bool doKill) {
207  if (doKill) independentOptions_[1] &= ~1024;
208  else independentOptions_[1] |= 1024;
209  }
211  inline int presolveActions() const {
212  return independentOptions_[1] & 0xffff;
213  }
214  inline void setPresolveActions(int action) {
215  independentOptions_[1] = (independentOptions_[1] & 0xffff0000) | (action & 0xffff);
216  }
218  inline int substitution() const {
219  return independentOptions_[2];
220  }
221  inline void setSubstitution(int value) {
222  independentOptions_[2] = value;
223  }
225 
227 private:
228 
232  SolveType method_;
235  PresolveType presolveType_;
237  int numberPasses_;
239  int options_[7];
241  int extraInfo_[7];
247  int independentOptions_[3];
249 };
250 
253 
254 public:
255 
256 
259  ClpSimplexProgress ( );
261 
263  ClpSimplexProgress ( ClpSimplex * model );
264 
267 
273  void reset();
275  void fillFromModel ( ClpSimplex * model );
276 
278 
284  int looping ( );
286  void startCheck();
288  int cycle(int in, int out, int wayIn, int wayOut);
289 
291  double lastObjective(int back = 1) const;
293  void setInfeasibility(double value);
295  double lastInfeasibility(int back = 1) const;
297  void modifyObjective(double value);
299  int lastIterationNumber(int back = 1) const;
301  void clearIterationNumbers();
303  inline void newOddState() {
304  oddState_ = - oddState_ - 1;
305  }
306  inline void endOddState() {
307  oddState_ = abs(oddState_);
308  }
309  inline void clearOddState() {
310  oddState_ = 0;
311  }
312  inline int oddState() const {
313  return oddState_;
314  }
316  inline int badTimes() const {
317  return numberBadTimes_;
318  }
319  inline void clearBadTimes() {
320  numberBadTimes_ = 0;
321  }
323  inline int reallyBadTimes() const {
324  return numberReallyBadTimes_;
325  }
326  inline void incrementReallyBadTimes() {
328  }
330  inline int timesFlagged() const {
331  return numberTimesFlagged_;
332  }
333  inline void clearTimesFlagged() {
335  }
336  inline void incrementTimesFlagged() {
338  }
339 
341 
342 #define CLP_PROGRESS 5
343  //#define CLP_PROGRESS_WEIGHT 10
345  double objective_[CLP_PROGRESS];
351 #ifdef CLP_PROGRESS_WEIGHT
352  double objectiveWeight_[CLP_PROGRESS_WEIGHT];
355  double infeasibilityWeight_[CLP_PROGRESS_WEIGHT];
357  double realInfeasibilityWeight_[CLP_PROGRESS_WEIGHT];
359  double drop_;
361  double best_;
362 #endif
363  double initialWeight_;
365 #define CLP_CYCLE 12
366  //double obj_[CLP_CYCLE];
377 #ifdef CLP_PROGRESS_WEIGHT
378  int numberInfeasibilitiesWeight_[CLP_PROGRESS_WEIGHT];
381  int iterationNumberWeight_[CLP_PROGRESS_WEIGHT];
382 #endif
383  int numberTimes_;
394 };
395 
396 #include "ClpConfig.h"
397 #if CLP_HAS_ABC
398 #include "AbcCommon.hpp"
400 class AbcSimplexProgress : public ClpSimplexProgress {
401 
402 public:
403 
404 
407  AbcSimplexProgress ( );
409 
411  AbcSimplexProgress ( ClpSimplex * model );
412 
414  AbcSimplexProgress(const AbcSimplexProgress &);
415 
417  AbcSimplexProgress & operator=(const AbcSimplexProgress & rhs);
419  ~AbcSimplexProgress ( );
420 
422 
428  int looping ( );
429 
431 
433 };
434 #endif
435 #endif
void reset()
Resets as much as possible.
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
Definition: ClpSolve.hpp:195
This is a very simple class to guide algorithms.
Definition: ClpSolve.hpp:20
bool doDupcol() const
Whether we want to do dupcol part of presolve.
Definition: ClpSolve.hpp:179
void startCheck()
Start check at beginning of whileIterating.
void setDoSingletonColumn(bool doSingleton_)
Definition: ClpSolve.hpp:198
bool doTripleton() const
Whether we want to do tripleton part of presolve.
Definition: ClpSolve.hpp:147
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition: ClpSolve.hpp:131
int getSpecialOption(int which) const
bool doImpliedFree() const
Whether we want to do impliedfree part of presolve.
Definition: ClpSolve.hpp:171
SolveType getSolveType()
ClpSimplex * model_
Pointer back to model so we can get information.
Definition: ClpSolve.hpp:372
void setSpecialOption(int which, int value, int extraInfo=-1)
Special options - bits 0 4 - use crash (default allslack in dual, idiot in primal) 8 - all slack basi...
int out_[CLP_CYCLE]
Definition: ClpSolve.hpp:369
For saving extra information to see if looping.
Definition: ClpSolve.hpp:252
int numberTimes_
Number of times checked (so won't stop too early)
Definition: ClpSolve.hpp:384
#define CLP_PROGRESS
Definition: ClpSolve.hpp:342
void newOddState()
Odd state.
Definition: ClpSolve.hpp:303
bool doDuprow() const
Whether we want to do duprow part of presolve.
Definition: ClpSolve.hpp:187
void generateCpp(FILE *fp)
Generates code for above constructor.
int looping()
Returns -1 if okay, -n+1 (n number of times bad) if bad but action taken, >=0 if give up and use as p...
void setDoTripleton(bool doTripleton_)
Definition: ClpSolve.hpp:150
void setPresolveType(PresolveType amount, int extraInfo=-1)
double lastInfeasibility(int back=1) const
Returns real primal infeasibility (if -1) - current if (0)
ClpSolve()
Default constructor.
~ClpSimplexProgress()
Destructor.
int cycle(int in, int out, int wayIn, int wayOut)
Returns cycle length in whileIterating.
int in_[CLP_CYCLE]
For cycle checking.
Definition: ClpSolve.hpp:368
int numberReallyBadTimes_
Number really bad times.
Definition: ClpSolve.hpp:388
int getPresolvePasses() const
int reallyBadTimes() const
number of really bad times
Definition: ClpSolve.hpp:323
void incrementTimesFlagged()
Definition: ClpSolve.hpp:336
void setDoForcing(bool doForcing_)
Definition: ClpSolve.hpp:166
void clearIterationNumbers()
clears all iteration numbers (to switch off panic)
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:55
void setDoDupcol(bool doDupcol_)
Definition: ClpSolve.hpp:182
void fillFromModel(ClpSimplex *model)
Fill from model.
bool doKillSmall() const
Whether we want to kill small substitutions.
Definition: ClpSolve.hpp:203
void setDoTighten(bool doTighten_)
Definition: ClpSolve.hpp:158
SolveType
enums for solve function
Definition: ClpSolve.hpp:25
void setDoDual(bool doDual_)
Definition: ClpSolve.hpp:126
double lastObjective(int back=1) const
Returns previous objective (if -1) - current if (0)
int iterationNumber_[CLP_PROGRESS]
Iteration number at which occurred.
Definition: ClpSolve.hpp:376
void setDoSingleton(bool doSingleton_)
Definition: ClpSolve.hpp:134
double realInfeasibility_[CLP_PROGRESS]
Sum of real primal infeasibilities for primal.
Definition: ClpSolve.hpp:350
void setSolveType(SolveType method, int extraInfo=-1)
Solve types.
int lastIterationNumber(int back=1) const
Returns previous iteration number (if -1) - current if (0)
void incrementReallyBadTimes()
Definition: ClpSolve.hpp:326
void clearTimesFlagged()
Definition: ClpSolve.hpp:333
void setDoDuprow(bool doDuprow_)
Definition: ClpSolve.hpp:190
int timesFlagged() const
number of times flagged
Definition: ClpSolve.hpp:330
double infeasibility_[CLP_PROGRESS]
Sum of infeasibilities for algorithm.
Definition: ClpSolve.hpp:348
void setDoKillSmall(bool doKill)
Definition: ClpSolve.hpp:206
int presolveActions() const
Set whole group.
Definition: ClpSolve.hpp:211
ClpSolve & operator=(const ClpSolve &rhs)
Assignment operator. This copies the data.
bool infeasibleReturn() const
Definition: ClpSolve.hpp:119
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
Definition: ClpSolve.hpp:139
void setInfeasibleReturn(bool trueFalse)
Say to return at once if infeasible, default is to solve.
int numberTimesFlagged_
Number of times no iterations as flagged.
Definition: ClpSolve.hpp:390
bool doTighten() const
Whether we want to do tighten part of presolve.
Definition: ClpSolve.hpp:155
~ClpSolve()
Destructor.
ClpSimplexProgress & operator=(const ClpSimplexProgress &rhs)
Assignment operator. This copies the data.
int oddState_
If things are in an odd state.
Definition: ClpSolve.hpp:392
int badTimes() const
number of bad times
Definition: ClpSolve.hpp:316
void setDoImpliedFree(bool doImpliedfree)
Definition: ClpSolve.hpp:174
ClpSimplexProgress()
Default constructor.
void setPresolveActions(int action)
Definition: ClpSolve.hpp:214
void modifyObjective(double value)
Modify objective e.g. if dual infeasible in dual.
double initialWeight_
Initial weight for weights.
Definition: ClpSolve.hpp:364
void setDoDoubleton(bool doDoubleton_)
Definition: ClpSolve.hpp:142
void setInfeasibility(double value)
Set real primal infeasibility and move back.
int oddState() const
Definition: ClpSolve.hpp:312
double objective_[CLP_PROGRESS]
Objective values.
Definition: ClpSolve.hpp:346
bool doForcing() const
Whether we want to do forcing part of presolve.
Definition: ClpSolve.hpp:163
int numberInfeasibilities_[CLP_PROGRESS]
Number of infeasibilities.
Definition: ClpSolve.hpp:374
char way_[CLP_CYCLE]
Definition: ClpSolve.hpp:370
PresolveType getPresolveType()
#define CLP_CYCLE
Definition: ClpSolve.hpp:365
bool doDual() const
Whether we want to do dual part of presolve.
Definition: ClpSolve.hpp:123
int numberBadTimes_
Number of times it looked like loop.
Definition: ClpSolve.hpp:386
void setSubstitution(int value)
Definition: ClpSolve.hpp:221
int substitution() const
Largest column for substitution (normally 3)
Definition: ClpSolve.hpp:218
int getExtraInfo(int which) const
Extra info for idiot (or sprint)