Clp 1.17.6

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ClpSolve.hpp
Go to the documentation of this file.
1 /* $Id: ClpSolve.hpp 2385 2019-01-06 19:43:06Z unxusr $ */
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,
26 usePrimal,
27 usePrimalorSprint,
28 useBarrier,
29 useBarrierNoCross,
30 automatic,
31 tryDantzigWolfe,
32 tryBenders,
33 notImplemented
34 };
35 enum PresolveType {
36 presolveOn = 0,
37 presolveOff,
38 presolveNumber,
39 presolveNumberCost
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);
109 SolveType getSolveType();
110
111 // Presolve types
112 void setPresolveType(PresolveType amount, int extraInfo = -1);
113 PresolveType getPresolveType();
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:
289 SolveType method_;
292 PresolveType presolveType_;
294 int numberPasses_;
296 int options_[7];
298 int extraInfo_[7];
305 int independentOptions_[3];
307 };
308
310 class ClpSimplexProgress {
311
312 public:
315 ClpSimplexProgress();
317
319 ClpSimplexProgress(ClpSimplex *model);
320
322 ClpSimplexProgress(const ClpSimplexProgress &);
323
325 ClpSimplexProgress &operator=(const ClpSimplexProgress &rhs);
327 ~ClpSimplexProgress();
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 }
391 inline void incrementReallyBadTimes()
392 {
393 numberReallyBadTimes_++;
394 }
396 inline int timesFlagged() const
397 {
398 return numberTimesFlagged_;
399 }
400 inline void clearTimesFlagged()
401 {
402 numberTimesFlagged_ = 0;
403 }
404 inline void incrementTimesFlagged()
405 {
406 numberTimesFlagged_++;
407 }
408
410
411 #define CLP_PROGRESS 5
412 //#define CLP_PROGRESS_WEIGHT 10
414 double objective_[CLP_PROGRESS];
417 double infeasibility_[CLP_PROGRESS];
419 double realInfeasibility_[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];
437 int in_[CLP_CYCLE];
438 int out_[CLP_CYCLE];
439 char way_[CLP_CYCLE];
441 ClpSimplex *model_;
443 int numberInfeasibilities_[CLP_PROGRESS];
445 int iterationNumber_[CLP_PROGRESS];
446 #ifdef CLP_PROGRESS_WEIGHT
447 int numberInfeasibilitiesWeight_[CLP_PROGRESS_WEIGHT];
450 int iterationNumberWeight_[CLP_PROGRESS_WEIGHT];
451 #endif
452 int numberTimes_;
455 int numberBadTimes_;
457 int numberReallyBadTimes_;
459 int numberTimesFlagged_;
461 int oddState_;
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 */
ClpSimplexProgress::reset
void reset()
Resets as much as possible.
ClpSolve::doSingletonColumn
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
Definition: ClpSolve.hpp:233
ClpSolve::tryDantzigWolfe
Definition: ClpSolve.hpp:31
ClpSolve
This is a very simple class to guide algorithms.
Definition: ClpSolve.hpp:20
ClpSimplexProgress::numberInfeasibilities
int numberInfeasibilities(int back=1) const
Returns number of primal infeasibilities (if -1) - current if (0)
ClpSolve::presolveNumberCost
Definition: ClpSolve.hpp:39
ClpSolve::doDupcol
bool doDupcol() const
Whether we want to do dupcol part of presolve.
Definition: ClpSolve.hpp:209
ClpSimplexProgress::startCheck
void startCheck()
Start check at beginning of whileIterating.
ClpSolve::setDoSingletonColumn
void setDoSingletonColumn(bool doSingleton_)
Definition: ClpSolve.hpp:237
ClpSolve::method_
SolveType method_
Solve type.
Definition: ClpSolve.hpp:290
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
ClpSimplexProgress::endOddState
void endOddState()
Definition: ClpSolve.hpp:365
ClpSolve::setIndependentOption
void setIndependentOption(int type, int value)
Definition: ClpSolve.hpp:274
ClpSolve::doSingleton
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition: ClpSolve.hpp:137
ClpSolve::getSpecialOption
int getSpecialOption(int which) const
ClpSolve::doImpliedFree
bool doImpliedFree() const
Whether we want to do impliedfree part of presolve.
Definition: ClpSolve.hpp:197
ClpSolve::usePrimalorSprint
Definition: ClpSolve.hpp:27
ClpSolve::getSolveType
SolveType getSolveType()
ClpSolve::useBarrierNoCross
Definition: ClpSolve.hpp:29
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::model_
ClpSimplex * model_
Pointer back to model so we can get information.
Definition: ClpSolve.hpp:441
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...
ClpSimplexProgress::out_
int out_[CLP_CYCLE]
Definition: ClpSolve.hpp:438
ClpSimplexProgress
For saving extra information to see if looping.
Definition: ClpSolve.hpp:310
ClpSimplexProgress::numberTimes_
int numberTimes_
Number of times checked (so won&#39;t stop too early)
Definition: ClpSolve.hpp:453
CLP_PROGRESS
#define CLP_PROGRESS
Definition: ClpSolve.hpp:411
ClpSolve::presolveNumber
Definition: ClpSolve.hpp:38
ClpSolve::usePrimal
Definition: ClpSolve.hpp:26
ClpSolve::PresolveType
PresolveType
Definition: ClpSolve.hpp:35
ClpSimplexProgress::newOddState
void newOddState()
Odd state.
Definition: ClpSolve.hpp:361
ClpSolve::doDuprow
bool doDuprow() const
Whether we want to do duprow part of presolve.
Definition: ClpSolve.hpp:221
ClpSolve::generateCpp
void generateCpp(FILE *fp)
Generates code for above constructor.
ClpSolve::presolveOff
Definition: ClpSolve.hpp:37
ClpSimplexProgress::looping
int looping()
Returns -1 if okay, -n+1 (n number of times bad) if bad but action taken, &gt;=0 if give up and use as p...
ClpSolve::setDoTripleton
void setDoTripleton(bool doTripleton_)
Definition: ClpSolve.hpp:165
ClpSolve::automatic
Definition: ClpSolve.hpp:30
ClpSolve::setPresolveType
void setPresolveType(PresolveType amount, int extraInfo=-1)
ClpConfig.h
ClpSolve::useDual
Definition: ClpSolve.hpp:25
ClpSolve::presolveOn
Definition: ClpSolve.hpp:36
ClpSimplexProgress::lastInfeasibility
double lastInfeasibility(int back=1) const
Returns real primal infeasibility (if -1) - current if (0)
ClpSolve::ClpSolve
ClpSolve()
Default constructor.
ClpSimplexProgress::~ClpSimplexProgress
~ClpSimplexProgress()
Destructor.
ClpSimplexProgress::cycle
int cycle(int in, int out, int wayIn, int wayOut)
Returns cycle length in whileIterating.
ClpSolve::useBarrier
Definition: ClpSolve.hpp:28
ClpSimplexProgress::in_
int in_[CLP_CYCLE]
For cycle checking.
Definition: ClpSolve.hpp:437
ClpSimplexProgress::numberReallyBadTimes_
int numberReallyBadTimes_
Number really bad times.
Definition: ClpSolve.hpp:457
ClpSolve::getPresolvePasses
int getPresolvePasses() const
ClpSimplexProgress::reallyBadTimes
int reallyBadTimes() const
number of really bad times
Definition: ClpSolve.hpp:387
ClpSimplexProgress::incrementTimesFlagged
void incrementTimesFlagged()
Definition: ClpSolve.hpp:404
AbcCommon.hpp
ClpSolve::setDoForcing
void setDoForcing(bool doForcing_)
Definition: ClpSolve.hpp:189
ClpSimplexProgress::clearIterationNumbers
void clearIterationNumbers()
clears all iteration numbers (to switch off panic)
ClpSimplex
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:106
ClpSolve::setDoDupcol
void setDoDupcol(bool doDupcol_)
Definition: ClpSolve.hpp:213
ClpSimplexProgress::fillFromModel
void fillFromModel(ClpSimplex *model)
Fill from model.
ClpSolve::doKillSmall
bool doKillSmall() const
Whether we want to kill small substitutions.
Definition: ClpSolve.hpp:245
ClpSolve::setDoTighten
void setDoTighten(bool doTighten_)
Definition: ClpSolve.hpp:177
ClpSolve::SolveType
SolveType
enums for solve function
Definition: ClpSolve.hpp:24
ClpSolve::setDoDual
void setDoDual(bool doDual_)
Definition: ClpSolve.hpp:129
ClpSimplexProgress::lastObjective
double lastObjective(int back=1) const
Returns previous objective (if -1) - current if (0)
ClpSimplexProgress::iterationNumber_
int iterationNumber_[CLP_PROGRESS]
Iteration number at which occurred.
Definition: ClpSolve.hpp:445
ClpSolve::setDoSingleton
void setDoSingleton(bool doSingleton_)
Definition: ClpSolve.hpp:141
ClpSimplexProgress::realInfeasibility_
double realInfeasibility_[CLP_PROGRESS]
Sum of real primal infeasibilities for primal.
Definition: ClpSolve.hpp:419
ClpSolve::setSolveType
void setSolveType(SolveType method, int extraInfo=-1)
Solve types.
ClpSimplexProgress::lastIterationNumber
int lastIterationNumber(int back=1) const
Returns previous iteration number (if -1) - current if (0)
ClpSimplexProgress::incrementReallyBadTimes
void incrementReallyBadTimes()
Definition: ClpSolve.hpp:391
ClpSimplexProgress::clearTimesFlagged
void clearTimesFlagged()
Definition: ClpSolve.hpp:400
ClpSolve::notImplemented
Definition: ClpSolve.hpp:33
ClpSolve::setDoDuprow
void setDoDuprow(bool doDuprow_)
Definition: ClpSolve.hpp:225
ClpSimplexProgress::timesFlagged
int timesFlagged() const
number of times flagged
Definition: ClpSolve.hpp:396
ClpSimplexProgress::infeasibility_
double infeasibility_[CLP_PROGRESS]
Sum of infeasibilities for algorithm.
Definition: ClpSolve.hpp:417
ClpSolve::setDoKillSmall
void setDoKillSmall(bool doKill)
Definition: ClpSolve.hpp:249
ClpSolve::presolveActions
int presolveActions() const
Set whole group.
Definition: ClpSolve.hpp:257
ClpSolve::operator=
ClpSolve & operator=(const ClpSolve &rhs)
Assignment operator. This copies the data.
ClpSimplexProgress::clearOddState
void clearOddState()
Definition: ClpSolve.hpp:369
ClpSolve::infeasibleReturn
bool infeasibleReturn() const
Definition: ClpSolve.hpp:120
ClpSolve::doDoubleton
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
Definition: ClpSolve.hpp:149
ClpSolve::setInfeasibleReturn
void setInfeasibleReturn(bool trueFalse)
Say to return at once if infeasible, default is to solve.
ClpSimplexProgress::numberTimesFlagged_
int numberTimesFlagged_
Number of times no iterations as flagged.
Definition: ClpSolve.hpp:459
ClpSolve::doTighten
bool doTighten() const
Whether we want to do tighten part of presolve.
Definition: ClpSolve.hpp:173
ClpSolve::~ClpSolve
~ClpSolve()
Destructor.
ClpSimplexProgress::operator=
ClpSimplexProgress & operator=(const ClpSimplexProgress &rhs)
Assignment operator. This copies the data.
ClpSimplexProgress::oddState_
int oddState_
If things are in an odd state.
Definition: ClpSolve.hpp:461
ClpSimplexProgress::badTimes
int badTimes() const
number of bad times
Definition: ClpSolve.hpp:378
ClpSolve::setDoImpliedFree
void setDoImpliedFree(bool doImpliedfree)
Definition: ClpSolve.hpp:201
ClpSolve::independentOption
int independentOption(int type) const
Definition: ClpSolve.hpp:278
ClpSolve::tryBenders
Definition: ClpSolve.hpp:32
ClpSimplexProgress::ClpSimplexProgress
ClpSimplexProgress()
Default constructor.
ClpSolve::setPresolveActions
void setPresolveActions(int action)
Definition: ClpSolve.hpp:261
ClpSimplexProgress::modifyObjective
void modifyObjective(double value)
Modify objective e.g. if dual infeasible in dual.
ClpSimplexProgress::initialWeight_
double initialWeight_
Initial weight for weights.
Definition: ClpSolve.hpp:433
ClpSolve::setDoDoubleton
void setDoDoubleton(bool doDoubleton_)
Definition: ClpSolve.hpp:153
ClpSolve::extraInfo_
int extraInfo_[7]
Extra information.
Definition: ClpSolve.hpp:298
ClpSolve::presolveType_
PresolveType presolveType_
Presolve type.
Definition: ClpSolve.hpp:292
ClpSimplexProgress::setInfeasibility
void setInfeasibility(double value)
Set real primal infeasibility and move back.
ClpSimplexProgress::oddState
int oddState() const
Definition: ClpSolve.hpp:373
ClpSimplexProgress::objective_
double objective_[CLP_PROGRESS]
Objective values.
Definition: ClpSolve.hpp:415
ClpSolve::numberPasses_
int numberPasses_
Amount of presolve.
Definition: ClpSolve.hpp:294
ClpSolve::doForcing
bool doForcing() const
Whether we want to do forcing part of presolve.
Definition: ClpSolve.hpp:185
ClpSimplexProgress::numberInfeasibilities_
int numberInfeasibilities_[CLP_PROGRESS]
Number of infeasibilities.
Definition: ClpSolve.hpp:443
ClpSimplexProgress::way_
char way_[CLP_CYCLE]
Definition: ClpSolve.hpp:439
ClpSimplexProgress::clearBadTimes
void clearBadTimes()
Definition: ClpSolve.hpp:382
ClpSolve::getPresolveType
PresolveType getPresolveType()
CLP_CYCLE
#define CLP_CYCLE
Definition: ClpSolve.hpp:434
ClpSolve::doDual
bool doDual() const
Whether we want to do dual part of presolve.
Definition: ClpSolve.hpp:125
ClpSimplexProgress::numberBadTimes_
int numberBadTimes_
Number of times it looked like loop.
Definition: ClpSolve.hpp:455
ClpSolve::setSubstitution
void setSubstitution(int value)
Definition: ClpSolve.hpp:270
ClpSolve::substitution
int substitution() const
Largest column for substitution (normally 3)
Definition: ClpSolve.hpp:266
ClpSolve::getExtraInfo
int getExtraInfo(int which) const
Extra info for idiot (or sprint)