Clp 1.17.5
Loading...
Searching...
No Matches
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
20class ClpSolve {
21
22public:
41
47 ClpSolve(SolveType method, PresolveType presolveType,
48 int numberPasses, int options[6],
49 int extraInfo[6], int independentOptions[3]);
51 void generateCpp(FILE *fp);
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
285private:
296 int options_[7];
307};
308
311
312public:
317
320
323
329 void reset();
332
334
340 int looping();
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;
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 {
390 }
392 {
394 }
396 inline int timesFlagged() const
397 {
398 return numberTimesFlagged_;
399 }
400 inline void clearTimesFlagged()
401 {
403 }
405 {
407 }
408
410
411#define CLP_PROGRESS 5
412 //#define CLP_PROGRESS_WEIGHT 10
414
420#ifdef CLP_PROGRESS_WEIGHT
422 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
434#define CLP_CYCLE 12
436 //double obj_[CLP_CYCLE];
446#ifdef CLP_PROGRESS_WEIGHT
448 int numberInfeasibilitiesWeight_[CLP_PROGRESS_WEIGHT];
450 int iterationNumberWeight_[CLP_PROGRESS_WEIGHT];
451#endif
463};
464
465#include "ClpConfig.h"
466#if CLP_HAS_ABC
467#include "AbcCommon.hpp"
469class AbcSimplexProgress : public ClpSimplexProgress {
470
471public:
475 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*/
#define CLP_PROGRESS
Definition ClpSolve.hpp:411
#define CLP_CYCLE
Definition ClpSolve.hpp:434
For saving extra information to see if looping.
Definition ClpSolve.hpp:310
double realInfeasibility_[CLP_PROGRESS]
Sum of real primal infeasibilities for primal.
Definition ClpSolve.hpp:419
int numberTimes_
Number of times checked (so won't stop too early)
Definition ClpSolve.hpp:453
char way_[CLP_CYCLE]
Definition ClpSolve.hpp:439
int oddState_
If things are in an odd state.
Definition ClpSolve.hpp:461
void reset()
Resets as much as possible.
int oddState() const
Definition ClpSolve.hpp:373
void fillFromModel(ClpSimplex *model)
Fill from model.
void newOddState()
Odd state.
Definition ClpSolve.hpp:361
void startCheck()
Start check at beginning of whileIterating.
int numberInfeasibilities(int back=1) const
Returns number of primal infeasibilities (if -1) - current if (0)
int numberReallyBadTimes_
Number really bad times.
Definition ClpSolve.hpp:457
void modifyObjective(double value)
Modify objective e.g. if dual infeasible in dual.
int badTimes() const
number of bad times
Definition ClpSolve.hpp:378
void setInfeasibility(double value)
Set real primal infeasibility and move back.
double initialWeight_
Initial weight for weights.
Definition ClpSolve.hpp:433
double infeasibility_[CLP_PROGRESS]
Sum of infeasibilities for algorithm.
Definition ClpSolve.hpp:417
double lastInfeasibility(int back=1) const
Returns real primal infeasibility (if -1) - current if (0)
void clearIterationNumbers()
clears all iteration numbers (to switch off panic)
int reallyBadTimes() const
number of really bad times
Definition ClpSolve.hpp:387
int lastIterationNumber(int back=1) const
Returns previous iteration number (if -1) - current if (0)
int in_[CLP_CYCLE]
For cycle checking.
Definition ClpSolve.hpp:437
void incrementTimesFlagged()
Definition ClpSolve.hpp:404
int numberInfeasibilities_[CLP_PROGRESS]
Number of infeasibilities.
Definition ClpSolve.hpp:443
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...
double lastObjective(int back=1) const
Returns previous objective (if -1) - current if (0)
int cycle(int in, int out, int wayIn, int wayOut)
Returns cycle length in whileIterating.
ClpSimplex * model_
Pointer back to model so we can get information.
Definition ClpSolve.hpp:441
int iterationNumber_[CLP_PROGRESS]
Iteration number at which occurred.
Definition ClpSolve.hpp:445
int timesFlagged() const
number of times flagged
Definition ClpSolve.hpp:396
ClpSimplexProgress & operator=(const ClpSimplexProgress &rhs)
Assignment operator. This copies the data.
~ClpSimplexProgress()
Destructor.
double objective_[CLP_PROGRESS]
Objective values.
Definition ClpSolve.hpp:415
int numberBadTimes_
Number of times it looked like loop.
Definition ClpSolve.hpp:455
ClpSimplexProgress(const ClpSimplexProgress &)
Copy constructor.
int out_[CLP_CYCLE]
Definition ClpSolve.hpp:438
ClpSimplexProgress()
Default constructor.
ClpSimplexProgress(ClpSimplex *model)
Constructor from model.
int numberTimesFlagged_
Number of times no iterations as flagged.
Definition ClpSolve.hpp:459
void incrementReallyBadTimes()
Definition ClpSolve.hpp:391
This solves LPs using the simplex method.
This is a very simple class to guide algorithms.
Definition ClpSolve.hpp:20
int independentOptions_[3]
Extra algorithm dependent options 0 - if set return from clpsolve if infeasible 1 - To be copied over...
Definition ClpSolve.hpp:305
void setDoForcing(bool doForcing_)
Definition ClpSolve.hpp:189
void setDoDual(bool doDual_)
Definition ClpSolve.hpp:129
int extraInfo_[7]
Extra information.
Definition ClpSolve.hpp:298
ClpSolve(SolveType method, PresolveType presolveType, int numberPasses, int options[6], int extraInfo[6], int independentOptions[3])
Constructor when you really know what you are doing.
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
Definition ClpSolve.hpp:233
~ClpSolve()
Destructor.
int getExtraInfo(int which) const
Extra info for idiot (or sprint)
void setDoSingletonColumn(bool doSingleton_)
Definition ClpSolve.hpp:237
bool doDupcol() const
Whether we want to do dupcol part of presolve.
Definition ClpSolve.hpp:209
void setInfeasibleReturn(bool trueFalse)
Say to return at once if infeasible, default is to solve.
bool doTripleton() const
Whether we want to do tripleton part of presolve.
Definition ClpSolve.hpp:161
SolveType
enums for solve function
Definition ClpSolve.hpp:24
@ notImplemented
Definition ClpSolve.hpp:33
@ tryDantzigWolfe
Definition ClpSolve.hpp:31
@ usePrimalorSprint
Definition ClpSolve.hpp:27
@ useBarrierNoCross
Definition ClpSolve.hpp:29
void setDoDuprow(bool doDuprow_)
Definition ClpSolve.hpp:225
PresolveType presolveType_
Presolve type.
Definition ClpSolve.hpp:292
bool doTighten() const
Whether we want to do tighten part of presolve.
Definition ClpSolve.hpp:173
SolveType getSolveType()
int independentOption(int type) const
Definition ClpSolve.hpp:278
ClpSolve & operator=(const ClpSolve &rhs)
Assignment operator. This copies the data.
int numberPasses_
Amount of presolve.
Definition ClpSolve.hpp:294
ClpSolve(const ClpSolve &)
Copy constructor.
@ presolveNumberCost
Definition ClpSolve.hpp:39
@ presolveOff
Definition ClpSolve.hpp:37
@ presolveNumber
Definition ClpSolve.hpp:38
int substitution() const
Largest column for substitution (normally 3)
Definition ClpSolve.hpp:266
void setPresolveActions(int action)
Definition ClpSolve.hpp:261
int presolveActions() const
Set whole group.
Definition ClpSolve.hpp:257
SolveType method_
Solve type.
Definition ClpSolve.hpp:290
bool doForcing() const
Whether we want to do forcing part of presolve.
Definition ClpSolve.hpp:185
void setSolveType(SolveType method, int extraInfo=-1)
Solve types.
int getPresolvePasses() const
void setSubstitution(int value)
Definition ClpSolve.hpp:270
bool doImpliedFree() const
Whether we want to do impliedfree part of presolve.
Definition ClpSolve.hpp:197
bool doDual() const
Whether we want to do dual part of presolve.
Definition ClpSolve.hpp:125
void setIndependentOption(int type, int value)
Definition ClpSolve.hpp:274
void generateCpp(FILE *fp)
Generates code for above constructor.
int getSpecialOption(int which) const
bool doKillSmall() const
Whether we want to kill small substitutions.
Definition ClpSolve.hpp:245
void setDoImpliedFree(bool doImpliedfree)
Definition ClpSolve.hpp:201
void setDoTripleton(bool doTripleton_)
Definition ClpSolve.hpp:165
void setDoDupcol(bool doDupcol_)
Definition ClpSolve.hpp:213
int options_[7]
Options - last is switch for OsiClp.
Definition ClpSolve.hpp:296
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition ClpSolve.hpp:137
bool doDuprow() const
Whether we want to do duprow part of presolve.
Definition ClpSolve.hpp:221
void setDoDoubleton(bool doDoubleton_)
Definition ClpSolve.hpp:153
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
Definition ClpSolve.hpp:149
PresolveType getPresolveType()
void setDoSingleton(bool doSingleton_)
Definition ClpSolve.hpp:141
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...
void setDoTighten(bool doTighten_)
Definition ClpSolve.hpp:177
void setDoKillSmall(bool doKill)
Definition ClpSolve.hpp:249
void setPresolveType(PresolveType amount, int extraInfo=-1)
bool infeasibleReturn() const
Definition ClpSolve.hpp:120
ClpSolve()
Default constructor.