1 | // Copyright (C) 2002, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | |
---|
4 | /* |
---|
5 | Authors |
---|
6 | |
---|
7 | John Forrest |
---|
8 | |
---|
9 | */ |
---|
10 | #ifndef ClpSimplex_H |
---|
11 | #define ClpSimplex_H |
---|
12 | |
---|
13 | #if defined(_MSC_VER) |
---|
14 | // Turn off compiler warning about long names |
---|
15 | # pragma warning(disable:4786) |
---|
16 | #endif |
---|
17 | |
---|
18 | #include <iostream> |
---|
19 | #include <cfloat> |
---|
20 | #include "ClpModel.hpp" |
---|
21 | #include "ClpMatrixBase.hpp" |
---|
22 | #include "ClpSolve.hpp" |
---|
23 | class ClpDualRowPivot; |
---|
24 | class ClpPrimalColumnPivot; |
---|
25 | class ClpFactorization; |
---|
26 | class CoinIndexedVector; |
---|
27 | class ClpNonLinearCost; |
---|
28 | class ClpSimplexProgress; |
---|
29 | class CoinModel; |
---|
30 | class OsiClpSolverInterface; |
---|
31 | class CoinWarmStartBasis; |
---|
32 | class ClpDisasterHandler; |
---|
33 | |
---|
34 | /** This solves LPs using the simplex method |
---|
35 | |
---|
36 | It inherits from ClpModel and all its arrays are created at |
---|
37 | algorithm time. Originally I tried to work with model arrays |
---|
38 | but for simplicity of coding I changed to single arrays with |
---|
39 | structural variables then row variables. Some coding is still |
---|
40 | based on old style and needs cleaning up. |
---|
41 | |
---|
42 | For a description of algorithms: |
---|
43 | |
---|
44 | for dual see ClpSimplexDual.hpp and at top of ClpSimplexDual.cpp |
---|
45 | for primal see ClpSimplexPrimal.hpp and at top of ClpSimplexPrimal.cpp |
---|
46 | |
---|
47 | There is an algorithm data member. + for primal variations |
---|
48 | and - for dual variations |
---|
49 | |
---|
50 | This file also includes (at end) a very simple class ClpSimplexProgress |
---|
51 | which is where anti-looping stuff should migrate to |
---|
52 | |
---|
53 | */ |
---|
54 | |
---|
55 | class ClpSimplex : public ClpModel { |
---|
56 | friend void ClpSimplexUnitTest(const std::string & mpsDir, |
---|
57 | const std::string & netlibDir); |
---|
58 | |
---|
59 | public: |
---|
60 | /** enums for status of various sorts. |
---|
61 | First 4 match CoinWarmStartBasis, |
---|
62 | isFixed means fixed at lower bound and out of basis |
---|
63 | */ |
---|
64 | enum Status { |
---|
65 | isFree = 0x00, |
---|
66 | basic = 0x01, |
---|
67 | atUpperBound = 0x02, |
---|
68 | atLowerBound = 0x03, |
---|
69 | superBasic = 0x04, |
---|
70 | isFixed = 0x05 |
---|
71 | }; |
---|
72 | // For Dual |
---|
73 | enum FakeBound { |
---|
74 | noFake = 0x00, |
---|
75 | bothFake = 0x01, |
---|
76 | upperFake = 0x02, |
---|
77 | lowerFake = 0x03 |
---|
78 | }; |
---|
79 | |
---|
80 | /**@name Constructors and destructor and copy */ |
---|
81 | //@{ |
---|
82 | /// Default constructor |
---|
83 | ClpSimplex ( ); |
---|
84 | |
---|
85 | /** Copy constructor. May scale depending on mode |
---|
86 | -1 leave mode as is |
---|
87 | 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) |
---|
88 | */ |
---|
89 | ClpSimplex(const ClpSimplex & rhs, int scalingMode =-1); |
---|
90 | /** Copy constructor from model. May scale depending on mode |
---|
91 | -1 leave mode as is |
---|
92 | 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) |
---|
93 | */ |
---|
94 | ClpSimplex(const ClpModel & rhs, int scalingMode=-1); |
---|
95 | /** Subproblem constructor. A subset of whole model is created from the |
---|
96 | row and column lists given. The new order is given by list order and |
---|
97 | duplicates are allowed. Name and integer information can be dropped |
---|
98 | Can optionally modify rhs to take into account variables NOT in list |
---|
99 | in this case duplicates are not allowed (also see getbackSolution) |
---|
100 | */ |
---|
101 | ClpSimplex (const ClpModel * wholeModel, |
---|
102 | int numberRows, const int * whichRows, |
---|
103 | int numberColumns, const int * whichColumns, |
---|
104 | bool dropNames=true, bool dropIntegers=true, |
---|
105 | bool fixOthers=false); |
---|
106 | /** This constructor modifies original ClpSimplex and stores |
---|
107 | original stuff in created ClpSimplex. It is only to be used in |
---|
108 | conjunction with originalModel */ |
---|
109 | ClpSimplex (ClpSimplex * wholeModel, |
---|
110 | int numberColumns, const int * whichColumns); |
---|
111 | /** This copies back stuff from miniModel and then deletes miniModel. |
---|
112 | Only to be used with mini constructor */ |
---|
113 | void originalModel(ClpSimplex * miniModel); |
---|
114 | /** |
---|
115 | If you are re-using the same matrix again and again then the setup time |
---|
116 | to do scaling may be significant. Also you may not want to initialize all values |
---|
117 | or return all values (especially if infeasible). While an auxiliary model exists |
---|
118 | it will be faster. If options -1 then model is switched off. Otherwise switched on |
---|
119 | with following options. |
---|
120 | 1 - rhs is constant |
---|
121 | 2 - bounds are constant |
---|
122 | 4 - objective is constant |
---|
123 | 8 - solution in by basis and no djs etc in |
---|
124 | 16 - no duals out (but reduced costs) |
---|
125 | 32 - no output if infeasible |
---|
126 | */ |
---|
127 | void auxiliaryModel(int options); |
---|
128 | /// Switch off e.g. if people using presolve |
---|
129 | void deleteAuxiliaryModel(); |
---|
130 | /// See if we have auxiliary model |
---|
131 | inline bool usingAuxiliaryModel() const |
---|
132 | { return auxiliaryModel_!=NULL;}; |
---|
133 | /// Assignment operator. This copies the data |
---|
134 | ClpSimplex & operator=(const ClpSimplex & rhs); |
---|
135 | /// Destructor |
---|
136 | ~ClpSimplex ( ); |
---|
137 | // Ones below are just ClpModel with some changes |
---|
138 | /** Loads a problem (the constraints on the |
---|
139 | rows are given by lower and upper bounds). If a pointer is 0 then the |
---|
140 | following values are the default: |
---|
141 | <ul> |
---|
142 | <li> <code>colub</code>: all columns have upper bound infinity |
---|
143 | <li> <code>collb</code>: all columns have lower bound 0 |
---|
144 | <li> <code>rowub</code>: all rows have upper bound infinity |
---|
145 | <li> <code>rowlb</code>: all rows have lower bound -infinity |
---|
146 | <li> <code>obj</code>: all variables have 0 objective coefficient |
---|
147 | </ul> |
---|
148 | */ |
---|
149 | void loadProblem ( const ClpMatrixBase& matrix, |
---|
150 | const double* collb, const double* colub, |
---|
151 | const double* obj, |
---|
152 | const double* rowlb, const double* rowub, |
---|
153 | const double * rowObjective=NULL); |
---|
154 | void loadProblem ( const CoinPackedMatrix& matrix, |
---|
155 | const double* collb, const double* colub, |
---|
156 | const double* obj, |
---|
157 | const double* rowlb, const double* rowub, |
---|
158 | const double * rowObjective=NULL); |
---|
159 | |
---|
160 | /** Just like the other loadProblem() method except that the matrix is |
---|
161 | given in a standard column major ordered format (without gaps). */ |
---|
162 | void loadProblem ( const int numcols, const int numrows, |
---|
163 | const CoinBigIndex* start, const int* index, |
---|
164 | const double* value, |
---|
165 | const double* collb, const double* colub, |
---|
166 | const double* obj, |
---|
167 | const double* rowlb, const double* rowub, |
---|
168 | const double * rowObjective=NULL); |
---|
169 | /// This one is for after presolve to save memory |
---|
170 | void loadProblem ( const int numcols, const int numrows, |
---|
171 | const CoinBigIndex* start, const int* index, |
---|
172 | const double* value,const int * length, |
---|
173 | const double* collb, const double* colub, |
---|
174 | const double* obj, |
---|
175 | const double* rowlb, const double* rowub, |
---|
176 | const double * rowObjective=NULL); |
---|
177 | /** This loads a model from a coinModel object - returns number of errors. |
---|
178 | If keepSolution true and size is same as current then |
---|
179 | keeps current status and solution |
---|
180 | */ |
---|
181 | int loadProblem ( CoinModel & modelObject,bool keepSolution=false); |
---|
182 | /// Read an mps file from the given filename |
---|
183 | int readMps(const char *filename, |
---|
184 | bool keepNames=false, |
---|
185 | bool ignoreErrors = false); |
---|
186 | /// Read GMPL files from the given filenames |
---|
187 | int readGMPL(const char *filename,const char * dataName, |
---|
188 | bool keepNames=false); |
---|
189 | /** Borrow model. This is so we dont have to copy large amounts |
---|
190 | of data around. It assumes a derived class wants to overwrite |
---|
191 | an empty model with a real one - while it does an algorithm. |
---|
192 | This is same as ClpModel one, but sets scaling on etc. */ |
---|
193 | void borrowModel(ClpModel & otherModel); |
---|
194 | void borrowModel(ClpSimplex & otherModel); |
---|
195 | /// Pass in Event handler (cloned and deleted at end) |
---|
196 | void passInEventHandler(const ClpEventHandler * eventHandler); |
---|
197 | /// Puts solution back into small model |
---|
198 | void getbackSolution(const ClpSimplex & smallModel,const int * whichRow, const int * whichColumn); |
---|
199 | //@} |
---|
200 | |
---|
201 | /**@name Functions most useful to user */ |
---|
202 | //@{ |
---|
203 | /** General solve algorithm which can do presolve. |
---|
204 | See ClpSolve.hpp for options |
---|
205 | */ |
---|
206 | int initialSolve(ClpSolve & options); |
---|
207 | /// Default initial solve |
---|
208 | int initialSolve(); |
---|
209 | /// Dual initial solve |
---|
210 | int initialDualSolve(); |
---|
211 | /// Primal initial solve |
---|
212 | int initialPrimalSolve(); |
---|
213 | /// Barrier initial solve |
---|
214 | int initialBarrierSolve(); |
---|
215 | /// Barrier initial solve, not to be followed by crossover |
---|
216 | int initialBarrierNoCrossSolve(); |
---|
217 | |
---|
218 | /** Dual algorithm - see ClpSimplexDual.hpp for method. |
---|
219 | ifValuesPass==2 just does values pass and then stops. |
---|
220 | |
---|
221 | startFinishOptions - bits |
---|
222 | 1 - do not delete work areas and factorization at end |
---|
223 | 2 - use old factorization if same number of rows |
---|
224 | 4 - skip as much initialization of work areas as possible |
---|
225 | (based on whatsChanged in clpmodel.hpp) ** work in progress |
---|
226 | maybe other bits later |
---|
227 | */ |
---|
228 | int dual(int ifValuesPass=0, int startFinishOptions=0); |
---|
229 | // If using Debug |
---|
230 | int dualDebug(int ifValuesPass=0, int startFinishOptions=0); |
---|
231 | /** Primal algorithm - see ClpSimplexPrimal.hpp for method. |
---|
232 | ifValuesPass==2 just does values pass and then stops. |
---|
233 | |
---|
234 | startFinishOptions - bits |
---|
235 | 1 - do not delete work areas and factorization at end |
---|
236 | 2 - use old factorization if same number of rows |
---|
237 | 4 - skip as much initialization of work areas as possible |
---|
238 | (based on whatsChanged in clpmodel.hpp) ** work in progress |
---|
239 | maybe other bits later |
---|
240 | */ |
---|
241 | int primal(int ifValuesPass=0, int startFinishOptions=0); |
---|
242 | /** Solves nonlinear problem using SLP - may be used as crash |
---|
243 | for other algorithms when number of iterations small. |
---|
244 | Also exits if all problematical variables are changing |
---|
245 | less than deltaTolerance |
---|
246 | */ |
---|
247 | int nonlinearSLP(int numberPasses,double deltaTolerance); |
---|
248 | /** Solves using barrier (assumes you have good cholesky factor code). |
---|
249 | Does crossover to simplex if asked*/ |
---|
250 | int barrier(bool crossover=true); |
---|
251 | /** Solves non-linear using reduced gradient. Phase = 0 get feasible, |
---|
252 | =1 use solution */ |
---|
253 | int reducedGradient(int phase=0); |
---|
254 | /** |
---|
255 | When scaling is on it is possible that the scaled problem |
---|
256 | is feasible but the unscaled is not. Clp returns a secondary |
---|
257 | status code to that effect. This option allows for a cleanup. |
---|
258 | If you use it I would suggest 1. |
---|
259 | This only affects actions when scaled optimal |
---|
260 | 0 - no action |
---|
261 | 1 - clean up using dual if primal infeasibility |
---|
262 | 2 - clean up using dual if dual infeasibility |
---|
263 | 3 - clean up using dual if primal or dual infeasibility |
---|
264 | 11,12,13 - as 1,2,3 but use primal |
---|
265 | |
---|
266 | return code as dual/primal |
---|
267 | */ |
---|
268 | int cleanup(int cleanupScaling); |
---|
269 | /** Dual ranging. |
---|
270 | This computes increase/decrease in cost for each given variable and corresponding |
---|
271 | sequence numbers which would change basis. Sequence numbers are 0..numberColumns |
---|
272 | and numberColumns.. for artificials/slacks. |
---|
273 | For non-basic variables the information is trivial to compute and the change in cost is just minus the |
---|
274 | reduced cost and the sequence number will be that of the non-basic variables. |
---|
275 | For basic variables a ratio test is between the reduced costs for non-basic variables |
---|
276 | and the row of the tableau corresponding to the basic variable. |
---|
277 | The increase/decrease value is always >= 0.0 |
---|
278 | |
---|
279 | Up to user to provide correct length arrays where each array is of length numberCheck. |
---|
280 | which contains list of variables for which information is desired. All other |
---|
281 | arrays will be filled in by function. If fifth entry in which is variable 7 then fifth entry in output arrays |
---|
282 | will be information for variable 7. |
---|
283 | |
---|
284 | If valueIncrease/Decrease not NULL (both must be NULL or both non NULL) then these are filled with |
---|
285 | the value of variable if such a change in cost were made (the existing bounds are ignored) |
---|
286 | |
---|
287 | Returns non-zero if infeasible unbounded etc |
---|
288 | */ |
---|
289 | int dualRanging(int numberCheck,const int * which, |
---|
290 | double * costIncrease, int * sequenceIncrease, |
---|
291 | double * costDecrease, int * sequenceDecrease, |
---|
292 | double * valueIncrease=NULL, double * valueDecrease=NULL); |
---|
293 | |
---|
294 | /** Primal ranging. |
---|
295 | This computes increase/decrease in value for each given variable and corresponding |
---|
296 | sequence numbers which would change basis. Sequence numbers are 0..numberColumns |
---|
297 | and numberColumns.. for artificials/slacks. |
---|
298 | This should only be used for non-basic variabls as otherwise information is pretty useless |
---|
299 | For basic variables the sequence number will be that of the basic variables. |
---|
300 | |
---|
301 | Up to user to provide correct length arrays where each array is of length numberCheck. |
---|
302 | which contains list of variables for which information is desired. All other |
---|
303 | arrays will be filled in by function. If fifth entry in which is variable 7 then fifth entry in output arrays |
---|
304 | will be information for variable 7. |
---|
305 | |
---|
306 | Returns non-zero if infeasible unbounded etc |
---|
307 | */ |
---|
308 | int primalRanging(int numberCheck,const int * which, |
---|
309 | double * valueIncrease, int * sequenceIncrease, |
---|
310 | double * valueDecrease, int * sequenceDecrease); |
---|
311 | /** Write the basis in MPS format to the specified file. |
---|
312 | If writeValues true writes values of structurals |
---|
313 | (and adds VALUES to end of NAME card) |
---|
314 | |
---|
315 | Row and column names may be null. |
---|
316 | formatType is |
---|
317 | <ul> |
---|
318 | <li> 0 - normal |
---|
319 | <li> 1 - extra accuracy |
---|
320 | <li> 2 - IEEE hex (later) |
---|
321 | </ul> |
---|
322 | |
---|
323 | Returns non-zero on I/O error |
---|
324 | */ |
---|
325 | int writeBasis(const char *filename, |
---|
326 | bool writeValues=false, |
---|
327 | int formatType=0) const; |
---|
328 | /** Read a basis from the given filename, |
---|
329 | returns -1 on file error, 0 if no values, 1 if values */ |
---|
330 | int readBasis(const char *filename); |
---|
331 | /// Returns a basis (to be deleted by user) |
---|
332 | CoinWarmStartBasis * getBasis() const; |
---|
333 | /// Passes in factorization |
---|
334 | void setFactorization( ClpFactorization & factorization); |
---|
335 | /** Tightens primal bounds to make dual faster. Unless |
---|
336 | fixed or doTight>10, bounds are slightly looser than they could be. |
---|
337 | This is to make dual go faster and is probably not needed |
---|
338 | with a presolve. Returns non-zero if problem infeasible. |
---|
339 | |
---|
340 | Fudge for branch and bound - put bounds on columns of factor * |
---|
341 | largest value (at continuous) - should improve stability |
---|
342 | in branch and bound on infeasible branches (0.0 is off) |
---|
343 | */ |
---|
344 | int tightenPrimalBounds(double factor=0.0,int doTight=0); |
---|
345 | /** Crash - at present just aimed at dual, returns |
---|
346 | -2 if dual preferred and crash basis created |
---|
347 | -1 if dual preferred and all slack basis preferred |
---|
348 | 0 if basis going in was not all slack |
---|
349 | 1 if primal preferred and all slack basis preferred |
---|
350 | 2 if primal preferred and crash basis created. |
---|
351 | |
---|
352 | if gap between bounds <="gap" variables can be flipped |
---|
353 | ( If pivot -1 then can be made super basic!) |
---|
354 | |
---|
355 | If "pivot" is |
---|
356 | -1 No pivoting - always primal |
---|
357 | 0 No pivoting (so will just be choice of algorithm) |
---|
358 | 1 Simple pivoting e.g. gub |
---|
359 | 2 Mini iterations |
---|
360 | */ |
---|
361 | int crash(double gap,int pivot); |
---|
362 | /// Sets row pivot choice algorithm in dual |
---|
363 | void setDualRowPivotAlgorithm(ClpDualRowPivot & choice); |
---|
364 | /// Sets column pivot choice algorithm in primal |
---|
365 | void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot & choice); |
---|
366 | /** For strong branching. On input lower and upper are new bounds |
---|
367 | while on output they are change in objective function values |
---|
368 | (>1.0e50 infeasible). |
---|
369 | Return code is 0 if nothing interesting, -1 if infeasible both |
---|
370 | ways and +1 if infeasible one way (check values to see which one(s)) |
---|
371 | Solutions are filled in as well - even down, odd up - also |
---|
372 | status and number of iterations |
---|
373 | */ |
---|
374 | int strongBranching(int numberVariables,const int * variables, |
---|
375 | double * newLower, double * newUpper, |
---|
376 | double ** outputSolution, |
---|
377 | int * outputStatus, int * outputIterations, |
---|
378 | bool stopOnFirstInfeasible=true, |
---|
379 | bool alwaysFinish=false, |
---|
380 | int startFinishOptions=0); |
---|
381 | //@} |
---|
382 | |
---|
383 | /**@name Needed for functionality of OsiSimplexInterface */ |
---|
384 | //@{ |
---|
385 | /** Pivot in a variable and out a variable. Returns 0 if okay, |
---|
386 | 1 if inaccuracy forced re-factorization, -1 if would be singular. |
---|
387 | Also updates primal/dual infeasibilities. |
---|
388 | Assumes sequenceIn_ and pivotRow_ set and also directionIn and Out. |
---|
389 | */ |
---|
390 | int pivot(); |
---|
391 | |
---|
392 | /** Pivot in a variable and choose an outgoing one. Assumes primal |
---|
393 | feasible - will not go through a bound. Returns step length in theta |
---|
394 | Returns ray in ray_ (or NULL if no pivot) |
---|
395 | Return codes as before but -1 means no acceptable pivot |
---|
396 | */ |
---|
397 | int primalPivotResult(); |
---|
398 | |
---|
399 | /** Pivot out a variable and choose an incoing one. Assumes dual |
---|
400 | feasible - will not go through a reduced cost. |
---|
401 | Returns step length in theta |
---|
402 | Returns ray in ray_ (or NULL if no pivot) |
---|
403 | Return codes as before but -1 means no acceptable pivot |
---|
404 | */ |
---|
405 | int dualPivotResult(); |
---|
406 | |
---|
407 | /** Common bits of coding for dual and primal. Return 0 if okay, |
---|
408 | 1 if bad matrix, 2 if very bad factorization |
---|
409 | |
---|
410 | startFinishOptions - bits |
---|
411 | 1 - do not delete work areas and factorization at end |
---|
412 | 2 - use old factorization if same number of rows |
---|
413 | 4 - skip as much initialization of work areas as possible |
---|
414 | (based on whatsChanged in clpmodel.hpp) ** work in progress |
---|
415 | maybe other bits later |
---|
416 | |
---|
417 | */ |
---|
418 | int startup(int ifValuesPass,int startFinishOptions=0); |
---|
419 | void finish(int startFinishOptions=0); |
---|
420 | |
---|
421 | /** Factorizes and returns true if optimal. Used by user */ |
---|
422 | bool statusOfProblem(bool initial=false); |
---|
423 | /// If user left factorization frequency then compute |
---|
424 | void defaultFactorizationFrequency(); |
---|
425 | //@} |
---|
426 | |
---|
427 | /**@name most useful gets and sets */ |
---|
428 | //@{ |
---|
429 | /// If problem is primal feasible |
---|
430 | inline bool primalFeasible() const |
---|
431 | { return (numberPrimalInfeasibilities_==0);}; |
---|
432 | /// If problem is dual feasible |
---|
433 | inline bool dualFeasible() const |
---|
434 | { return (numberDualInfeasibilities_==0);}; |
---|
435 | /// factorization |
---|
436 | inline ClpFactorization * factorization() const |
---|
437 | { return factorization_;}; |
---|
438 | /// Sparsity on or off |
---|
439 | bool sparseFactorization() const; |
---|
440 | void setSparseFactorization(bool value); |
---|
441 | /// Factorization frequency |
---|
442 | int factorizationFrequency() const; |
---|
443 | void setFactorizationFrequency(int value); |
---|
444 | /// Dual bound |
---|
445 | inline double dualBound() const |
---|
446 | { return dualBound_;}; |
---|
447 | void setDualBound(double value); |
---|
448 | /// Infeasibility cost |
---|
449 | inline double infeasibilityCost() const |
---|
450 | { return infeasibilityCost_;}; |
---|
451 | void setInfeasibilityCost(double value); |
---|
452 | /** Amount of print out: |
---|
453 | 0 - none |
---|
454 | 1 - just final |
---|
455 | 2 - just factorizations |
---|
456 | 3 - as 2 plus a bit more |
---|
457 | 4 - verbose |
---|
458 | above that 8,16,32 etc just for selective debug |
---|
459 | */ |
---|
460 | /** Perturbation: |
---|
461 | 50 - switch on perturbation |
---|
462 | 100 - auto perturb if takes too long (1.0e-6 largest nonzero) |
---|
463 | 101 - we are perturbed |
---|
464 | 102 - don't try perturbing again |
---|
465 | default is 100 |
---|
466 | others are for playing |
---|
467 | */ |
---|
468 | inline int perturbation() const |
---|
469 | { return perturbation_;}; |
---|
470 | void setPerturbation(int value); |
---|
471 | /// Current (or last) algorithm |
---|
472 | inline int algorithm() const |
---|
473 | {return algorithm_; } ; |
---|
474 | /// Set algorithm |
---|
475 | inline void setAlgorithm(int value) |
---|
476 | {algorithm_=value; } ; |
---|
477 | /// Sum of dual infeasibilities |
---|
478 | inline double sumDualInfeasibilities() const |
---|
479 | { return sumDualInfeasibilities_;} ; |
---|
480 | inline void setSumDualInfeasibilities(double value) |
---|
481 | { sumDualInfeasibilities_=value;} ; |
---|
482 | /// Sum of relaxed dual infeasibilities |
---|
483 | inline double sumOfRelaxedDualInfeasibilities() const |
---|
484 | { return sumOfRelaxedDualInfeasibilities_;} ; |
---|
485 | inline void setSumOfRelaxedDualInfeasibilities(double value) |
---|
486 | { sumOfRelaxedDualInfeasibilities_=value;} ; |
---|
487 | /// Number of dual infeasibilities |
---|
488 | inline int numberDualInfeasibilities() const |
---|
489 | { return numberDualInfeasibilities_;} ; |
---|
490 | inline void setNumberDualInfeasibilities(int value) |
---|
491 | { numberDualInfeasibilities_=value;} ; |
---|
492 | /// Number of dual infeasibilities (without free) |
---|
493 | inline int numberDualInfeasibilitiesWithoutFree() const |
---|
494 | { return numberDualInfeasibilitiesWithoutFree_;} ; |
---|
495 | /// Sum of primal infeasibilities |
---|
496 | inline double sumPrimalInfeasibilities() const |
---|
497 | { return sumPrimalInfeasibilities_;} ; |
---|
498 | inline void setSumPrimalInfeasibilities(double value) |
---|
499 | { sumPrimalInfeasibilities_=value;} ; |
---|
500 | /// Sum of relaxed primal infeasibilities |
---|
501 | inline double sumOfRelaxedPrimalInfeasibilities() const |
---|
502 | { return sumOfRelaxedPrimalInfeasibilities_;} ; |
---|
503 | inline void setSumOfRelaxedPrimalInfeasibilities(double value) |
---|
504 | { sumOfRelaxedPrimalInfeasibilities_=value;} ; |
---|
505 | /// Number of primal infeasibilities |
---|
506 | inline int numberPrimalInfeasibilities() const |
---|
507 | { return numberPrimalInfeasibilities_;} ; |
---|
508 | inline void setNumberPrimalInfeasibilities(int value) |
---|
509 | { numberPrimalInfeasibilities_=value;} ; |
---|
510 | /** Save model to file, returns 0 if success. This is designed for |
---|
511 | use outside algorithms so does not save iterating arrays etc. |
---|
512 | It does not save any messaging information. |
---|
513 | Does not save scaling values. |
---|
514 | It does not know about all types of virtual functions. |
---|
515 | */ |
---|
516 | int saveModel(const char * fileName); |
---|
517 | /** Restore model from file, returns 0 if success, |
---|
518 | deletes current model */ |
---|
519 | int restoreModel(const char * fileName); |
---|
520 | |
---|
521 | /** Just check solution (for external use) - sets sum of |
---|
522 | infeasibilities etc. |
---|
523 | If setToBounds 0 then primal column values not changed |
---|
524 | and used to compute primal row activity values. If 1 or 2 |
---|
525 | then status used - so all nonbasic variables set to |
---|
526 | indicated bound and if any values changed (or ==2) basic values re-computed. |
---|
527 | */ |
---|
528 | void checkSolution(int setToBounds=false); |
---|
529 | /** Just check solution (for internal use) - sets sum of |
---|
530 | infeasibilities etc. */ |
---|
531 | void checkSolutionInternal(); |
---|
532 | /// Useful row length arrays (0,1,2,3,4,5) |
---|
533 | inline CoinIndexedVector * rowArray(int index) const |
---|
534 | { return rowArray_[index];}; |
---|
535 | /// Useful column length arrays (0,1,2,3,4,5) |
---|
536 | inline CoinIndexedVector * columnArray(int index) const |
---|
537 | { return columnArray_[index];}; |
---|
538 | //@} |
---|
539 | |
---|
540 | /******************** End of most useful part **************/ |
---|
541 | /**@name Functions less likely to be useful to casual user */ |
---|
542 | //@{ |
---|
543 | /** Given an existing factorization computes and checks |
---|
544 | primal and dual solutions. Uses input arrays for variables at |
---|
545 | bounds. Returns feasibility states */ |
---|
546 | int getSolution ( const double * rowActivities, |
---|
547 | const double * columnActivities); |
---|
548 | /** Given an existing factorization computes and checks |
---|
549 | primal and dual solutions. Uses current problem arrays for |
---|
550 | bounds. Returns feasibility states */ |
---|
551 | int getSolution (); |
---|
552 | /** Constructs a non linear cost from list of non-linearities (columns only) |
---|
553 | First lower of each column is taken as real lower |
---|
554 | Last lower is taken as real upper and cost ignored |
---|
555 | |
---|
556 | Returns nonzero if bad data e.g. lowers not monotonic |
---|
557 | */ |
---|
558 | int createPiecewiseLinearCosts(const int * starts, |
---|
559 | const double * lower, const double * gradient); |
---|
560 | /** Return model - updates any scalars */ |
---|
561 | void returnModel(ClpSimplex & otherModel); |
---|
562 | /** Factorizes using current basis. |
---|
563 | solveType - 1 iterating, 0 initial, -1 external |
---|
564 | If 10 added then in primal values pass |
---|
565 | Return codes are as from ClpFactorization unless initial factorization |
---|
566 | when total number of singularities is returned. |
---|
567 | Special case is numberRows_+1 -> all slack basis. |
---|
568 | */ |
---|
569 | int internalFactorize(int solveType); |
---|
570 | /// Save data |
---|
571 | ClpDataSave saveData() ; |
---|
572 | /// Restore data |
---|
573 | void restoreData(ClpDataSave saved); |
---|
574 | /// Clean up status |
---|
575 | void cleanStatus(); |
---|
576 | /// Factorizes using current basis. For external use |
---|
577 | int factorize(); |
---|
578 | /** Computes duals from scratch. If givenDjs then |
---|
579 | allows for nonzero basic djs */ |
---|
580 | void computeDuals(double * givenDjs); |
---|
581 | /// Computes primals from scratch |
---|
582 | void computePrimals ( const double * rowActivities, |
---|
583 | const double * columnActivities); |
---|
584 | /** Adds multiple of a column into an array */ |
---|
585 | void add(double * array, |
---|
586 | int column, double multiplier) const; |
---|
587 | /** |
---|
588 | Unpacks one column of the matrix into indexed array |
---|
589 | Uses sequenceIn_ |
---|
590 | Also applies scaling if needed |
---|
591 | */ |
---|
592 | void unpack(CoinIndexedVector * rowArray) const ; |
---|
593 | /** |
---|
594 | Unpacks one column of the matrix into indexed array |
---|
595 | Slack if sequence>= numberColumns |
---|
596 | Also applies scaling if needed |
---|
597 | */ |
---|
598 | void unpack(CoinIndexedVector * rowArray,int sequence) const; |
---|
599 | /** |
---|
600 | Unpacks one column of the matrix into indexed array |
---|
601 | ** as packed vector |
---|
602 | Uses sequenceIn_ |
---|
603 | Also applies scaling if needed |
---|
604 | */ |
---|
605 | void unpackPacked(CoinIndexedVector * rowArray) ; |
---|
606 | /** |
---|
607 | Unpacks one column of the matrix into indexed array |
---|
608 | ** as packed vector |
---|
609 | Slack if sequence>= numberColumns |
---|
610 | Also applies scaling if needed |
---|
611 | */ |
---|
612 | void unpackPacked(CoinIndexedVector * rowArray,int sequence); |
---|
613 | protected: |
---|
614 | /** |
---|
615 | This does basis housekeeping and does values for in/out variables. |
---|
616 | Can also decide to re-factorize |
---|
617 | */ |
---|
618 | int housekeeping(double objectiveChange); |
---|
619 | /** This sets largest infeasibility and most infeasible and sum |
---|
620 | and number of infeasibilities (Primal) */ |
---|
621 | void checkPrimalSolution(const double * rowActivities=NULL, |
---|
622 | const double * columnActivies=NULL); |
---|
623 | /** This sets largest infeasibility and most infeasible and sum |
---|
624 | and number of infeasibilities (Dual) */ |
---|
625 | void checkDualSolution(); |
---|
626 | /** This sets sum and number of infeasibilities (Dual and Primal) */ |
---|
627 | void checkBothSolutions(); |
---|
628 | public: |
---|
629 | /** For advanced use. When doing iterative solves things can get |
---|
630 | nasty so on values pass if incoming solution has largest |
---|
631 | infeasibility < incomingInfeasibility throw out variables |
---|
632 | from basis until largest infeasibility < allowedInfeasibility |
---|
633 | or incoming largest infeasibility. |
---|
634 | If allowedInfeasibility>= incomingInfeasibility this is |
---|
635 | always possible altough you may end up with an all slack basis. |
---|
636 | |
---|
637 | Defaults are 1.0,10.0 |
---|
638 | */ |
---|
639 | void setValuesPassAction(float incomingInfeasibility, |
---|
640 | float allowedInfeasibility); |
---|
641 | //@} |
---|
642 | /**@name most useful gets and sets */ |
---|
643 | //@{ |
---|
644 | // On reflection I doubt whether anyone uses so test |
---|
645 | private: |
---|
646 | /// Worst column primal infeasibility |
---|
647 | inline double columnPrimalInfeasibility() const |
---|
648 | { return columnPrimalInfeasibility_;} ; |
---|
649 | /// Sequence of worst (-1 if feasible) |
---|
650 | inline int columnPrimalSequence() const |
---|
651 | { return columnPrimalSequence_;} ; |
---|
652 | /// Worst row primal infeasibility |
---|
653 | inline double rowPrimalInfeasibility() const |
---|
654 | { return rowPrimalInfeasibility_;} ; |
---|
655 | /// Sequence of worst (-1 if feasible) |
---|
656 | inline int rowPrimalSequence() const |
---|
657 | { return rowPrimalSequence_;} ; |
---|
658 | /** Worst column dual infeasibility (note - these may not be as meaningful |
---|
659 | if the problem is primal infeasible */ |
---|
660 | inline double columnDualInfeasibility() const |
---|
661 | { return columnDualInfeasibility_;} ; |
---|
662 | /// Sequence of worst (-1 if feasible) |
---|
663 | inline int columnDualSequence() const |
---|
664 | { return columnDualSequence_;} ; |
---|
665 | /// Worst row dual infeasibility |
---|
666 | inline double rowDualInfeasibility() const |
---|
667 | { return rowDualInfeasibility_;} ; |
---|
668 | /// Sequence of worst (-1 if feasible) |
---|
669 | inline int rowDualSequence() const |
---|
670 | { return rowDualSequence_;} ; |
---|
671 | /// Primal tolerance needed to make dual feasible (<largeTolerance) |
---|
672 | inline double primalToleranceToGetOptimal() const |
---|
673 | { return primalToleranceToGetOptimal_;} ; |
---|
674 | /// Remaining largest dual infeasibility |
---|
675 | inline double remainingDualInfeasibility() const |
---|
676 | { return remainingDualInfeasibility_;} ; |
---|
677 | /// Largest difference between input primal solution and computed |
---|
678 | inline double largestSolutionError() const |
---|
679 | { return largestSolutionError_;} ; |
---|
680 | public: |
---|
681 | /// Large bound value (for complementarity etc) |
---|
682 | inline double largeValue() const |
---|
683 | { return largeValue_;} ; |
---|
684 | void setLargeValue( double value) ; |
---|
685 | /// Largest error on Ax-b |
---|
686 | inline double largestPrimalError() const |
---|
687 | { return largestPrimalError_;} ; |
---|
688 | /// Largest error on basic duals |
---|
689 | inline double largestDualError() const |
---|
690 | { return largestDualError_;} ; |
---|
691 | /// Largest error on Ax-b |
---|
692 | inline void setLargestPrimalError(double value) |
---|
693 | { largestPrimalError_=value;} ; |
---|
694 | /// Largest error on basic duals |
---|
695 | inline void setLargestDualError(double value) |
---|
696 | { largestDualError_=value;} ; |
---|
697 | /// Basic variables pivoting on which rows |
---|
698 | inline int * pivotVariable() const |
---|
699 | { return pivotVariable_;}; |
---|
700 | /// If automatic scaling on |
---|
701 | inline bool automaticScaling() const |
---|
702 | { return automaticScale_!=0;}; |
---|
703 | inline void setAutomaticScaling(bool onOff) |
---|
704 | { automaticScale_ = onOff ? 1: 0;}; |
---|
705 | /// Current dual tolerance |
---|
706 | inline double currentDualTolerance() const |
---|
707 | { return dualTolerance_;} ; |
---|
708 | inline void setCurrentDualTolerance(double value) |
---|
709 | { dualTolerance_ = value;} ; |
---|
710 | /// Current primal tolerance |
---|
711 | inline double currentPrimalTolerance() const |
---|
712 | { return primalTolerance_;} ; |
---|
713 | inline void setCurrentPrimalTolerance(double value) |
---|
714 | { primalTolerance_ = value;} ; |
---|
715 | /// How many iterative refinements to do |
---|
716 | inline int numberRefinements() const |
---|
717 | { return numberRefinements_;} ; |
---|
718 | void setNumberRefinements( int value) ; |
---|
719 | /// Alpha (pivot element) for use by classes e.g. steepestedge |
---|
720 | inline double alpha() const { return alpha_;}; |
---|
721 | inline void setAlpha(double value) { alpha_ = value;}; |
---|
722 | /// Reduced cost of last incoming for use by classes e.g. steepestedge |
---|
723 | inline double dualIn() const { return dualIn_;}; |
---|
724 | /// Pivot Row for use by classes e.g. steepestedge |
---|
725 | inline int pivotRow() const{ return pivotRow_;}; |
---|
726 | inline void setPivotRow(int value) { pivotRow_=value;}; |
---|
727 | /// value of incoming variable (in Dual) |
---|
728 | double valueIncomingDual() const; |
---|
729 | //@} |
---|
730 | |
---|
731 | protected: |
---|
732 | /**@name protected methods */ |
---|
733 | //@{ |
---|
734 | /** May change basis and then returns number changed. |
---|
735 | Computation of solutions may be overriden by given pi and solution |
---|
736 | */ |
---|
737 | int gutsOfSolution ( double * givenDuals, |
---|
738 | const double * givenPrimals, |
---|
739 | bool valuesPass=false); |
---|
740 | /// Does most of deletion (0 = all, 1 = most, 2 most + factorization) |
---|
741 | void gutsOfDelete(int type); |
---|
742 | /// Does most of copying |
---|
743 | void gutsOfCopy(const ClpSimplex & rhs); |
---|
744 | /** puts in format I like (rowLower,rowUpper) also see StandardMatrix |
---|
745 | 1 bit does rows, 2 bit does column bounds, 4 bit does objective(s). |
---|
746 | 8 bit does solution scaling in |
---|
747 | 16 bit does rowArray and columnArray indexed vectors |
---|
748 | and makes row copy if wanted, also sets columnStart_ etc |
---|
749 | Also creates scaling arrays if needed. It does scaling if needed. |
---|
750 | 16 also moves solutions etc in to work arrays |
---|
751 | On 16 returns false if problem "bad" i.e. matrix or bounds bad |
---|
752 | If startFinishOptions is -1 then called by user in getSolution |
---|
753 | so do arrays but keep pivotVariable_ |
---|
754 | */ |
---|
755 | bool createRim(int what,bool makeRowCopy=false,int startFinishOptions=0); |
---|
756 | /** releases above arrays and does solution scaling out. May also |
---|
757 | get rid of factorization data - |
---|
758 | 0 get rid of nothing, 1 get rid of arrays, 2 also factorization |
---|
759 | */ |
---|
760 | void deleteRim(int getRidOfFactorizationData=2); |
---|
761 | /// Sanity check on input rim data (after scaling) - returns true if okay |
---|
762 | bool sanityCheck(); |
---|
763 | //@} |
---|
764 | public: |
---|
765 | /**@name public methods */ |
---|
766 | //@{ |
---|
767 | /** Return row or column sections - not as much needed as it |
---|
768 | once was. These just map into single arrays */ |
---|
769 | inline double * solutionRegion(int section) const |
---|
770 | { if (!section) return rowActivityWork_; else return columnActivityWork_;}; |
---|
771 | inline double * djRegion(int section) const |
---|
772 | { if (!section) return rowReducedCost_; else return reducedCostWork_;}; |
---|
773 | inline double * lowerRegion(int section) const |
---|
774 | { if (!section) return rowLowerWork_; else return columnLowerWork_;}; |
---|
775 | inline double * upperRegion(int section) const |
---|
776 | { if (!section) return rowUpperWork_; else return columnUpperWork_;}; |
---|
777 | inline double * costRegion(int section) const |
---|
778 | { if (!section) return rowObjectiveWork_; else return objectiveWork_;}; |
---|
779 | /// Return region as single array |
---|
780 | inline double * solutionRegion() const |
---|
781 | { return solution_;}; |
---|
782 | inline double * djRegion() const |
---|
783 | { return dj_;}; |
---|
784 | inline double * lowerRegion() const |
---|
785 | { return lower_;}; |
---|
786 | inline double * upperRegion() const |
---|
787 | { return upper_;}; |
---|
788 | inline double * costRegion() const |
---|
789 | { return cost_;}; |
---|
790 | inline Status getStatus(int sequence) const |
---|
791 | {return static_cast<Status> (status_[sequence]&7);}; |
---|
792 | inline void setStatus(int sequence, Status status) |
---|
793 | { |
---|
794 | unsigned char & st_byte = status_[sequence]; |
---|
795 | st_byte &= ~7; |
---|
796 | st_byte |= status; |
---|
797 | }; |
---|
798 | /** Normally the first factorization does sparse coding because |
---|
799 | the factorization could be singular. This allows initial dense |
---|
800 | factorization when it is known to be safe |
---|
801 | */ |
---|
802 | void setInitialDenseFactorization(bool onOff); |
---|
803 | bool initialDenseFactorization() const; |
---|
804 | /** Return sequence In or Out */ |
---|
805 | inline int sequenceIn() const |
---|
806 | {return sequenceIn_;}; |
---|
807 | inline int sequenceOut() const |
---|
808 | {return sequenceOut_;}; |
---|
809 | /** Set sequenceIn or Out */ |
---|
810 | inline void setSequenceIn(int sequence) |
---|
811 | { sequenceIn_=sequence;}; |
---|
812 | inline void setSequenceOut(int sequence) |
---|
813 | { sequenceOut_=sequence;}; |
---|
814 | /** Return direction In or Out */ |
---|
815 | inline int directionIn() const |
---|
816 | {return directionIn_;}; |
---|
817 | inline int directionOut() const |
---|
818 | {return directionOut_;}; |
---|
819 | /** Set directionIn or Out */ |
---|
820 | inline void setDirectionIn(int direction) |
---|
821 | { directionIn_=direction;}; |
---|
822 | inline void setDirectionOut(int direction) |
---|
823 | { directionOut_=direction;}; |
---|
824 | /// Value of Out variable |
---|
825 | inline double valueOut() const |
---|
826 | { return valueOut_;}; |
---|
827 | /// Returns 1 if sequence indicates column |
---|
828 | inline int isColumn(int sequence) const |
---|
829 | { return sequence<numberColumns_ ? 1 : 0;}; |
---|
830 | /// Returns sequence number within section |
---|
831 | inline int sequenceWithin(int sequence) const |
---|
832 | { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;}; |
---|
833 | /// Return row or column values |
---|
834 | inline double solution(int sequence) |
---|
835 | { return solution_[sequence];}; |
---|
836 | /// Return address of row or column values |
---|
837 | inline double & solutionAddress(int sequence) |
---|
838 | { return solution_[sequence];}; |
---|
839 | inline double reducedCost(int sequence) |
---|
840 | { return dj_[sequence];}; |
---|
841 | inline double & reducedCostAddress(int sequence) |
---|
842 | { return dj_[sequence];}; |
---|
843 | inline double lower(int sequence) |
---|
844 | { return lower_[sequence];}; |
---|
845 | /// Return address of row or column lower bound |
---|
846 | inline double & lowerAddress(int sequence) |
---|
847 | { return lower_[sequence];}; |
---|
848 | inline double upper(int sequence) |
---|
849 | { return upper_[sequence];}; |
---|
850 | /// Return address of row or column upper bound |
---|
851 | inline double & upperAddress(int sequence) |
---|
852 | { return upper_[sequence];}; |
---|
853 | inline double cost(int sequence) |
---|
854 | { return cost_[sequence];}; |
---|
855 | /// Return address of row or column cost |
---|
856 | inline double & costAddress(int sequence) |
---|
857 | { return cost_[sequence];}; |
---|
858 | /// Return original lower bound |
---|
859 | inline double originalLower(int iSequence) const |
---|
860 | { if (iSequence<numberColumns_) return columnLower_[iSequence]; else |
---|
861 | return rowLower_[iSequence-numberColumns_];}; |
---|
862 | /// Return original lower bound |
---|
863 | inline double originalUpper(int iSequence) const |
---|
864 | { if (iSequence<numberColumns_) return columnUpper_[iSequence]; else |
---|
865 | return rowUpper_[iSequence-numberColumns_];}; |
---|
866 | /// Theta (pivot change) |
---|
867 | inline double theta() const |
---|
868 | { return theta_;}; |
---|
869 | /// Return pointer to details of costs |
---|
870 | inline ClpNonLinearCost * nonLinearCost() const |
---|
871 | { return nonLinearCost_;}; |
---|
872 | //@} |
---|
873 | /**@name status methods */ |
---|
874 | //@{ |
---|
875 | inline void setFakeBound(int sequence, FakeBound fakeBound) |
---|
876 | { |
---|
877 | unsigned char & st_byte = status_[sequence]; |
---|
878 | st_byte &= ~24; |
---|
879 | st_byte |= fakeBound<<3; |
---|
880 | }; |
---|
881 | inline FakeBound getFakeBound(int sequence) const |
---|
882 | {return static_cast<FakeBound> ((status_[sequence]>>3)&3);}; |
---|
883 | inline void setRowStatus(int sequence, Status status) |
---|
884 | { |
---|
885 | unsigned char & st_byte = status_[sequence+numberColumns_]; |
---|
886 | st_byte &= ~7; |
---|
887 | st_byte |= status; |
---|
888 | }; |
---|
889 | inline Status getRowStatus(int sequence) const |
---|
890 | {return static_cast<Status> (status_[sequence+numberColumns_]&7);}; |
---|
891 | inline void setColumnStatus(int sequence, Status status) |
---|
892 | { |
---|
893 | unsigned char & st_byte = status_[sequence]; |
---|
894 | st_byte &= ~7; |
---|
895 | st_byte |= status; |
---|
896 | }; |
---|
897 | inline Status getColumnStatus(int sequence) const |
---|
898 | {return static_cast<Status> (status_[sequence]&7);}; |
---|
899 | inline void setPivoted( int sequence) |
---|
900 | { status_[sequence] |= 32;}; |
---|
901 | inline void clearPivoted( int sequence) |
---|
902 | { status_[sequence] &= ~32; }; |
---|
903 | inline bool pivoted(int sequence) const |
---|
904 | {return (((status_[sequence]>>5)&1)!=0);}; |
---|
905 | /// To flag a variable (not inline to allow for column generation) |
---|
906 | void setFlagged( int sequence); |
---|
907 | inline void clearFlagged( int sequence) |
---|
908 | { |
---|
909 | status_[sequence] &= ~64; |
---|
910 | }; |
---|
911 | inline bool flagged(int sequence) const |
---|
912 | {return ((status_[sequence]&64)!=0);}; |
---|
913 | /// To say row active in primal pivot row choice |
---|
914 | inline void setActive( int iRow) |
---|
915 | { |
---|
916 | status_[iRow] |= 128; |
---|
917 | }; |
---|
918 | inline void clearActive( int iRow) |
---|
919 | { |
---|
920 | status_[iRow] &= ~128; |
---|
921 | }; |
---|
922 | inline bool active(int iRow) const |
---|
923 | {return ((status_[iRow]&128)!=0);}; |
---|
924 | /** Set up status array (can be used by OsiClp). |
---|
925 | Also can be used to set up all slack basis */ |
---|
926 | void createStatus() ; |
---|
927 | /** Sets up all slack basis and resets solution to |
---|
928 | as it was after initial load or readMps */ |
---|
929 | void allSlackBasis(bool resetSolution=false); |
---|
930 | |
---|
931 | /// So we know when to be cautious |
---|
932 | inline int lastBadIteration() const |
---|
933 | {return lastBadIteration_;}; |
---|
934 | /// Progress flag - at present 0 bit says artificials out |
---|
935 | inline int progressFlag() const |
---|
936 | {return progressFlag_;}; |
---|
937 | /// Force re-factorization early |
---|
938 | inline void forceFactorization(int value) |
---|
939 | { forceFactorization_ = value;}; |
---|
940 | /// Raw objective value (so always minimize in primal) |
---|
941 | inline double rawObjectiveValue() const |
---|
942 | { return objectiveValue_;}; |
---|
943 | /// Compute objective value from solution and put in objectiveValue_ |
---|
944 | void computeObjectiveValue(bool useWorkingSolution=false); |
---|
945 | /** Number of extra rows. These are ones which will be dynamically created |
---|
946 | each iteration. This is for GUB but may have other uses. |
---|
947 | */ |
---|
948 | inline int numberExtraRows() const |
---|
949 | { return numberExtraRows_;}; |
---|
950 | /** Maximum number of basic variables - can be more than number of rows if GUB |
---|
951 | */ |
---|
952 | inline int maximumBasic() const |
---|
953 | { return maximumBasic_;}; |
---|
954 | /// Create C++ lines to get to current state |
---|
955 | void generateCpp( FILE * fp,bool defaultFactor=false); |
---|
956 | /// Gets clean and emptyish factorization |
---|
957 | ClpFactorization * getEmptyFactorization(); |
---|
958 | /// May delete or may make clean and emptyish factorization |
---|
959 | void setEmptyFactorization(); |
---|
960 | /// Move status and solution across |
---|
961 | void moveInfo(const ClpSimplex & rhs, bool justStatus=false); |
---|
962 | /** For advanced options |
---|
963 | 1 - Don't keep changing infeasibility weight |
---|
964 | 2 - Keep nonLinearCost round solves |
---|
965 | 4 - Force outgoing variables to exact bound (primal) |
---|
966 | 8 - Safe to use dense initial factorization |
---|
967 | 16 -Just use basic variables for operation if column generation |
---|
968 | 32 -Clean up with primal before strong branching |
---|
969 | 64 -Treat problem as feasible until last minute (i.e. minimize infeasibilities) |
---|
970 | 128 - Switch off all matrix sanity checks |
---|
971 | 256 - No row copy |
---|
972 | 512 - If not in values pass, solution guaranteed, skip as much as possible |
---|
973 | 1024 - In branch and bound |
---|
974 | 2048 - Don't bother to re-factorize if < 20 iterations |
---|
975 | 4096 - Skip some optimality checks |
---|
976 | 8192 - Do Primal when cleaning up primal |
---|
977 | 16384 - In fast dual (so we can switch off things) |
---|
978 | 32678 - called from Osi |
---|
979 | NOTE - many applications can call Clp but there may be some short cuts |
---|
980 | which are taken which are not guaranteed safe from all applications. |
---|
981 | Vetted applications will have a bit set and the code may test this |
---|
982 | At present I expect a few such applications - if too many I will |
---|
983 | have to re-think. It is up to application owner to change the code |
---|
984 | if she/he needs these short cuts. I will not debug unless in Coin |
---|
985 | repository. See COIN_CLP_VETTED comments. |
---|
986 | 0x01000000 is Cbc (and in branch and bound) |
---|
987 | */ |
---|
988 | #define COIN_CBC_USING_CLP 0x01000000 |
---|
989 | inline unsigned int specialOptions() const |
---|
990 | { return specialOptions_;}; |
---|
991 | inline void setSpecialOptions(unsigned int value) |
---|
992 | { specialOptions_=value;}; |
---|
993 | //@} |
---|
994 | |
---|
995 | ///@name Basis handling |
---|
996 | // These are only to be used using startFinishOptions (ClpSimplexDual, ClpSimplexPrimal) |
---|
997 | // *** At present only without scaling |
---|
998 | // *** Slacks havve -1.0 element (so == row activity) - take care |
---|
999 | ///Get a row of the tableau (slack part in slack if not NULL) |
---|
1000 | void getBInvARow(int row, double* z, double * slack=NULL); |
---|
1001 | |
---|
1002 | ///Get a row of the basis inverse |
---|
1003 | void getBInvRow(int row, double* z); |
---|
1004 | |
---|
1005 | ///Get a column of the tableau |
---|
1006 | void getBInvACol(int col, double* vec); |
---|
1007 | |
---|
1008 | ///Get a column of the basis inverse |
---|
1009 | void getBInvCol(int col, double* vec); |
---|
1010 | |
---|
1011 | /** Get basic indices (order of indices corresponds to the |
---|
1012 | order of elements in a vector retured by getBInvACol() and |
---|
1013 | getBInvCol()). |
---|
1014 | */ |
---|
1015 | void getBasics(int* index); |
---|
1016 | |
---|
1017 | //@} |
---|
1018 | //------------------------------------------------------------------------- |
---|
1019 | /**@name Changing bounds on variables and constraints */ |
---|
1020 | //@{ |
---|
1021 | /** Set an objective function coefficient */ |
---|
1022 | void setObjectiveCoefficient( int elementIndex, double elementValue ); |
---|
1023 | /** Set an objective function coefficient */ |
---|
1024 | inline void setObjCoeff( int elementIndex, double elementValue ) |
---|
1025 | { setObjectiveCoefficient( elementIndex, elementValue);}; |
---|
1026 | |
---|
1027 | /** Set a single column lower bound<br> |
---|
1028 | Use -DBL_MAX for -infinity. */ |
---|
1029 | void setColumnLower( int elementIndex, double elementValue ); |
---|
1030 | |
---|
1031 | /** Set a single column upper bound<br> |
---|
1032 | Use DBL_MAX for infinity. */ |
---|
1033 | void setColumnUpper( int elementIndex, double elementValue ); |
---|
1034 | |
---|
1035 | /** Set a single column lower and upper bound */ |
---|
1036 | void setColumnBounds( int elementIndex, |
---|
1037 | double lower, double upper ); |
---|
1038 | |
---|
1039 | /** Set the bounds on a number of columns simultaneously<br> |
---|
1040 | The default implementation just invokes setColLower() and |
---|
1041 | setColUpper() over and over again. |
---|
1042 | @param indexFirst,indexLast pointers to the beginning and after the |
---|
1043 | end of the array of the indices of the variables whose |
---|
1044 | <em>either</em> bound changes |
---|
1045 | @param boundList the new lower/upper bound pairs for the variables |
---|
1046 | */ |
---|
1047 | void setColumnSetBounds(const int* indexFirst, |
---|
1048 | const int* indexLast, |
---|
1049 | const double* boundList); |
---|
1050 | |
---|
1051 | /** Set a single column lower bound<br> |
---|
1052 | Use -DBL_MAX for -infinity. */ |
---|
1053 | inline void setColLower( int elementIndex, double elementValue ) |
---|
1054 | { setColumnLower(elementIndex, elementValue);}; |
---|
1055 | /** Set a single column upper bound<br> |
---|
1056 | Use DBL_MAX for infinity. */ |
---|
1057 | inline void setColUpper( int elementIndex, double elementValue ) |
---|
1058 | { setColumnUpper(elementIndex, elementValue);}; |
---|
1059 | |
---|
1060 | /** Set a single column lower and upper bound */ |
---|
1061 | inline void setColBounds( int elementIndex, |
---|
1062 | double lower, double upper ) |
---|
1063 | { setColumnBounds(elementIndex, lower, upper);}; |
---|
1064 | |
---|
1065 | /** Set the bounds on a number of columns simultaneously<br> |
---|
1066 | @param indexFirst,indexLast pointers to the beginning and after the |
---|
1067 | end of the array of the indices of the variables whose |
---|
1068 | <em>either</em> bound changes |
---|
1069 | @param boundList the new lower/upper bound pairs for the variables |
---|
1070 | */ |
---|
1071 | inline void setColSetBounds(const int* indexFirst, |
---|
1072 | const int* indexLast, |
---|
1073 | const double* boundList) |
---|
1074 | { setColumnSetBounds(indexFirst, indexLast, boundList);}; |
---|
1075 | |
---|
1076 | /** Set a single row lower bound<br> |
---|
1077 | Use -DBL_MAX for -infinity. */ |
---|
1078 | void setRowLower( int elementIndex, double elementValue ); |
---|
1079 | |
---|
1080 | /** Set a single row upper bound<br> |
---|
1081 | Use DBL_MAX for infinity. */ |
---|
1082 | void setRowUpper( int elementIndex, double elementValue ) ; |
---|
1083 | |
---|
1084 | /** Set a single row lower and upper bound */ |
---|
1085 | void setRowBounds( int elementIndex, |
---|
1086 | double lower, double upper ) ; |
---|
1087 | |
---|
1088 | /** Set the bounds on a number of rows simultaneously<br> |
---|
1089 | @param indexFirst,indexLast pointers to the beginning and after the |
---|
1090 | end of the array of the indices of the constraints whose |
---|
1091 | <em>either</em> bound changes |
---|
1092 | @param boundList the new lower/upper bound pairs for the constraints |
---|
1093 | */ |
---|
1094 | void setRowSetBounds(const int* indexFirst, |
---|
1095 | const int* indexLast, |
---|
1096 | const double* boundList); |
---|
1097 | |
---|
1098 | //@} |
---|
1099 | |
---|
1100 | ////////////////// data ////////////////// |
---|
1101 | protected: |
---|
1102 | |
---|
1103 | /**@name data. Many arrays have a row part and a column part. |
---|
1104 | There is a single array with both - columns then rows and |
---|
1105 | then normally two arrays pointing to rows and columns. The |
---|
1106 | single array is the owner of memory |
---|
1107 | */ |
---|
1108 | //@{ |
---|
1109 | /// Worst column primal infeasibility |
---|
1110 | double columnPrimalInfeasibility_; |
---|
1111 | /// Worst row primal infeasibility |
---|
1112 | double rowPrimalInfeasibility_; |
---|
1113 | /// Sequence of worst (-1 if feasible) |
---|
1114 | int columnPrimalSequence_; |
---|
1115 | /// Sequence of worst (-1 if feasible) |
---|
1116 | int rowPrimalSequence_; |
---|
1117 | /// Worst column dual infeasibility |
---|
1118 | double columnDualInfeasibility_; |
---|
1119 | /// Worst row dual infeasibility |
---|
1120 | double rowDualInfeasibility_; |
---|
1121 | /// Sequence of worst (-1 if feasible) |
---|
1122 | int columnDualSequence_; |
---|
1123 | /// Sequence of worst (-1 if feasible) |
---|
1124 | int rowDualSequence_; |
---|
1125 | /// Primal tolerance needed to make dual feasible (<largeTolerance) |
---|
1126 | double primalToleranceToGetOptimal_; |
---|
1127 | /// Remaining largest dual infeasibility |
---|
1128 | double remainingDualInfeasibility_; |
---|
1129 | /// Large bound value (for complementarity etc) |
---|
1130 | double largeValue_; |
---|
1131 | /// Largest error on Ax-b |
---|
1132 | double largestPrimalError_; |
---|
1133 | /// Largest error on basic duals |
---|
1134 | double largestDualError_; |
---|
1135 | /// Largest difference between input primal solution and computed |
---|
1136 | double largestSolutionError_; |
---|
1137 | /// Dual bound |
---|
1138 | double dualBound_; |
---|
1139 | /// Alpha (pivot element) |
---|
1140 | double alpha_; |
---|
1141 | /// Theta (pivot change) |
---|
1142 | double theta_; |
---|
1143 | /// Lower Bound on In variable |
---|
1144 | double lowerIn_; |
---|
1145 | /// Value of In variable |
---|
1146 | double valueIn_; |
---|
1147 | /// Upper Bound on In variable |
---|
1148 | double upperIn_; |
---|
1149 | /// Reduced cost of In variable |
---|
1150 | double dualIn_; |
---|
1151 | /// Lower Bound on Out variable |
---|
1152 | double lowerOut_; |
---|
1153 | /// Value of Out variable |
---|
1154 | double valueOut_; |
---|
1155 | /// Upper Bound on Out variable |
---|
1156 | double upperOut_; |
---|
1157 | /// Infeasibility (dual) or ? (primal) of Out variable |
---|
1158 | double dualOut_; |
---|
1159 | /// Current dual tolerance for algorithm |
---|
1160 | double dualTolerance_; |
---|
1161 | /// Current primal tolerance for algorithm |
---|
1162 | double primalTolerance_; |
---|
1163 | /// Sum of dual infeasibilities |
---|
1164 | double sumDualInfeasibilities_; |
---|
1165 | /// Sum of primal infeasibilities |
---|
1166 | double sumPrimalInfeasibilities_; |
---|
1167 | /// Weight assigned to being infeasible in primal |
---|
1168 | double infeasibilityCost_; |
---|
1169 | /// Sum of Dual infeasibilities using tolerance based on error in duals |
---|
1170 | double sumOfRelaxedDualInfeasibilities_; |
---|
1171 | /// Sum of Primal infeasibilities using tolerance based on error in primals |
---|
1172 | double sumOfRelaxedPrimalInfeasibilities_; |
---|
1173 | /// Acceptable pivot value just after factorization |
---|
1174 | double acceptablePivot_; |
---|
1175 | /// Working copy of lower bounds (Owner of arrays below) |
---|
1176 | double * lower_; |
---|
1177 | /// Row lower bounds - working copy |
---|
1178 | double * rowLowerWork_; |
---|
1179 | /// Column lower bounds - working copy |
---|
1180 | double * columnLowerWork_; |
---|
1181 | /// Working copy of upper bounds (Owner of arrays below) |
---|
1182 | double * upper_; |
---|
1183 | /// Row upper bounds - working copy |
---|
1184 | double * rowUpperWork_; |
---|
1185 | /// Column upper bounds - working copy |
---|
1186 | double * columnUpperWork_; |
---|
1187 | /// Working copy of objective (Owner of arrays below) |
---|
1188 | double * cost_; |
---|
1189 | /// Row objective - working copy |
---|
1190 | double * rowObjectiveWork_; |
---|
1191 | /// Column objective - working copy |
---|
1192 | double * objectiveWork_; |
---|
1193 | /// Useful row length arrays |
---|
1194 | CoinIndexedVector * rowArray_[6]; |
---|
1195 | /// Useful column length arrays |
---|
1196 | CoinIndexedVector * columnArray_[6]; |
---|
1197 | /// Sequence of In variable |
---|
1198 | int sequenceIn_; |
---|
1199 | /// Direction of In, 1 going up, -1 going down, 0 not a clude |
---|
1200 | int directionIn_; |
---|
1201 | /// Sequence of Out variable |
---|
1202 | int sequenceOut_; |
---|
1203 | /// Direction of Out, 1 to upper bound, -1 to lower bound, 0 - superbasic |
---|
1204 | int directionOut_; |
---|
1205 | /// Pivot Row |
---|
1206 | int pivotRow_; |
---|
1207 | /// Last good iteration (immediately after a re-factorization) |
---|
1208 | int lastGoodIteration_; |
---|
1209 | /// Working copy of reduced costs (Owner of arrays below) |
---|
1210 | double * dj_; |
---|
1211 | /// Reduced costs of slacks not same as duals (or - duals) |
---|
1212 | double * rowReducedCost_; |
---|
1213 | /// Possible scaled reduced costs |
---|
1214 | double * reducedCostWork_; |
---|
1215 | /// Working copy of primal solution (Owner of arrays below) |
---|
1216 | double * solution_; |
---|
1217 | /// Row activities - working copy |
---|
1218 | double * rowActivityWork_; |
---|
1219 | /// Column activities - working copy |
---|
1220 | double * columnActivityWork_; |
---|
1221 | /// Auxiliary model |
---|
1222 | ClpSimplex * auxiliaryModel_; |
---|
1223 | /// Number of dual infeasibilities |
---|
1224 | int numberDualInfeasibilities_; |
---|
1225 | /// Number of dual infeasibilities (without free) |
---|
1226 | int numberDualInfeasibilitiesWithoutFree_; |
---|
1227 | /// Number of primal infeasibilities |
---|
1228 | int numberPrimalInfeasibilities_; |
---|
1229 | /// How many iterative refinements to do |
---|
1230 | int numberRefinements_; |
---|
1231 | /// dual row pivot choice |
---|
1232 | ClpDualRowPivot * dualRowPivot_; |
---|
1233 | /// primal column pivot choice |
---|
1234 | ClpPrimalColumnPivot * primalColumnPivot_; |
---|
1235 | /// Basic variables pivoting on which rows |
---|
1236 | int * pivotVariable_; |
---|
1237 | /// factorization |
---|
1238 | ClpFactorization * factorization_; |
---|
1239 | /// Saved version of solution |
---|
1240 | double * savedSolution_; |
---|
1241 | /// Number of times code has tentatively thought optimal |
---|
1242 | int numberTimesOptimal_; |
---|
1243 | /// If change has been made (first attempt at stopping looping) |
---|
1244 | int changeMade_; |
---|
1245 | /// Algorithm >0 == Primal, <0 == Dual |
---|
1246 | int algorithm_; |
---|
1247 | /** Now for some reliability aids |
---|
1248 | This forces re-factorization early */ |
---|
1249 | int forceFactorization_; |
---|
1250 | /** Perturbation: |
---|
1251 | -50 to +50 - perturb by this power of ten (-6 sounds good) |
---|
1252 | 100 - auto perturb if takes too long (1.0e-6 largest nonzero) |
---|
1253 | 101 - we are perturbed |
---|
1254 | 102 - don't try perturbing again |
---|
1255 | default is 100 |
---|
1256 | */ |
---|
1257 | int perturbation_; |
---|
1258 | /// Saved status regions |
---|
1259 | unsigned char * saveStatus_; |
---|
1260 | /** Very wasteful way of dealing with infeasibilities in primal. |
---|
1261 | However it will allow non-linearities and use of dual |
---|
1262 | analysis. If it doesn't work it can easily be replaced. |
---|
1263 | */ |
---|
1264 | ClpNonLinearCost * nonLinearCost_; |
---|
1265 | /** For advanced options |
---|
1266 | See get and set for meaning |
---|
1267 | */ |
---|
1268 | unsigned int specialOptions_; |
---|
1269 | /// So we know when to be cautious |
---|
1270 | int lastBadIteration_; |
---|
1271 | /// So we know when to open up again |
---|
1272 | int lastFlaggedIteration_; |
---|
1273 | /// Can be used for count of fake bounds (dual) or fake costs (primal) |
---|
1274 | int numberFake_; |
---|
1275 | /// Can be used for count of changed costs (dual) or changed bounds (primal) |
---|
1276 | int numberChanged_; |
---|
1277 | /// Progress flag - at present 0 bit says artificials out, 1 free in |
---|
1278 | int progressFlag_; |
---|
1279 | /// First free/super-basic variable (-1 if none) |
---|
1280 | int firstFree_; |
---|
1281 | /** Number of extra rows. These are ones which will be dynamically created |
---|
1282 | each iteration. This is for GUB but may have other uses. |
---|
1283 | */ |
---|
1284 | int numberExtraRows_; |
---|
1285 | /** Maximum number of basic variables - can be more than number of rows if GUB |
---|
1286 | */ |
---|
1287 | int maximumBasic_; |
---|
1288 | /** For advanced use. When doing iterative solves things can get |
---|
1289 | nasty so on values pass if incoming solution has largest |
---|
1290 | infeasibility < incomingInfeasibility throw out variables |
---|
1291 | from basis until largest infeasibility < allowedInfeasibility. |
---|
1292 | if allowedInfeasibility>= incomingInfeasibility this is |
---|
1293 | always possible altough you may end up with an all slack basis. |
---|
1294 | |
---|
1295 | Defaults are 1.0,10.0 |
---|
1296 | */ |
---|
1297 | float incomingInfeasibility_; |
---|
1298 | float allowedInfeasibility_; |
---|
1299 | /// Automatic scaling of objective and rhs and bounds |
---|
1300 | int automaticScale_; |
---|
1301 | /// For dealing with all issues of cycling etc |
---|
1302 | ClpSimplexProgress * progress_; |
---|
1303 | public: |
---|
1304 | /// Spare int array for passing information [0]!=0 switches on |
---|
1305 | mutable int spareIntArray_[4]; |
---|
1306 | /// Spare double array for passing information [0]!=0 switches on |
---|
1307 | mutable double spareDoubleArray_[4]; |
---|
1308 | protected: |
---|
1309 | /// Allow OsiClp certain perks |
---|
1310 | friend class OsiClpSolverInterface; |
---|
1311 | //@} |
---|
1312 | }; |
---|
1313 | //############################################################################# |
---|
1314 | /** A function that tests the methods in the ClpSimplex class. The |
---|
1315 | only reason for it not to be a member method is that this way it doesn't |
---|
1316 | have to be compiled into the library. And that's a gain, because the |
---|
1317 | library should be compiled with optimization on, but this method should be |
---|
1318 | compiled with debugging. |
---|
1319 | |
---|
1320 | It also does some testing of ClpFactorization class |
---|
1321 | */ |
---|
1322 | void |
---|
1323 | ClpSimplexUnitTest(const std::string & mpsDir, |
---|
1324 | const std::string & netlibDir); |
---|
1325 | |
---|
1326 | |
---|
1327 | /// For saving extra information to see if looping. |
---|
1328 | class ClpSimplexProgress { |
---|
1329 | |
---|
1330 | public: |
---|
1331 | |
---|
1332 | |
---|
1333 | /**@name Constructors and destructor and copy */ |
---|
1334 | //@{ |
---|
1335 | /// Default constructor |
---|
1336 | ClpSimplexProgress ( ); |
---|
1337 | |
---|
1338 | /// Constructor from model |
---|
1339 | ClpSimplexProgress ( ClpSimplex * model ); |
---|
1340 | |
---|
1341 | /// Copy constructor. |
---|
1342 | ClpSimplexProgress(const ClpSimplexProgress &); |
---|
1343 | |
---|
1344 | /// Assignment operator. This copies the data |
---|
1345 | ClpSimplexProgress & operator=(const ClpSimplexProgress & rhs); |
---|
1346 | /// Destructor |
---|
1347 | ~ClpSimplexProgress ( ); |
---|
1348 | //@} |
---|
1349 | |
---|
1350 | /**@name Check progress */ |
---|
1351 | //@{ |
---|
1352 | /** Returns -1 if okay, -n+1 (n number of times bad) if bad but action taken, |
---|
1353 | >=0 if give up and use as problem status |
---|
1354 | */ |
---|
1355 | int looping ( ); |
---|
1356 | /// Start check at beginning of whileIterating |
---|
1357 | void startCheck(); |
---|
1358 | /// Returns cycle length in whileIterating |
---|
1359 | int cycle(int in, int out,int wayIn,int wayOut); |
---|
1360 | |
---|
1361 | /// Returns previous objective (if -1) - current if (0) |
---|
1362 | double lastObjective(int back=1) const; |
---|
1363 | /// Set real primal infeasibility and move back |
---|
1364 | void setInfeasibility(double value); |
---|
1365 | /// Returns real primal infeasibility (if -1) - current if (0) |
---|
1366 | double lastInfeasibility(int back=1) const; |
---|
1367 | /// Modify objective e.g. if dual infeasible in dual |
---|
1368 | void modifyObjective(double value); |
---|
1369 | /// Returns previous iteration number (if -1) - current if (0) |
---|
1370 | int lastIterationNumber(int back=1) const; |
---|
1371 | /// clears all iteration numbers (to switch off panic) |
---|
1372 | void clearIterationNumbers(); |
---|
1373 | /// Odd state |
---|
1374 | inline void newOddState() |
---|
1375 | { oddState_= - oddState_-1;}; |
---|
1376 | inline void endOddState() |
---|
1377 | { oddState_=abs(oddState_);}; |
---|
1378 | inline void clearOddState() |
---|
1379 | { oddState_=0;}; |
---|
1380 | inline int oddState() const |
---|
1381 | { return oddState_;}; |
---|
1382 | /// number of bad times |
---|
1383 | inline int badTimes() const |
---|
1384 | { return numberBadTimes_;}; |
---|
1385 | inline void clearBadTimes() |
---|
1386 | { numberBadTimes_=0;}; |
---|
1387 | |
---|
1388 | //@} |
---|
1389 | /**@name Data */ |
---|
1390 | #define CLP_PROGRESS 5 |
---|
1391 | //@{ |
---|
1392 | /// Objective values |
---|
1393 | double objective_[CLP_PROGRESS]; |
---|
1394 | /// Sum of infeasibilities for algorithm |
---|
1395 | double infeasibility_[CLP_PROGRESS]; |
---|
1396 | /// Sum of real primal infeasibilities for primal |
---|
1397 | double realInfeasibility_[CLP_PROGRESS]; |
---|
1398 | #define CLP_CYCLE 12 |
---|
1399 | /// For cycle checking |
---|
1400 | //double obj_[CLP_CYCLE]; |
---|
1401 | int in_[CLP_CYCLE]; |
---|
1402 | int out_[CLP_CYCLE]; |
---|
1403 | char way_[CLP_CYCLE]; |
---|
1404 | /// Pointer back to model so we can get information |
---|
1405 | ClpSimplex * model_; |
---|
1406 | /// Number of infeasibilities |
---|
1407 | int numberInfeasibilities_[CLP_PROGRESS]; |
---|
1408 | /// Iteration number at which occurred |
---|
1409 | int iterationNumber_[CLP_PROGRESS]; |
---|
1410 | /// Number of times checked (so won't stop too early) |
---|
1411 | int numberTimes_; |
---|
1412 | /// Number of times it looked like loop |
---|
1413 | int numberBadTimes_; |
---|
1414 | /// If things are in an odd state |
---|
1415 | int oddState_; |
---|
1416 | //@} |
---|
1417 | }; |
---|
1418 | // For Devex stuff |
---|
1419 | #define DEVEX_TRY_NORM 1.0e-4 |
---|
1420 | #define DEVEX_ADD_ONE 1.0 |
---|
1421 | #endif |
---|