Clp 1.16.9
Loading...
Searching...
No Matches
ClpSolve.hpp
Go to the documentation of this file.
1/* $Id: ClpSolve.hpp 2078 2015-01-05 12:39:49Z forrest $ */
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:
23
25 enum SolveType {
35 };
41 };
42
48 ClpSolve ( SolveType method, PresolveType presolveType,
49 int numberPasses, int options[6],
50 int extraInfo[6], int independentOptions[3]);
52 void generateCpp(FILE * fp);
56 ClpSolve & operator=(const ClpSolve & rhs);
60
105 void setSpecialOption(int which, int value, int extraInfo = -1);
106 int getSpecialOption(int which) const;
107
109 void setSolveType(SolveType method, int extraInfo = -1);
111
112 // Presolve types
113 void setPresolveType(PresolveType amount, int extraInfo = -1);
115 int getPresolvePasses() const;
117 int getExtraInfo(int which) const;
120 void setInfeasibleReturn(bool trueFalse);
121 inline bool infeasibleReturn() const {
122 return independentOptions_[0] != 0;
123 }
125 inline bool doDual() const {
126 return (independentOptions_[1] & 1) == 0;
127 }
128 inline void setDoDual(bool doDual_) {
129 if (doDual_) independentOptions_[1] &= ~1;
130 else independentOptions_[1] |= 1;
131 }
133 inline bool doSingleton() const {
134 return (independentOptions_[1] & 2) == 0;
135 }
136 inline void setDoSingleton(bool doSingleton_) {
137 if (doSingleton_) independentOptions_[1] &= ~2;
138 else independentOptions_[1] |= 2;
139 }
141 inline bool doDoubleton() const {
142 return (independentOptions_[1] & 4) == 0;
143 }
144 inline void setDoDoubleton(bool doDoubleton_) {
145 if (doDoubleton_) independentOptions_[1] &= ~4;
146 else independentOptions_[1] |= 4;
147 }
149 inline bool doTripleton() const {
150 return (independentOptions_[1] & 8) == 0;
151 }
152 inline void setDoTripleton(bool doTripleton_) {
153 if (doTripleton_) independentOptions_[1] &= ~8;
154 else independentOptions_[1] |= 8;
155 }
157 inline bool doTighten() const {
158 return (independentOptions_[1] & 16) == 0;
159 }
160 inline void setDoTighten(bool doTighten_) {
161 if (doTighten_) independentOptions_[1] &= ~16;
162 else independentOptions_[1] |= 16;
163 }
165 inline bool doForcing() const {
166 return (independentOptions_[1] & 32) == 0;
167 }
168 inline void setDoForcing(bool doForcing_) {
169 if (doForcing_) independentOptions_[1] &= ~32;
170 else independentOptions_[1] |= 32;
171 }
173 inline bool doImpliedFree() const {
174 return (independentOptions_[1] & 64) == 0;
175 }
176 inline void setDoImpliedFree(bool doImpliedfree) {
177 if (doImpliedfree) independentOptions_[1] &= ~64;
178 else independentOptions_[1] |= 64;
179 }
181 inline bool doDupcol() const {
182 return (independentOptions_[1] & 128) == 0;
183 }
184 inline void setDoDupcol(bool doDupcol_) {
185 if (doDupcol_) independentOptions_[1] &= ~128;
186 else independentOptions_[1] |= 128;
187 }
189 inline bool doDuprow() const {
190 return (independentOptions_[1] & 256) == 0;
191 }
192 inline void setDoDuprow(bool doDuprow_) {
193 if (doDuprow_) independentOptions_[1] &= ~256;
194 else independentOptions_[1] |= 256;
195 }
197 inline bool doSingletonColumn() const {
198 return (independentOptions_[1] & 512) == 0;
199 }
200 inline void setDoSingletonColumn(bool doSingleton_) {
201 if (doSingleton_) independentOptions_[1] &= ~512;
202 else independentOptions_[1] |= 512;
203 }
205 inline bool doKillSmall() const {
206 return (independentOptions_[1] & 8192) == 0;
207 }
208 inline void setDoKillSmall(bool doKill) {
209 if (doKill) independentOptions_[1] &= ~8192;
210 else independentOptions_[1] |= 8192;
211 }
213 inline int presolveActions() const {
214 return independentOptions_[1] & 0xffff;
215 }
216 inline void setPresolveActions(int action) {
217 independentOptions_[1] = (independentOptions_[1] & 0xffff0000) | (action & 0xffff);
218 }
220 inline int substitution() const {
221 return independentOptions_[2];
222 }
223 inline void setSubstitution(int value) {
224 independentOptions_[2] = value;
225 }
226 inline void setIndependentOption(int type,int value) {
227 independentOptions_[type] = value;
228 }
229 inline int independentOption(int type) const {
230 return independentOptions_[type];
231 }
233
235private:
236
241 SolveType method_;
243 PresolveType presolveType_;
245 int numberPasses_;
247 int options_[7];
249 int extraInfo_[7];
256 int independentOptions_[3];
258};
259
262
263public:
264
265
270
273
276
282 void reset();
284 void fillFromModel ( ClpSimplex * model );
285
287
293 int looping ( );
297 int cycle(int in, int out, int wayIn, int wayOut);
298
300 double lastObjective(int back = 1) const;
302 void setInfeasibility(double value);
304 double lastInfeasibility(int back = 1) const;
306 int numberInfeasibilities(int back = 1) const;
308 void modifyObjective(double value);
310 int lastIterationNumber(int back = 1) const;
314 inline void newOddState() {
315 oddState_ = - oddState_ - 1;
316 }
317 inline void endOddState() {
318 oddState_ = abs(oddState_);
319 }
320 inline void clearOddState() {
321 oddState_ = 0;
322 }
323 inline int oddState() const {
324 return oddState_;
325 }
327 inline int badTimes() const {
328 return numberBadTimes_;
329 }
330 inline void clearBadTimes() {
331 numberBadTimes_ = 0;
332 }
334 inline int reallyBadTimes() const {
336 }
339 }
341 inline int timesFlagged() const {
342 return numberTimesFlagged_;
343 }
344 inline void clearTimesFlagged() {
346 }
347 inline void incrementTimesFlagged() {
349 }
350
352
353#define CLP_PROGRESS 5
354 //#define CLP_PROGRESS_WEIGHT 10
356
362#ifdef CLP_PROGRESS_WEIGHT
364 double objectiveWeight_[CLP_PROGRESS_WEIGHT];
366 double infeasibilityWeight_[CLP_PROGRESS_WEIGHT];
368 double realInfeasibilityWeight_[CLP_PROGRESS_WEIGHT];
370 double drop_;
372 double best_;
373#endif
376#define CLP_CYCLE 12
378 //double obj_[CLP_CYCLE];
388#ifdef CLP_PROGRESS_WEIGHT
390 int numberInfeasibilitiesWeight_[CLP_PROGRESS_WEIGHT];
392 int iterationNumberWeight_[CLP_PROGRESS_WEIGHT];
393#endif
405};
406
407#include "ClpConfig.h"
408#if CLP_HAS_ABC
409#include "AbcCommon.hpp"
411class AbcSimplexProgress : public ClpSimplexProgress {
412
413public:
414
415
419 AbcSimplexProgress ( );
420
422 AbcSimplexProgress ( ClpSimplex * model );
423
425 AbcSimplexProgress(const AbcSimplexProgress &);
426
428 AbcSimplexProgress & operator=(const AbcSimplexProgress & rhs);
430 ~AbcSimplexProgress ( );
431
433
439 int looping ( );
440
442
444};
445#endif
446#endif
#define CLP_PROGRESS
Definition: ClpSolve.hpp:353
#define CLP_CYCLE
Definition: ClpSolve.hpp:376
For saving extra information to see if looping.
Definition: ClpSolve.hpp:261
double realInfeasibility_[CLP_PROGRESS]
Sum of real primal infeasibilities for primal.
Definition: ClpSolve.hpp:361
int numberTimes_
Number of times checked (so won't stop too early)
Definition: ClpSolve.hpp:395
char way_[CLP_CYCLE]
Definition: ClpSolve.hpp:381
int oddState_
If things are in an odd state.
Definition: ClpSolve.hpp:403
void reset()
Resets as much as possible.
int oddState() const
Definition: ClpSolve.hpp:323
void fillFromModel(ClpSimplex *model)
Fill from model.
void newOddState()
Odd state.
Definition: ClpSolve.hpp:314
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:399
void modifyObjective(double value)
Modify objective e.g. if dual infeasible in dual.
int badTimes() const
number of bad times
Definition: ClpSolve.hpp:327
void setInfeasibility(double value)
Set real primal infeasibility and move back.
void clearTimesFlagged()
Definition: ClpSolve.hpp:344
double initialWeight_
Initial weight for weights.
Definition: ClpSolve.hpp:375
double infeasibility_[CLP_PROGRESS]
Sum of infeasibilities for algorithm.
Definition: ClpSolve.hpp:359
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:334
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:379
void incrementTimesFlagged()
Definition: ClpSolve.hpp:347
int numberInfeasibilities_[CLP_PROGRESS]
Number of infeasibilities.
Definition: ClpSolve.hpp:385
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:383
int iterationNumber_[CLP_PROGRESS]
Iteration number at which occurred.
Definition: ClpSolve.hpp:387
int timesFlagged() const
number of times flagged
Definition: ClpSolve.hpp:341
ClpSimplexProgress & operator=(const ClpSimplexProgress &rhs)
Assignment operator. This copies the data.
~ClpSimplexProgress()
Destructor.
double objective_[CLP_PROGRESS]
Objective values.
Definition: ClpSolve.hpp:357
int numberBadTimes_
Number of times it looked like loop.
Definition: ClpSolve.hpp:397
ClpSimplexProgress(const ClpSimplexProgress &)
Copy constructor.
int out_[CLP_CYCLE]
Definition: ClpSolve.hpp:380
ClpSimplexProgress()
Default constructor.
ClpSimplexProgress(ClpSimplex *model)
Constructor from model.
int numberTimesFlagged_
Number of times no iterations as flagged.
Definition: ClpSolve.hpp:401
void incrementReallyBadTimes()
Definition: ClpSolve.hpp:337
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:70
This is a very simple class to guide algorithms.
Definition: ClpSolve.hpp:20
void setDoForcing(bool doForcing_)
Definition: ClpSolve.hpp:168
void setDoDual(bool doDual_)
Definition: ClpSolve.hpp:128
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:197
~ClpSolve()
Destructor.
int getExtraInfo(int which) const
Extra info for idiot (or sprint)
void setDoSingletonColumn(bool doSingleton_)
Definition: ClpSolve.hpp:200
bool doDupcol() const
Whether we want to do dupcol part of presolve.
Definition: ClpSolve.hpp:181
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:149
SolveType
enums for solve function
Definition: ClpSolve.hpp:25
@ tryBenders
Definition: ClpSolve.hpp:33
@ automatic
Definition: ClpSolve.hpp:31
@ useBarrier
Definition: ClpSolve.hpp:29
@ notImplemented
Definition: ClpSolve.hpp:34
@ tryDantzigWolfe
Definition: ClpSolve.hpp:32
@ usePrimal
Definition: ClpSolve.hpp:27
@ usePrimalorSprint
Definition: ClpSolve.hpp:28
@ useBarrierNoCross
Definition: ClpSolve.hpp:30
void setDoDuprow(bool doDuprow_)
Definition: ClpSolve.hpp:192
bool doTighten() const
Whether we want to do tighten part of presolve.
Definition: ClpSolve.hpp:157
SolveType getSolveType()
int independentOption(int type) const
Definition: ClpSolve.hpp:229
ClpSolve & operator=(const ClpSolve &rhs)
Assignment operator. This copies the data.
ClpSolve(const ClpSolve &)
Copy constructor.
@ presolveNumberCost
Definition: ClpSolve.hpp:40
@ presolveOff
Definition: ClpSolve.hpp:38
@ presolveOn
Definition: ClpSolve.hpp:37
@ presolveNumber
Definition: ClpSolve.hpp:39
int substitution() const
Largest column for substitution (normally 3)
Definition: ClpSolve.hpp:220
void setPresolveActions(int action)
Definition: ClpSolve.hpp:216
int presolveActions() const
Set whole group.
Definition: ClpSolve.hpp:213
bool doForcing() const
Whether we want to do forcing part of presolve.
Definition: ClpSolve.hpp:165
void setSolveType(SolveType method, int extraInfo=-1)
Solve types.
int getPresolvePasses() const
void setSubstitution(int value)
Definition: ClpSolve.hpp:223
bool doImpliedFree() const
Whether we want to do impliedfree part of presolve.
Definition: ClpSolve.hpp:173
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:226
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:205
void setDoImpliedFree(bool doImpliedfree)
Definition: ClpSolve.hpp:176
void setDoTripleton(bool doTripleton_)
Definition: ClpSolve.hpp:152
void setDoDupcol(bool doDupcol_)
Definition: ClpSolve.hpp:184
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition: ClpSolve.hpp:133
bool doDuprow() const
Whether we want to do duprow part of presolve.
Definition: ClpSolve.hpp:189
void setDoDoubleton(bool doDoubleton_)
Definition: ClpSolve.hpp:144
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
Definition: ClpSolve.hpp:141
PresolveType getPresolveType()
void setDoSingleton(bool doSingleton_)
Definition: ClpSolve.hpp:136
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:160
void setDoKillSmall(bool doKill)
Definition: ClpSolve.hpp:208
void setPresolveType(PresolveType amount, int extraInfo=-1)
bool infeasibleReturn() const
Definition: ClpSolve.hpp:121
ClpSolve()
Default constructor.