Clp  1.17.8
ClpSolve.hpp
Go to the documentation of this file.
1 /* $Id$ */
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:
24  enum SolveType {
25  useDual = 0,
34  };
35  enum PresolveType {
40  };
41 
44  ClpSolve();
47  ClpSolve(SolveType method, PresolveType presolveType,
48  int numberPasses, int options[6],
49  int extraInfo[6], int independentOptions[3]);
51  void generateCpp(FILE *fp);
53  ClpSolve(const ClpSolve &);
55  ClpSolve &operator=(const ClpSolve &rhs);
57  ~ClpSolve();
59 
104  void setSpecialOption(int which, int value, int extraInfo = -1);
105  int getSpecialOption(int which) const;
106 
108  void setSolveType(SolveType method, int extraInfo = -1);
110 
111  // Presolve types
112  void setPresolveType(PresolveType amount, int extraInfo = -1);
114  int getPresolvePasses() const;
116  int getExtraInfo(int which) const;
119  void setInfeasibleReturn(bool trueFalse);
120  inline bool infeasibleReturn() const
121  {
122  return independentOptions_[0] != 0;
123  }
125  inline bool doDual() const
126  {
127  return (independentOptions_[1] & 1) == 0;
128  }
129  inline void setDoDual(bool doDual_)
130  {
131  if (doDual_)
132  independentOptions_[1] &= ~1;
133  else
134  independentOptions_[1] |= 1;
135  }
137  inline bool doSingleton() const
138  {
139  return (independentOptions_[1] & 2) == 0;
140  }
141  inline void setDoSingleton(bool doSingleton_)
142  {
143  if (doSingleton_)
144  independentOptions_[1] &= ~2;
145  else
146  independentOptions_[1] |= 2;
147  }
149  inline bool doDoubleton() const
150  {
151  return (independentOptions_[1] & 4) == 0;
152  }
153  inline void setDoDoubleton(bool doDoubleton_)
154  {
155  if (doDoubleton_)
156  independentOptions_[1] &= ~4;
157  else
158  independentOptions_[1] |= 4;
159  }
161  inline bool doTripleton() const
162  {
163  return (independentOptions_[1] & 8) == 0;
164  }
165  inline void setDoTripleton(bool doTripleton_)
166  {
167  if (doTripleton_)
168  independentOptions_[1] &= ~8;
169  else
170  independentOptions_[1] |= 8;
171  }
173  inline bool doTighten() const
174  {
175  return (independentOptions_[1] & 16) == 0;
176  }
177  inline void setDoTighten(bool doTighten_)
178  {
179  if (doTighten_)
180  independentOptions_[1] &= ~16;
181  else
182  independentOptions_[1] |= 16;
183  }
185  inline bool doForcing() const
186  {
187  return (independentOptions_[1] & 32) == 0;
188  }
189  inline void setDoForcing(bool doForcing_)
190  {
191  if (doForcing_)
192  independentOptions_[1] &= ~32;
193  else
194  independentOptions_[1] |= 32;
195  }
197  inline bool doImpliedFree() const
198  {
199  return (independentOptions_[1] & 64) == 0;
200  }
201  inline void setDoImpliedFree(bool doImpliedfree)
202  {
203  if (doImpliedfree)
204  independentOptions_[1] &= ~64;
205  else
206  independentOptions_[1] |= 64;
207  }
209  inline bool doDupcol() const
210  {
211  return (independentOptions_[1] & 128) == 0;
212  }
213  inline void setDoDupcol(bool doDupcol_)
214  {
215  if (doDupcol_)
216  independentOptions_[1] &= ~128;
217  else
218  independentOptions_[1] |= 128;
219  }
221  inline bool doDuprow() const
222  {
223  return (independentOptions_[1] & 256) == 0;
224  }
225  inline void setDoDuprow(bool doDuprow_)
226  {
227  if (doDuprow_)
228  independentOptions_[1] &= ~256;
229  else
230  independentOptions_[1] |= 256;
231  }
233  inline bool doSingletonColumn() const
234  {
235  return (independentOptions_[1] & 512) == 0;
236  }
237  inline void setDoSingletonColumn(bool doSingleton_)
238  {
239  if (doSingleton_)
240  independentOptions_[1] &= ~512;
241  else
242  independentOptions_[1] |= 512;
243  }
245  inline bool doKillSmall() const
246  {
247  return (independentOptions_[1] & 8192) == 0;
248  }
249  inline void setDoKillSmall(bool doKill)
250  {
251  if (doKill)
252  independentOptions_[1] &= ~8192;
253  else
254  independentOptions_[1] |= 8192;
255  }
257  inline int presolveActions() const
258  {
259  return independentOptions_[1] & 0xffffff;
260  }
261  inline void setPresolveActions(int action)
262  {
263  independentOptions_[1] = (independentOptions_[1] & 0xff000000) | (action & 0xffffff);
264  }
266  inline int substitution() const
267  {
268  return independentOptions_[2];
269  }
270  inline void setSubstitution(int value)
271  {
272  independentOptions_[2] = value;
273  }
274  inline void setIndependentOption(int type, int value)
275  {
276  independentOptions_[type] = value;
277  }
278  inline int independentOption(int type) const
279  {
280  return independentOptions_[type];
281  }
283 
285 private:
296  int options_[7];
298  int extraInfo_[7];
307 };
308 
311 
312 public:
317 
320 
323 
329  void reset();
331  void fillFromModel(ClpSimplex *model);
332 
334 
340  int looping();
342  void startCheck();
344  int cycle(int in, int out, int wayIn, int wayOut);
345 
347  double lastObjective(int back = 1) const;
349  void setInfeasibility(double value);
351  double lastInfeasibility(int back = 1) const;
353  int numberInfeasibilities(int back = 1) const;
355  void modifyObjective(double value);
357  int lastIterationNumber(int back = 1) const;
359  void clearIterationNumbers();
361  inline void newOddState()
362  {
363  oddState_ = -oddState_ - 1;
364  }
365  inline void endOddState()
366  {
367  oddState_ = abs(oddState_);
368  }
369  inline void clearOddState()
370  {
371  oddState_ = 0;
372  }
373  inline int oddState() const
374  {
375  return oddState_;
376  }
378  inline int badTimes() const
379  {
380  return numberBadTimes_;
381  }
382  inline void clearBadTimes()
383  {
384  numberBadTimes_ = 0;
385  }
387  inline int reallyBadTimes() const
388  {
389  return numberReallyBadTimes_;
390  }
392  {
394  }
396  inline int timesFlagged() const
397  {
398  return numberTimesFlagged_;
399  }
400  inline void clearTimesFlagged()
401  {
403  }
404  inline void incrementTimesFlagged()
405  {
407  }
408 
410 
411 #define CLP_PROGRESS 5
412  //#define CLP_PROGRESS_WEIGHT 10
414  double objective_[CLP_PROGRESS];
420 #ifdef CLP_PROGRESS_WEIGHT
421  double objectiveWeight_[CLP_PROGRESS_WEIGHT];
424  double infeasibilityWeight_[CLP_PROGRESS_WEIGHT];
426  double realInfeasibilityWeight_[CLP_PROGRESS_WEIGHT];
428  double drop_;
430  double best_;
431 #endif
432  double initialWeight_;
434 #define CLP_CYCLE 12
435  //double obj_[CLP_CYCLE];
446 #ifdef CLP_PROGRESS_WEIGHT
447  int numberInfeasibilitiesWeight_[CLP_PROGRESS_WEIGHT];
450  int iterationNumberWeight_[CLP_PROGRESS_WEIGHT];
451 #endif
452  int numberTimes_;
463 };
464 
465 #include "ClpConfig.h"
466 #if CLP_HAS_ABC
467 #include "AbcCommon.hpp"
469 class AbcSimplexProgress : public ClpSimplexProgress {
470 
471 public:
474  AbcSimplexProgress();
476 
478  AbcSimplexProgress(ClpSimplex *model);
479 
481  AbcSimplexProgress(const AbcSimplexProgress &);
482 
484  AbcSimplexProgress &operator=(const AbcSimplexProgress &rhs);
486  ~AbcSimplexProgress();
487 
489 
495  int looping();
496 
498 
500 };
501 #endif
502 #endif
503 
504 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
505 */
ClpSimplex
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:106
ClpSimplexProgress::oddState_
int oddState_
If things are in an odd state.
Definition: ClpSolve.hpp:461
CLP_CYCLE
#define CLP_CYCLE
Definition: ClpSolve.hpp:434
ClpSimplexProgress::clearOddState
void clearOddState()
Definition: ClpSolve.hpp:369
ClpSolve::tryBenders
@ tryBenders
Definition: ClpSolve.hpp:32
ClpSolve::doDual
bool doDual() const
Whether we want to do dual part of presolve.
Definition: ClpSolve.hpp:125
ClpSolve
This is a very simple class to guide algorithms.
Definition: ClpSolve.hpp:20
ClpSolve::usePrimal
@ usePrimal
Definition: ClpSolve.hpp:26
ClpSimplexProgress::newOddState
void newOddState()
Odd state.
Definition: ClpSolve.hpp:361
ClpSimplexProgress::fillFromModel
void fillFromModel(ClpSimplex *model)
Fill from model.
ClpSimplexProgress::objective_
double objective_[CLP_PROGRESS]
Objective values.
Definition: ClpSolve.hpp:415
ClpSolve::setIndependentOption
void setIndependentOption(int type, int value)
Definition: ClpSolve.hpp:274
ClpSolve::doTighten
bool doTighten() const
Whether we want to do tighten part of presolve.
Definition: ClpSolve.hpp:173
ClpSolve::setDoDoubleton
void setDoDoubleton(bool doDoubleton_)
Definition: ClpSolve.hpp:153
ClpSolve::tryDantzigWolfe
@ tryDantzigWolfe
Definition: ClpSolve.hpp:31
ClpSolve::automatic
@ automatic
Definition: ClpSolve.hpp:30
ClpSolve::numberPasses_
int numberPasses_
Amount of presolve.
Definition: ClpSolve.hpp:294
ClpSimplexProgress::lastInfeasibility
double lastInfeasibility(int back=1) const
Returns real primal infeasibility (if -1) - current if (0)
ClpSolve::doImpliedFree
bool doImpliedFree() const
Whether we want to do impliedfree part of presolve.
Definition: ClpSolve.hpp:197
ClpSolve::setDoDupcol
void setDoDupcol(bool doDupcol_)
Definition: ClpSolve.hpp:213
ClpSolve::presolveActions
int presolveActions() const
Set whole group.
Definition: ClpSolve.hpp:257
ClpSolve::setDoTripleton
void setDoTripleton(bool doTripleton_)
Definition: ClpSolve.hpp:165
ClpSolve::SolveType
SolveType
enums for solve function
Definition: ClpSolve.hpp:24
ClpSolve::doDupcol
bool doDupcol() const
Whether we want to do dupcol part of presolve.
Definition: ClpSolve.hpp:209
ClpSolve::getPresolveType
PresolveType getPresolveType()
ClpSimplexProgress::numberInfeasibilities
int numberInfeasibilities(int back=1) const
Returns number of primal infeasibilities (if -1) - current if (0)
ClpSolve::setDoDual
void setDoDual(bool doDual_)
Definition: ClpSolve.hpp:129
ClpSimplexProgress::out_
int out_[CLP_CYCLE]
Definition: ClpSolve.hpp:438
ClpSimplexProgress::clearTimesFlagged
void clearTimesFlagged()
Definition: ClpSolve.hpp:400
ClpSolve::presolveType_
PresolveType presolveType_
Presolve type.
Definition: ClpSolve.hpp:292
ClpSolve::substitution
int substitution() const
Largest column for substitution (normally 3)
Definition: ClpSolve.hpp:266
ClpSimplexProgress::realInfeasibility_
double realInfeasibility_[CLP_PROGRESS]
Sum of real primal infeasibilities for primal.
Definition: ClpSolve.hpp:419
ClpSolve::generateCpp
void generateCpp(FILE *fp)
Generates code for above constructor.
ClpSimplexProgress::infeasibility_
double infeasibility_[CLP_PROGRESS]
Sum of infeasibilities for algorithm.
Definition: ClpSolve.hpp:417
CLP_PROGRESS
#define CLP_PROGRESS
Definition: ClpSolve.hpp:411
ClpSolve::useBarrierNoCross
@ useBarrierNoCross
Definition: ClpSolve.hpp:29
ClpSimplexProgress
For saving extra information to see if looping.
Definition: ClpSolve.hpp:310
ClpSimplexProgress::lastObjective
double lastObjective(int back=1) const
Returns previous objective (if -1) - current if (0)
ClpSolve::doForcing
bool doForcing() const
Whether we want to do forcing part of presolve.
Definition: ClpSolve.hpp:185
ClpSolve::setDoKillSmall
void setDoKillSmall(bool doKill)
Definition: ClpSolve.hpp:249
ClpSimplexProgress::cycle
int cycle(int in, int out, int wayIn, int wayOut)
Returns cycle length in whileIterating.
ClpSolve::PresolveType
PresolveType
Definition: ClpSolve.hpp:35
ClpSolve::notImplemented
@ notImplemented
Definition: ClpSolve.hpp:33
AbcCommon.hpp
ClpSolve::ClpSolve
ClpSolve()
Default constructor.
ClpSimplexProgress::numberReallyBadTimes_
int numberReallyBadTimes_
Number really bad times.
Definition: ClpSolve.hpp:457
ClpSolve::presolveOff
@ presolveOff
Definition: ClpSolve.hpp:37
ClpSimplexProgress::incrementTimesFlagged
void incrementTimesFlagged()
Definition: ClpSolve.hpp:404
ClpSolve::setDoSingleton
void setDoSingleton(bool doSingleton_)
Definition: ClpSolve.hpp:141
ClpSolve::presolveNumber
@ presolveNumber
Definition: ClpSolve.hpp:38
ClpSimplexProgress::initialWeight_
double initialWeight_
Initial weight for weights.
Definition: ClpSolve.hpp:433
ClpSimplexProgress::clearIterationNumbers
void clearIterationNumbers()
clears all iteration numbers (to switch off panic)
ClpSimplexProgress::way_
char way_[CLP_CYCLE]
Definition: ClpSolve.hpp:439
ClpSolve::getExtraInfo
int getExtraInfo(int which) const
Extra info for idiot (or sprint)
ClpSolve::doTripleton
bool doTripleton() const
Whether we want to do tripleton part of presolve.
Definition: ClpSolve.hpp:161
ClpSolve::options_
int options_[7]
Options - last is switch for OsiClp.
Definition: ClpSolve.hpp:296
ClpSolve::getSolveType
SolveType getSolveType()
ClpSimplexProgress::looping
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...
ClpSimplexProgress::numberTimesFlagged_
int numberTimesFlagged_
Number of times no iterations as flagged.
Definition: ClpSolve.hpp:459
ClpSolve::useBarrier
@ useBarrier
Definition: ClpSolve.hpp:28
ClpSolve::useDual
@ useDual
Definition: ClpSolve.hpp:25
ClpSolve::independentOption
int independentOption(int type) const
Definition: ClpSolve.hpp:278
ClpSimplexProgress::reallyBadTimes
int reallyBadTimes() const
number of really bad times
Definition: ClpSolve.hpp:387
ClpSolve::setPresolveActions
void setPresolveActions(int action)
Definition: ClpSolve.hpp:261
ClpSolve::doSingleton
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition: ClpSolve.hpp:137
ClpSimplexProgress::iterationNumber_
int iterationNumber_[CLP_PROGRESS]
Iteration number at which occurred.
Definition: ClpSolve.hpp:445
ClpSolve::infeasibleReturn
bool infeasibleReturn() const
Definition: ClpSolve.hpp:120
ClpSolve::independentOptions_
int independentOptions_[3]
Extra algorithm dependent options 0 - if set return from clpsolve if infeasible 1 - To be copied over...
Definition: ClpSolve.hpp:305
ClpSimplexProgress::reset
void reset()
Resets as much as possible.
ClpSolve::setPresolveType
void setPresolveType(PresolveType amount, int extraInfo=-1)
ClpSolve::presolveOn
@ presolveOn
Definition: ClpSolve.hpp:36
ClpSolve::getSpecialOption
int getSpecialOption(int which) const
ClpSolve::setSubstitution
void setSubstitution(int value)
Definition: ClpSolve.hpp:270
ClpSimplexProgress::ClpSimplexProgress
ClpSimplexProgress()
Default constructor.
ClpSimplexProgress::incrementReallyBadTimes
void incrementReallyBadTimes()
Definition: ClpSolve.hpp:391
ClpSimplexProgress::modifyObjective
void modifyObjective(double value)
Modify objective e.g. if dual infeasible in dual.
ClpSolve::setSolveType
void setSolveType(SolveType method, int extraInfo=-1)
Solve types.
ClpSolve::getPresolvePasses
int getPresolvePasses() const
ClpSimplexProgress::model_
ClpSimplex * model_
Pointer back to model so we can get information.
Definition: ClpSolve.hpp:441
ClpSimplexProgress::~ClpSimplexProgress
~ClpSimplexProgress()
Destructor.
ClpSolve::operator=
ClpSolve & operator=(const ClpSolve &rhs)
Assignment operator. This copies the data.
ClpSimplexProgress::timesFlagged
int timesFlagged() const
number of times flagged
Definition: ClpSolve.hpp:396
ClpConfig.h
ClpSimplexProgress::setInfeasibility
void setInfeasibility(double value)
Set real primal infeasibility and move back.
ClpSolve::setDoImpliedFree
void setDoImpliedFree(bool doImpliedfree)
Definition: ClpSolve.hpp:201
ClpSolve::setDoTighten
void setDoTighten(bool doTighten_)
Definition: ClpSolve.hpp:177
ClpSolve::extraInfo_
int extraInfo_[7]
Extra information.
Definition: ClpSolve.hpp:298
ClpSolve::doDuprow
bool doDuprow() const
Whether we want to do duprow part of presolve.
Definition: ClpSolve.hpp:221
ClpSimplexProgress::clearBadTimes
void clearBadTimes()
Definition: ClpSolve.hpp:382
ClpSolve::setDoForcing
void setDoForcing(bool doForcing_)
Definition: ClpSolve.hpp:189
ClpSolve::~ClpSolve
~ClpSolve()
Destructor.
ClpSolve::setDoSingletonColumn
void setDoSingletonColumn(bool doSingleton_)
Definition: ClpSolve.hpp:237
ClpSimplexProgress::oddState
int oddState() const
Definition: ClpSolve.hpp:373
ClpSolve::setSpecialOption
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...
ClpSolve::setInfeasibleReturn
void setInfeasibleReturn(bool trueFalse)
Say to return at once if infeasible, default is to solve.
ClpSolve::method_
SolveType method_
Solve type.
Definition: ClpSolve.hpp:290
ClpSolve::setDoDuprow
void setDoDuprow(bool doDuprow_)
Definition: ClpSolve.hpp:225
ClpSimplexProgress::startCheck
void startCheck()
Start check at beginning of whileIterating.
ClpSolve::doSingletonColumn
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
Definition: ClpSolve.hpp:233
ClpSimplexProgress::badTimes
int badTimes() const
number of bad times
Definition: ClpSolve.hpp:378
ClpSolve::presolveNumberCost
@ presolveNumberCost
Definition: ClpSolve.hpp:39
ClpSimplexProgress::endOddState
void endOddState()
Definition: ClpSolve.hpp:365
ClpSimplexProgress::numberInfeasibilities_
int numberInfeasibilities_[CLP_PROGRESS]
Number of infeasibilities.
Definition: ClpSolve.hpp:443
ClpSimplexProgress::lastIterationNumber
int lastIterationNumber(int back=1) const
Returns previous iteration number (if -1) - current if (0)
ClpSolve::doKillSmall
bool doKillSmall() const
Whether we want to kill small substitutions.
Definition: ClpSolve.hpp:245
ClpSimplexProgress::in_
int in_[CLP_CYCLE]
For cycle checking.
Definition: ClpSolve.hpp:437
ClpSimplexProgress::numberBadTimes_
int numberBadTimes_
Number of times it looked like loop.
Definition: ClpSolve.hpp:455
ClpSolve::doDoubleton
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
Definition: ClpSolve.hpp:149
ClpSimplexProgress::operator=
ClpSimplexProgress & operator=(const ClpSimplexProgress &rhs)
Assignment operator. This copies the data.
ClpSimplexProgress::numberTimes_
int numberTimes_
Number of times checked (so won't stop too early)
Definition: ClpSolve.hpp:453
ClpSolve::usePrimalorSprint
@ usePrimalorSprint
Definition: ClpSolve.hpp:27