1 | // $Id$ |
---|
2 | // Copyright (C) 2000, 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 | |
---|
7 | #ifndef OsiClpSolverInterface_H |
---|
8 | #define OsiClpSolverInterface_H |
---|
9 | |
---|
10 | #include <string> |
---|
11 | #include <cfloat> |
---|
12 | #include <map> |
---|
13 | |
---|
14 | #include "ClpSimplex.hpp" |
---|
15 | #include "ClpLinearObjective.hpp" |
---|
16 | #include "CoinPackedMatrix.hpp" |
---|
17 | #include "OsiSolverInterface.hpp" |
---|
18 | #include "CoinWarmStartBasis.hpp" |
---|
19 | #include "ClpEventHandler.hpp" |
---|
20 | #include "ClpNode.hpp" |
---|
21 | #include "CoinIndexedVector.hpp" |
---|
22 | #include "CoinFinite.hpp" |
---|
23 | |
---|
24 | class OsiRowCut; |
---|
25 | class OsiClpUserSolver; |
---|
26 | class OsiClpDisasterHandler; |
---|
27 | class CoinSet; |
---|
28 | static const double OsiClpInfinity = COIN_DBL_MAX; |
---|
29 | |
---|
30 | //############################################################################# |
---|
31 | |
---|
32 | /** Clp Solver Interface |
---|
33 | |
---|
34 | Instantiation of OsiClpSolverInterface for the Model Algorithm. |
---|
35 | |
---|
36 | */ |
---|
37 | |
---|
38 | class OsiClpSolverInterface : |
---|
39 | virtual public OsiSolverInterface { |
---|
40 | friend void OsiClpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir); |
---|
41 | |
---|
42 | public: |
---|
43 | //--------------------------------------------------------------------------- |
---|
44 | /**@name Solve methods */ |
---|
45 | //@{ |
---|
46 | /// Solve initial LP relaxation |
---|
47 | virtual void initialSolve(); |
---|
48 | |
---|
49 | /// Resolve an LP relaxation after problem modification |
---|
50 | virtual void resolve(); |
---|
51 | |
---|
52 | /// Resolve an LP relaxation after problem modification (try GUB) |
---|
53 | virtual void resolveGub(int needed); |
---|
54 | |
---|
55 | /// Invoke solver's built-in enumeration algorithm |
---|
56 | virtual void branchAndBound(); |
---|
57 | |
---|
58 | /** Solve when primal column and dual row solutions are near-optimal |
---|
59 | options - 0 no presolve (use primal and dual) |
---|
60 | 1 presolve (just use primal) |
---|
61 | 2 no presolve (just use primal) |
---|
62 | basis - 0 use all slack basis |
---|
63 | 1 try and put some in basis |
---|
64 | */ |
---|
65 | void crossover(int options,int basis); |
---|
66 | //@} |
---|
67 | |
---|
68 | /*! @name OsiSimplexInterface methods |
---|
69 | \brief Methods for the Osi Simplex API. |
---|
70 | |
---|
71 | The current implementation should work for both minimisation and |
---|
72 | maximisation in mode 1 (tableau access). In mode 2 (single pivot), only |
---|
73 | minimisation is supported as of 100907. |
---|
74 | */ |
---|
75 | //@{ |
---|
76 | /** \brief Simplex API capability. |
---|
77 | |
---|
78 | Returns |
---|
79 | - 0 if no simplex API |
---|
80 | - 1 if can just do getBInv etc |
---|
81 | - 2 if has all OsiSimplex methods |
---|
82 | */ |
---|
83 | virtual int canDoSimplexInterface() const; |
---|
84 | |
---|
85 | /*! \brief Enables simplex mode 1 (tableau access) |
---|
86 | |
---|
87 | Tells solver that calls to getBInv etc are about to take place. |
---|
88 | Underlying code may need mutable as this may be called from |
---|
89 | CglCut::generateCuts which is const. If that is too horrific then |
---|
90 | each solver e.g. BCP or CBC will have to do something outside |
---|
91 | main loop. |
---|
92 | */ |
---|
93 | virtual void enableFactorization() const; |
---|
94 | |
---|
95 | /*! \brief Undo any setting changes made by #enableFactorization */ |
---|
96 | virtual void disableFactorization() const; |
---|
97 | |
---|
98 | /** Returns true if a basis is available |
---|
99 | AND problem is optimal. This should be used to see if |
---|
100 | the BInvARow type operations are possible and meaningful. |
---|
101 | */ |
---|
102 | virtual bool basisIsAvailable() const; |
---|
103 | |
---|
104 | /** The following two methods may be replaced by the |
---|
105 | methods of OsiSolverInterface using OsiWarmStartBasis if: |
---|
106 | 1. OsiWarmStartBasis resize operation is implemented |
---|
107 | more efficiently and |
---|
108 | 2. It is ensured that effects on the solver are the same |
---|
109 | |
---|
110 | Returns a basis status of the structural/artificial variables |
---|
111 | At present as warm start i.e 0 free, 1 basic, 2 upper, 3 lower |
---|
112 | |
---|
113 | NOTE artificials are treated as +1 elements so for <= rhs |
---|
114 | artificial will be at lower bound if constraint is tight |
---|
115 | |
---|
116 | This means that Clpsimplex flips artificials as it works |
---|
117 | in terms of row activities |
---|
118 | */ |
---|
119 | virtual void getBasisStatus(int* cstat, int* rstat) const; |
---|
120 | |
---|
121 | /** Set the status of structural/artificial variables and |
---|
122 | factorize, update solution etc |
---|
123 | |
---|
124 | NOTE artificials are treated as +1 elements so for <= rhs |
---|
125 | artificial will be at lower bound if constraint is tight |
---|
126 | |
---|
127 | This means that Clpsimplex flips artificials as it works |
---|
128 | in terms of row activities |
---|
129 | Returns 0 if OK, 1 if problem is bad e.g. duplicate elements, too large ... |
---|
130 | */ |
---|
131 | virtual int setBasisStatus(const int* cstat, const int* rstat); |
---|
132 | |
---|
133 | ///Get the reduced gradient for the cost vector c |
---|
134 | virtual void getReducedGradient(double* columnReducedCosts, |
---|
135 | double * duals, |
---|
136 | const double * c) const ; |
---|
137 | |
---|
138 | ///Get a row of the tableau (slack part in slack if not NULL) |
---|
139 | virtual void getBInvARow(int row, double* z, double * slack=NULL) const; |
---|
140 | |
---|
141 | /** Get a row of the tableau (slack part in slack if not NULL) |
---|
142 | If keepScaled is true then scale factors not applied after so |
---|
143 | user has to use coding similar to what is in this method |
---|
144 | */ |
---|
145 | virtual void getBInvARow(int row, CoinIndexedVector * z, CoinIndexedVector * slack=NULL, |
---|
146 | bool keepScaled=false) const; |
---|
147 | |
---|
148 | ///Get a row of the basis inverse |
---|
149 | virtual void getBInvRow(int row, double* z) const; |
---|
150 | |
---|
151 | ///Get a column of the tableau |
---|
152 | virtual void getBInvACol(int col, double* vec) const ; |
---|
153 | |
---|
154 | ///Get a column of the tableau |
---|
155 | virtual void getBInvACol(int col, CoinIndexedVector * vec) const ; |
---|
156 | |
---|
157 | /** Update (i.e. ftran) the vector passed in. |
---|
158 | Unscaling is applied after - can't be applied before |
---|
159 | */ |
---|
160 | |
---|
161 | virtual void getBInvACol(CoinIndexedVector * vec) const ; |
---|
162 | |
---|
163 | ///Get a column of the basis inverse |
---|
164 | virtual void getBInvCol(int col, double* vec) const ; |
---|
165 | |
---|
166 | /** Get basic indices (order of indices corresponds to the |
---|
167 | order of elements in a vector retured by getBInvACol() and |
---|
168 | getBInvCol()). |
---|
169 | */ |
---|
170 | virtual void getBasics(int* index) const; |
---|
171 | |
---|
172 | /*! \brief Enables simplex mode 2 (individual pivot control) |
---|
173 | |
---|
174 | This method is supposed to ensure that all typical things (like |
---|
175 | reduced costs, etc.) are updated when individual pivots are executed |
---|
176 | and can be queried by other methods. |
---|
177 | */ |
---|
178 | virtual void enableSimplexInterface(bool doingPrimal); |
---|
179 | /// Copy across enabled stuff from one solver to another |
---|
180 | void copyEnabledSuff(OsiClpSolverInterface & rhs); |
---|
181 | |
---|
182 | /*! \brief Undo setting changes made by #enableSimplexInterface */ |
---|
183 | virtual void disableSimplexInterface(); |
---|
184 | /// Copy across enabled stuff from one solver to another |
---|
185 | void copyEnabledStuff(ClpSimplex & rhs); |
---|
186 | |
---|
187 | /** Perform a pivot by substituting a colIn for colOut in the basis. |
---|
188 | The status of the leaving variable is given in statOut. Where |
---|
189 | 1 is to upper bound, -1 to lower bound |
---|
190 | Return code is 0 for okay, |
---|
191 | 1 if inaccuracy forced re-factorization (should be okay) and |
---|
192 | -1 for singular factorization |
---|
193 | */ |
---|
194 | virtual int pivot(int colIn, int colOut, int outStatus); |
---|
195 | |
---|
196 | /** Obtain a result of the primal pivot |
---|
197 | Outputs: colOut -- leaving column, outStatus -- its status, |
---|
198 | t -- step size, and, if dx!=NULL, *dx -- primal ray direction. |
---|
199 | Inputs: colIn -- entering column, sign -- direction of its change (+/-1). |
---|
200 | Both for colIn and colOut, artificial variables are index by |
---|
201 | the negative of the row index minus 1. |
---|
202 | Return code (for now): 0 -- leaving variable found, |
---|
203 | -1 -- everything else? |
---|
204 | Clearly, more informative set of return values is required |
---|
205 | Primal and dual solutions are updated |
---|
206 | */ |
---|
207 | virtual int primalPivotResult(int colIn, int sign, |
---|
208 | int& colOut, int& outStatus, |
---|
209 | double& t, CoinPackedVector* dx); |
---|
210 | |
---|
211 | /** Obtain a result of the dual pivot (similar to the previous method) |
---|
212 | Differences: entering variable and a sign of its change are now |
---|
213 | the outputs, the leaving variable and its statuts -- the inputs |
---|
214 | If dx!=NULL, then *dx contains dual ray |
---|
215 | Return code: same |
---|
216 | */ |
---|
217 | virtual int dualPivotResult(int& colIn, int& sign, |
---|
218 | int colOut, int outStatus, |
---|
219 | double& t, CoinPackedVector* dx); |
---|
220 | |
---|
221 | |
---|
222 | //@} |
---|
223 | //--------------------------------------------------------------------------- |
---|
224 | /**@name Parameter set/get methods |
---|
225 | |
---|
226 | The set methods return true if the parameter was set to the given value, |
---|
227 | false otherwise. There can be various reasons for failure: the given |
---|
228 | parameter is not applicable for the solver (e.g., refactorization |
---|
229 | frequency for the clp algorithm), the parameter is not yet implemented |
---|
230 | for the solver or simply the value of the parameter is out of the range |
---|
231 | the solver accepts. If a parameter setting call returns false check the |
---|
232 | details of your solver. |
---|
233 | |
---|
234 | The get methods return true if the given parameter is applicable for the |
---|
235 | solver and is implemented. In this case the value of the parameter is |
---|
236 | returned in the second argument. Otherwise they return false. |
---|
237 | */ |
---|
238 | //@{ |
---|
239 | // Set an integer parameter |
---|
240 | bool setIntParam(OsiIntParam key, int value); |
---|
241 | // Set an double parameter |
---|
242 | bool setDblParam(OsiDblParam key, double value); |
---|
243 | // Set a string parameter |
---|
244 | bool setStrParam(OsiStrParam key, const std::string & value); |
---|
245 | // Get an integer parameter |
---|
246 | bool getIntParam(OsiIntParam key, int& value) const; |
---|
247 | // Get an double parameter |
---|
248 | bool getDblParam(OsiDblParam key, double& value) const; |
---|
249 | // Get a string parameter |
---|
250 | bool getStrParam(OsiStrParam key, std::string& value) const; |
---|
251 | // Set a hint parameter - overrides OsiSolverInterface |
---|
252 | virtual bool setHintParam(OsiHintParam key, bool yesNo=true, |
---|
253 | OsiHintStrength strength=OsiHintTry, |
---|
254 | void * otherInformation=NULL); |
---|
255 | //@} |
---|
256 | |
---|
257 | //--------------------------------------------------------------------------- |
---|
258 | ///@name Methods returning info on how the solution process terminated |
---|
259 | //@{ |
---|
260 | /// Are there a numerical difficulties? |
---|
261 | virtual bool isAbandoned() const; |
---|
262 | /// Is optimality proven? |
---|
263 | virtual bool isProvenOptimal() const; |
---|
264 | /// Is primal infeasiblity proven? |
---|
265 | virtual bool isProvenPrimalInfeasible() const; |
---|
266 | /// Is dual infeasiblity proven? |
---|
267 | virtual bool isProvenDualInfeasible() const; |
---|
268 | /// Is the given primal objective limit reached? |
---|
269 | virtual bool isPrimalObjectiveLimitReached() const; |
---|
270 | /// Is the given dual objective limit reached? |
---|
271 | virtual bool isDualObjectiveLimitReached() const; |
---|
272 | /// Iteration limit reached? |
---|
273 | virtual bool isIterationLimitReached() const; |
---|
274 | //@} |
---|
275 | |
---|
276 | //--------------------------------------------------------------------------- |
---|
277 | /**@name WarmStart related methods */ |
---|
278 | //@{ |
---|
279 | |
---|
280 | /*! \brief Get an empty warm start object |
---|
281 | |
---|
282 | This routine returns an empty CoinWarmStartBasis object. Its purpose is |
---|
283 | to provide a way to give a client a warm start basis object of the |
---|
284 | appropriate type, which can resized and modified as desired. |
---|
285 | */ |
---|
286 | |
---|
287 | virtual CoinWarmStart *getEmptyWarmStart () const; |
---|
288 | |
---|
289 | /// Get warmstarting information |
---|
290 | virtual CoinWarmStart* getWarmStart() const; |
---|
291 | /// Get warmstarting information |
---|
292 | inline CoinWarmStartBasis* getPointerToWarmStart() |
---|
293 | { return &basis_;} |
---|
294 | /// Get warmstarting information |
---|
295 | inline const CoinWarmStartBasis* getConstPointerToWarmStart() const |
---|
296 | { return &basis_;} |
---|
297 | /** Set warmstarting information. Return true/false depending on whether |
---|
298 | the warmstart information was accepted or not. */ |
---|
299 | virtual bool setWarmStart(const CoinWarmStart* warmstart); |
---|
300 | /** \brief Get warm start information. |
---|
301 | |
---|
302 | Return warm start information for the current state of the solver |
---|
303 | interface. If there is no valid warm start information, an empty warm |
---|
304 | start object wil be returned. This does not necessarily create an |
---|
305 | object - may just point to one. must Delete set true if user |
---|
306 | should delete returned object. |
---|
307 | OsiClp version always returns pointer and false. |
---|
308 | */ |
---|
309 | virtual CoinWarmStart* getPointerToWarmStart(bool & mustDelete) ; |
---|
310 | |
---|
311 | //@} |
---|
312 | |
---|
313 | //--------------------------------------------------------------------------- |
---|
314 | /**@name Hotstart related methods (primarily used in strong branching). |
---|
315 | The user can create a hotstart (a snapshot) of the optimization process |
---|
316 | then reoptimize over and over again always starting from there.<br> |
---|
317 | <strong>NOTE</strong>: between hotstarted optimizations only |
---|
318 | bound changes are allowed. */ |
---|
319 | //@{ |
---|
320 | /// Create a hotstart point of the optimization process |
---|
321 | virtual void markHotStart(); |
---|
322 | /// Optimize starting from the hotstart |
---|
323 | virtual void solveFromHotStart(); |
---|
324 | /// Delete the snapshot |
---|
325 | virtual void unmarkHotStart(); |
---|
326 | /** Start faster dual - returns negative if problems 1 if infeasible, |
---|
327 | Options to pass to solver |
---|
328 | 1 - create external reduced costs for columns |
---|
329 | 2 - create external reduced costs for rows |
---|
330 | 4 - create external row activity (columns always done) |
---|
331 | Above only done if feasible |
---|
332 | When set resolve does less work |
---|
333 | */ |
---|
334 | int startFastDual(int options); |
---|
335 | /// Stop fast dual |
---|
336 | void stopFastDual(); |
---|
337 | /// Sets integer tolerance and increment |
---|
338 | void setStuff(double tolerance,double increment); |
---|
339 | //@} |
---|
340 | |
---|
341 | //--------------------------------------------------------------------------- |
---|
342 | /**@name Problem information methods |
---|
343 | |
---|
344 | These methods call the solver's query routines to return |
---|
345 | information about the problem referred to by the current object. |
---|
346 | Querying a problem that has no data associated with it result in |
---|
347 | zeros for the number of rows and columns, and NULL pointers from |
---|
348 | the methods that return vectors. |
---|
349 | |
---|
350 | Const pointers returned from any data-query method are valid as |
---|
351 | long as the data is unchanged and the solver is not called. |
---|
352 | */ |
---|
353 | //@{ |
---|
354 | /**@name Methods related to querying the input data */ |
---|
355 | //@{ |
---|
356 | /// Get number of columns |
---|
357 | virtual int getNumCols() const { |
---|
358 | return modelPtr_->numberColumns(); } |
---|
359 | |
---|
360 | /// Get number of rows |
---|
361 | virtual int getNumRows() const { |
---|
362 | return modelPtr_->numberRows(); } |
---|
363 | |
---|
364 | /// Get number of nonzero elements |
---|
365 | virtual int getNumElements() const { |
---|
366 | int retVal = 0; |
---|
367 | const CoinPackedMatrix * matrix =modelPtr_->matrix(); |
---|
368 | if ( matrix != NULL ) retVal=matrix->getNumElements(); |
---|
369 | return retVal; } |
---|
370 | |
---|
371 | /// Return name of row if one exists or Rnnnnnnn |
---|
372 | /// maxLen is currently ignored and only there to match the signature from the base class! |
---|
373 | virtual std::string getRowName(int rowIndex, |
---|
374 | unsigned maxLen = static_cast<unsigned>(std::string::npos)) const; |
---|
375 | |
---|
376 | /// Return name of column if one exists or Cnnnnnnn |
---|
377 | /// maxLen is currently ignored and only there to match the signature from the base class! |
---|
378 | virtual std::string getColName(int colIndex, |
---|
379 | unsigned maxLen = static_cast<unsigned>(std::string::npos)) const; |
---|
380 | |
---|
381 | |
---|
382 | /// Get pointer to array[getNumCols()] of column lower bounds |
---|
383 | virtual const double * getColLower() const { return modelPtr_->columnLower(); } |
---|
384 | |
---|
385 | /// Get pointer to array[getNumCols()] of column upper bounds |
---|
386 | virtual const double * getColUpper() const { return modelPtr_->columnUpper(); } |
---|
387 | |
---|
388 | /** Get pointer to array[getNumRows()] of row constraint senses. |
---|
389 | <ul> |
---|
390 | <li>'L' <= constraint |
---|
391 | <li>'E' = constraint |
---|
392 | <li>'G' >= constraint |
---|
393 | <li>'R' ranged constraint |
---|
394 | <li>'N' free constraint |
---|
395 | </ul> |
---|
396 | */ |
---|
397 | virtual const char * getRowSense() const; |
---|
398 | |
---|
399 | /** Get pointer to array[getNumRows()] of rows right-hand sides |
---|
400 | <ul> |
---|
401 | <li> if rowsense()[i] == 'L' then rhs()[i] == rowupper()[i] |
---|
402 | <li> if rowsense()[i] == 'G' then rhs()[i] == rowlower()[i] |
---|
403 | <li> if rowsense()[i] == 'R' then rhs()[i] == rowupper()[i] |
---|
404 | <li> if rowsense()[i] == 'N' then rhs()[i] == 0.0 |
---|
405 | </ul> |
---|
406 | */ |
---|
407 | virtual const double * getRightHandSide() const ; |
---|
408 | |
---|
409 | /** Get pointer to array[getNumRows()] of row ranges. |
---|
410 | <ul> |
---|
411 | <li> if rowsense()[i] == 'R' then |
---|
412 | rowrange()[i] == rowupper()[i] - rowlower()[i] |
---|
413 | <li> if rowsense()[i] != 'R' then |
---|
414 | rowrange()[i] is undefined |
---|
415 | </ul> |
---|
416 | */ |
---|
417 | virtual const double * getRowRange() const ; |
---|
418 | |
---|
419 | /// Get pointer to array[getNumRows()] of row lower bounds |
---|
420 | virtual const double * getRowLower() const { return modelPtr_->rowLower(); } |
---|
421 | |
---|
422 | /// Get pointer to array[getNumRows()] of row upper bounds |
---|
423 | virtual const double * getRowUpper() const { return modelPtr_->rowUpper(); } |
---|
424 | |
---|
425 | /// Get pointer to array[getNumCols()] of objective function coefficients |
---|
426 | virtual const double * getObjCoefficients() const |
---|
427 | { if (fakeMinInSimplex_) |
---|
428 | return linearObjective_ ; |
---|
429 | else |
---|
430 | return modelPtr_->objective(); } |
---|
431 | |
---|
432 | /// Get objective function sense (1 for min (default), -1 for max) |
---|
433 | virtual double getObjSense() const |
---|
434 | { return ((fakeMinInSimplex_)?-modelPtr_->optimizationDirection(): |
---|
435 | modelPtr_->optimizationDirection()); } |
---|
436 | |
---|
437 | /// Return true if column is continuous |
---|
438 | virtual bool isContinuous(int colNumber) const; |
---|
439 | /// Return true if variable is binary |
---|
440 | virtual bool isBinary(int colIndex) const; |
---|
441 | |
---|
442 | /** Return true if column is integer. |
---|
443 | Note: This function returns true if the the column |
---|
444 | is binary or a general integer. |
---|
445 | */ |
---|
446 | virtual bool isInteger(int colIndex) const; |
---|
447 | |
---|
448 | /// Return true if variable is general integer |
---|
449 | virtual bool isIntegerNonBinary(int colIndex) const; |
---|
450 | |
---|
451 | /// Return true if variable is binary and not fixed at either bound |
---|
452 | virtual bool isFreeBinary(int colIndex) const; |
---|
453 | /** Return array of column length |
---|
454 | 0 - continuous |
---|
455 | 1 - binary (may get fixed later) |
---|
456 | 2 - general integer (may get fixed later) |
---|
457 | */ |
---|
458 | virtual const char * getColType(bool refresh=false) const; |
---|
459 | |
---|
460 | /** Return true if column is integer but does not have to |
---|
461 | be declared as such. |
---|
462 | Note: This function returns true if the the column |
---|
463 | is binary or a general integer. |
---|
464 | */ |
---|
465 | bool isOptionalInteger(int colIndex) const; |
---|
466 | /** Set the index-th variable to be an optional integer variable */ |
---|
467 | void setOptionalInteger(int index); |
---|
468 | |
---|
469 | /// Get pointer to row-wise copy of matrix |
---|
470 | virtual const CoinPackedMatrix * getMatrixByRow() const; |
---|
471 | |
---|
472 | /// Get pointer to column-wise copy of matrix |
---|
473 | virtual const CoinPackedMatrix * getMatrixByCol() const; |
---|
474 | |
---|
475 | /// Get pointer to mutable column-wise copy of matrix |
---|
476 | virtual CoinPackedMatrix * getMutableMatrixByCol() const; |
---|
477 | |
---|
478 | /// Get solver's value for infinity |
---|
479 | virtual double getInfinity() const { return OsiClpInfinity; } |
---|
480 | //@} |
---|
481 | |
---|
482 | /**@name Methods related to querying the solution */ |
---|
483 | //@{ |
---|
484 | /// Get pointer to array[getNumCols()] of primal solution vector |
---|
485 | virtual const double * getColSolution() const; |
---|
486 | |
---|
487 | /// Get pointer to array[getNumRows()] of dual prices |
---|
488 | virtual const double * getRowPrice() const; |
---|
489 | |
---|
490 | /// Get a pointer to array[getNumCols()] of reduced costs |
---|
491 | virtual const double * getReducedCost() const; |
---|
492 | |
---|
493 | /** Get pointer to array[getNumRows()] of row activity levels (constraint |
---|
494 | matrix times the solution vector */ |
---|
495 | virtual const double * getRowActivity() const; |
---|
496 | |
---|
497 | /// Get objective function value |
---|
498 | virtual double getObjValue() const; |
---|
499 | |
---|
500 | /** Get how many iterations it took to solve the problem (whatever |
---|
501 | "iteration" mean to the solver. */ |
---|
502 | virtual int getIterationCount() const |
---|
503 | { return modelPtr_->numberIterations(); } |
---|
504 | |
---|
505 | /** Get as many dual rays as the solver can provide. (In case of proven |
---|
506 | primal infeasibility there should be at least one.) |
---|
507 | |
---|
508 | The first getNumRows() ray components will always be associated with |
---|
509 | the row duals (as returned by getRowPrice()). If \c fullRay is true, |
---|
510 | the final getNumCols() entries will correspond to the ray components |
---|
511 | associated with the nonbasic variables. If the full ray is requested |
---|
512 | and the method cannot provide it, it will throw an exception. |
---|
513 | |
---|
514 | <strong>NOTE for implementers of solver interfaces:</strong> <br> |
---|
515 | The double pointers in the vector should point to arrays of length |
---|
516 | getNumRows() and they should be allocated via new[]. <br> |
---|
517 | |
---|
518 | <strong>NOTE for users of solver interfaces:</strong> <br> |
---|
519 | It is the user's responsibility to free the double pointers in the |
---|
520 | vector using delete[]. |
---|
521 | */ |
---|
522 | virtual std::vector<double*> getDualRays(int maxNumRays, |
---|
523 | bool fullRay = false) const; |
---|
524 | /** Get as many primal rays as the solver can provide. (In case of proven |
---|
525 | dual infeasibility there should be at least one.) |
---|
526 | |
---|
527 | <strong>NOTE for implementers of solver interfaces:</strong> <br> |
---|
528 | The double pointers in the vector should point to arrays of length |
---|
529 | getNumCols() and they should be allocated via new[]. <br> |
---|
530 | |
---|
531 | <strong>NOTE for users of solver interfaces:</strong> <br> |
---|
532 | It is the user's responsibility to free the double pointers in the |
---|
533 | vector using delete[]. |
---|
534 | */ |
---|
535 | virtual std::vector<double*> getPrimalRays(int maxNumRays) const; |
---|
536 | |
---|
537 | //@} |
---|
538 | //@} |
---|
539 | |
---|
540 | //--------------------------------------------------------------------------- |
---|
541 | |
---|
542 | /**@name Problem modifying methods */ |
---|
543 | //@{ |
---|
544 | //------------------------------------------------------------------------- |
---|
545 | /**@name Changing bounds on variables and constraints */ |
---|
546 | //@{ |
---|
547 | /** Set an objective function coefficient */ |
---|
548 | virtual void setObjCoeff( int elementIndex, double elementValue ); |
---|
549 | |
---|
550 | /** Set a single column lower bound<br> |
---|
551 | Use -DBL_MAX for -infinity. */ |
---|
552 | virtual void setColLower( int elementIndex, double elementValue ); |
---|
553 | |
---|
554 | /** Set a single column upper bound<br> |
---|
555 | Use DBL_MAX for infinity. */ |
---|
556 | virtual void setColUpper( int elementIndex, double elementValue ); |
---|
557 | |
---|
558 | /** Set a single column lower and upper bound */ |
---|
559 | virtual void setColBounds( int elementIndex, |
---|
560 | double lower, double upper ); |
---|
561 | |
---|
562 | /** Set the bounds on a number of columns simultaneously<br> |
---|
563 | The default implementation just invokes setColLower() and |
---|
564 | setColUpper() over and over again. |
---|
565 | @param indexFirst,indexLast pointers to the beginning and after the |
---|
566 | end of the array of the indices of the variables whose |
---|
567 | <em>either</em> bound changes |
---|
568 | @param boundList the new lower/upper bound pairs for the variables |
---|
569 | */ |
---|
570 | virtual void setColSetBounds(const int* indexFirst, |
---|
571 | const int* indexLast, |
---|
572 | const double* boundList); |
---|
573 | |
---|
574 | /** Set a single row lower bound<br> |
---|
575 | Use -DBL_MAX for -infinity. */ |
---|
576 | virtual void setRowLower( int elementIndex, double elementValue ); |
---|
577 | |
---|
578 | /** Set a single row upper bound<br> |
---|
579 | Use DBL_MAX for infinity. */ |
---|
580 | virtual void setRowUpper( int elementIndex, double elementValue ) ; |
---|
581 | |
---|
582 | /** Set a single row lower and upper bound */ |
---|
583 | virtual void setRowBounds( int elementIndex, |
---|
584 | double lower, double upper ) ; |
---|
585 | |
---|
586 | /** Set the type of a single row<br> */ |
---|
587 | virtual void setRowType(int index, char sense, double rightHandSide, |
---|
588 | double range); |
---|
589 | |
---|
590 | /** Set the bounds on a number of rows simultaneously<br> |
---|
591 | The default implementation just invokes setRowLower() and |
---|
592 | setRowUpper() over and over again. |
---|
593 | @param indexFirst,indexLast pointers to the beginning and after the |
---|
594 | end of the array of the indices of the constraints whose |
---|
595 | <em>either</em> bound changes |
---|
596 | @param boundList the new lower/upper bound pairs for the constraints |
---|
597 | */ |
---|
598 | virtual void setRowSetBounds(const int* indexFirst, |
---|
599 | const int* indexLast, |
---|
600 | const double* boundList); |
---|
601 | |
---|
602 | /** Set the type of a number of rows simultaneously<br> |
---|
603 | The default implementation just invokes setRowType() |
---|
604 | over and over again. |
---|
605 | @param indexFirst,indexLast pointers to the beginning and after the |
---|
606 | end of the array of the indices of the constraints whose |
---|
607 | <em>any</em> characteristics changes |
---|
608 | @param senseList the new senses |
---|
609 | @param rhsList the new right hand sides |
---|
610 | @param rangeList the new ranges |
---|
611 | */ |
---|
612 | virtual void setRowSetTypes(const int* indexFirst, |
---|
613 | const int* indexLast, |
---|
614 | const char* senseList, |
---|
615 | const double* rhsList, |
---|
616 | const double* rangeList); |
---|
617 | /** Set the objective coefficients for all columns |
---|
618 | array [getNumCols()] is an array of values for the objective. |
---|
619 | This defaults to a series of set operations and is here for speed. |
---|
620 | */ |
---|
621 | virtual void setObjective(const double * array); |
---|
622 | |
---|
623 | /** Set the lower bounds for all columns |
---|
624 | array [getNumCols()] is an array of values for the objective. |
---|
625 | This defaults to a series of set operations and is here for speed. |
---|
626 | */ |
---|
627 | virtual void setColLower(const double * array); |
---|
628 | |
---|
629 | /** Set the upper bounds for all columns |
---|
630 | array [getNumCols()] is an array of values for the objective. |
---|
631 | This defaults to a series of set operations and is here for speed. |
---|
632 | */ |
---|
633 | virtual void setColUpper(const double * array); |
---|
634 | |
---|
635 | // using OsiSolverInterface::setRowName ; |
---|
636 | /// Set name of row |
---|
637 | // virtual void setRowName(int rowIndex, std::string & name) ; |
---|
638 | virtual void setRowName(int rowIndex, std::string name) ; |
---|
639 | |
---|
640 | // using OsiSolverInterface::setColName ; |
---|
641 | /// Set name of column |
---|
642 | // virtual void setColName(int colIndex, std::string & name) ; |
---|
643 | virtual void setColName(int colIndex, std::string name) ; |
---|
644 | |
---|
645 | //@} |
---|
646 | |
---|
647 | //------------------------------------------------------------------------- |
---|
648 | /**@name Integrality related changing methods */ |
---|
649 | //@{ |
---|
650 | /** Set the index-th variable to be a continuous variable */ |
---|
651 | virtual void setContinuous(int index); |
---|
652 | /** Set the index-th variable to be an integer variable */ |
---|
653 | virtual void setInteger(int index); |
---|
654 | /** Set the variables listed in indices (which is of length len) to be |
---|
655 | continuous variables */ |
---|
656 | virtual void setContinuous(const int* indices, int len); |
---|
657 | /** Set the variables listed in indices (which is of length len) to be |
---|
658 | integer variables */ |
---|
659 | virtual void setInteger(const int* indices, int len); |
---|
660 | /// Number of SOS sets |
---|
661 | inline int numberSOS() const |
---|
662 | { return numberSOS_;} |
---|
663 | /// SOS set info |
---|
664 | inline const CoinSet * setInfo() const |
---|
665 | { return setInfo_;} |
---|
666 | /** \brief Identify integer variables and SOS and create corresponding objects. |
---|
667 | |
---|
668 | Record integer variables and create an OsiSimpleInteger object for each |
---|
669 | one. All existing OsiSimpleInteger objects will be destroyed. |
---|
670 | If the solver supports SOS then do the same for SOS. |
---|
671 | If justCount then no objects created and we just store numberIntegers_ |
---|
672 | Returns number of SOS |
---|
673 | */ |
---|
674 | |
---|
675 | virtual int findIntegersAndSOS(bool justCount); |
---|
676 | //@} |
---|
677 | |
---|
678 | //------------------------------------------------------------------------- |
---|
679 | /// Set objective function sense (1 for min (default), -1 for max,) |
---|
680 | virtual void setObjSense(double s ) |
---|
681 | { modelPtr_->setOptimizationDirection( s < 0 ? -1 : 1); } |
---|
682 | |
---|
683 | /** Set the primal solution column values |
---|
684 | |
---|
685 | colsol[numcols()] is an array of values of the problem column |
---|
686 | variables. These values are copied to memory owned by the |
---|
687 | solver object or the solver. They will be returned as the |
---|
688 | result of colsol() until changed by another call to |
---|
689 | setColsol() or by a call to any solver routine. Whether the |
---|
690 | solver makes use of the solution in any way is |
---|
691 | solver-dependent. |
---|
692 | */ |
---|
693 | virtual void setColSolution(const double * colsol); |
---|
694 | |
---|
695 | /** Set dual solution vector |
---|
696 | |
---|
697 | rowprice[numrows()] is an array of values of the problem row |
---|
698 | dual variables. These values are copied to memory owned by the |
---|
699 | solver object or the solver. They will be returned as the |
---|
700 | result of rowprice() until changed by another call to |
---|
701 | setRowprice() or by a call to any solver routine. Whether the |
---|
702 | solver makes use of the solution in any way is |
---|
703 | solver-dependent. |
---|
704 | */ |
---|
705 | virtual void setRowPrice(const double * rowprice); |
---|
706 | |
---|
707 | //------------------------------------------------------------------------- |
---|
708 | /**@name Methods to expand a problem.<br> |
---|
709 | Note that if a column is added then by default it will correspond to a |
---|
710 | continuous variable. */ |
---|
711 | //@{ |
---|
712 | |
---|
713 | //using OsiSolverInterface::addCol ; |
---|
714 | /** */ |
---|
715 | virtual void addCol(const CoinPackedVectorBase& vec, |
---|
716 | const double collb, const double colub, |
---|
717 | const double obj); |
---|
718 | /*! \brief Add a named column (primal variable) to the problem. |
---|
719 | */ |
---|
720 | virtual void addCol(const CoinPackedVectorBase& vec, |
---|
721 | const double collb, const double colub, |
---|
722 | const double obj, std::string name) ; |
---|
723 | /** Add a column (primal variable) to the problem. */ |
---|
724 | virtual void addCol(int numberElements, const int * rows, const double * elements, |
---|
725 | const double collb, const double colub, |
---|
726 | const double obj) ; |
---|
727 | /*! \brief Add a named column (primal variable) to the problem. |
---|
728 | */ |
---|
729 | virtual void addCol(int numberElements, |
---|
730 | const int* rows, const double* elements, |
---|
731 | const double collb, const double colub, |
---|
732 | const double obj, std::string name) ; |
---|
733 | /** */ |
---|
734 | virtual void addCols(const int numcols, |
---|
735 | const CoinPackedVectorBase * const * cols, |
---|
736 | const double* collb, const double* colub, |
---|
737 | const double* obj); |
---|
738 | /** */ |
---|
739 | virtual void addCols(const int numcols, |
---|
740 | const int * columnStarts, const int * rows, const double * elements, |
---|
741 | const double* collb, const double* colub, |
---|
742 | const double* obj); |
---|
743 | /** */ |
---|
744 | virtual void deleteCols(const int num, const int * colIndices); |
---|
745 | |
---|
746 | /** */ |
---|
747 | virtual void addRow(const CoinPackedVectorBase& vec, |
---|
748 | const double rowlb, const double rowub); |
---|
749 | /** */ |
---|
750 | /*! \brief Add a named row (constraint) to the problem. |
---|
751 | |
---|
752 | The default implementation adds the row, then changes the name. This |
---|
753 | can surely be made more efficient within an OsiXXX class. |
---|
754 | */ |
---|
755 | virtual void addRow(const CoinPackedVectorBase& vec, |
---|
756 | const double rowlb, const double rowub, |
---|
757 | std::string name) ; |
---|
758 | virtual void addRow(const CoinPackedVectorBase& vec, |
---|
759 | const char rowsen, const double rowrhs, |
---|
760 | const double rowrng); |
---|
761 | /** Add a row (constraint) to the problem. */ |
---|
762 | virtual void addRow(int numberElements, const int * columns, const double * element, |
---|
763 | const double rowlb, const double rowub) ; |
---|
764 | /*! \brief Add a named row (constraint) to the problem. |
---|
765 | */ |
---|
766 | virtual void addRow(const CoinPackedVectorBase& vec, |
---|
767 | const char rowsen, const double rowrhs, |
---|
768 | const double rowrng, std::string name) ; |
---|
769 | /** */ |
---|
770 | virtual void addRows(const int numrows, |
---|
771 | const CoinPackedVectorBase * const * rows, |
---|
772 | const double* rowlb, const double* rowub); |
---|
773 | /** */ |
---|
774 | virtual void addRows(const int numrows, |
---|
775 | const CoinPackedVectorBase * const * rows, |
---|
776 | const char* rowsen, const double* rowrhs, |
---|
777 | const double* rowrng); |
---|
778 | |
---|
779 | /** */ |
---|
780 | virtual void addRows(const int numrows, |
---|
781 | const int * rowStarts, const int * columns, const double * element, |
---|
782 | const double* rowlb, const double* rowub); |
---|
783 | /// |
---|
784 | void modifyCoefficient(int row, int column, double newElement, |
---|
785 | bool keepZero=false) |
---|
786 | {modelPtr_->modifyCoefficient(row,column,newElement, keepZero);} |
---|
787 | |
---|
788 | /** */ |
---|
789 | virtual void deleteRows(const int num, const int * rowIndices); |
---|
790 | /** If solver wants it can save a copy of "base" (continuous) model here |
---|
791 | */ |
---|
792 | virtual void saveBaseModel() ; |
---|
793 | /** Strip off rows to get to this number of rows. |
---|
794 | If solver wants it can restore a copy of "base" (continuous) model here |
---|
795 | */ |
---|
796 | virtual void restoreBaseModel(int numberRows); |
---|
797 | |
---|
798 | //----------------------------------------------------------------------- |
---|
799 | /** Apply a collection of row cuts which are all effective. |
---|
800 | applyCuts seems to do one at a time which seems inefficient. |
---|
801 | */ |
---|
802 | virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts); |
---|
803 | /** Apply a collection of row cuts which are all effective. |
---|
804 | applyCuts seems to do one at a time which seems inefficient. |
---|
805 | This uses array of pointers |
---|
806 | */ |
---|
807 | virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts); |
---|
808 | /** Apply a collection of cuts. |
---|
809 | |
---|
810 | Only cuts which have an <code>effectiveness >= effectivenessLb</code> |
---|
811 | are applied. |
---|
812 | <ul> |
---|
813 | <li> ReturnCode.getNumineffective() -- number of cuts which were |
---|
814 | not applied because they had an |
---|
815 | <code>effectiveness < effectivenessLb</code> |
---|
816 | <li> ReturnCode.getNuminconsistent() -- number of invalid cuts |
---|
817 | <li> ReturnCode.getNuminconsistentWrtIntegerModel() -- number of |
---|
818 | cuts that are invalid with respect to this integer model |
---|
819 | <li> ReturnCode.getNuminfeasible() -- number of cuts that would |
---|
820 | make this integer model infeasible |
---|
821 | <li> ReturnCode.getNumApplied() -- number of integer cuts which |
---|
822 | were applied to the integer model |
---|
823 | <li> cs.size() == getNumineffective() + |
---|
824 | getNuminconsistent() + |
---|
825 | getNuminconsistentWrtIntegerModel() + |
---|
826 | getNuminfeasible() + |
---|
827 | getNumApplied() |
---|
828 | </ul> |
---|
829 | */ |
---|
830 | virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs, |
---|
831 | double effectivenessLb = 0.0); |
---|
832 | |
---|
833 | //@} |
---|
834 | //@} |
---|
835 | |
---|
836 | //--------------------------------------------------------------------------- |
---|
837 | |
---|
838 | public: |
---|
839 | |
---|
840 | /**@name Methods to input a problem */ |
---|
841 | //@{ |
---|
842 | /** Load in an problem by copying the arguments (the constraints on the |
---|
843 | rows are given by lower and upper bounds). If a pointer is NULL then the |
---|
844 | following values are the default: |
---|
845 | <ul> |
---|
846 | <li> <code>colub</code>: all columns have upper bound infinity |
---|
847 | <li> <code>collb</code>: all columns have lower bound 0 |
---|
848 | <li> <code>rowub</code>: all rows have upper bound infinity |
---|
849 | <li> <code>rowlb</code>: all rows have lower bound -infinity |
---|
850 | <li> <code>obj</code>: all variables have 0 objective coefficient |
---|
851 | </ul> |
---|
852 | */ |
---|
853 | virtual void loadProblem(const CoinPackedMatrix& matrix, |
---|
854 | const double* collb, const double* colub, |
---|
855 | const double* obj, |
---|
856 | const double* rowlb, const double* rowub); |
---|
857 | |
---|
858 | /** Load in an problem by assuming ownership of the arguments (the |
---|
859 | constraints on the rows are given by lower and upper bounds). For |
---|
860 | default values see the previous method. <br> |
---|
861 | <strong>WARNING</strong>: The arguments passed to this method will be |
---|
862 | freed using the C++ <code>delete</code> and <code>delete[]</code> |
---|
863 | functions. |
---|
864 | */ |
---|
865 | virtual void assignProblem(CoinPackedMatrix*& matrix, |
---|
866 | double*& collb, double*& colub, double*& obj, |
---|
867 | double*& rowlb, double*& rowub); |
---|
868 | |
---|
869 | /** Load in an problem by copying the arguments (the constraints on the |
---|
870 | rows are given by sense/rhs/range triplets). If a pointer is NULL then the |
---|
871 | following values are the default: |
---|
872 | <ul> |
---|
873 | <li> <code>colub</code>: all columns have upper bound infinity |
---|
874 | <li> <code>collb</code>: all columns have lower bound 0 |
---|
875 | <li> <code>obj</code>: all variables have 0 objective coefficient |
---|
876 | <li> <code>rowsen</code>: all rows are >= |
---|
877 | <li> <code>rowrhs</code>: all right hand sides are 0 |
---|
878 | <li> <code>rowrng</code>: 0 for the ranged rows |
---|
879 | </ul> |
---|
880 | */ |
---|
881 | virtual void loadProblem(const CoinPackedMatrix& matrix, |
---|
882 | const double* collb, const double* colub, |
---|
883 | const double* obj, |
---|
884 | const char* rowsen, const double* rowrhs, |
---|
885 | const double* rowrng); |
---|
886 | |
---|
887 | /** Load in an problem by assuming ownership of the arguments (the |
---|
888 | constraints on the rows are given by sense/rhs/range triplets). For |
---|
889 | default values see the previous method. <br> |
---|
890 | <strong>WARNING</strong>: The arguments passed to this method will be |
---|
891 | freed using the C++ <code>delete</code> and <code>delete[]</code> |
---|
892 | functions. |
---|
893 | */ |
---|
894 | virtual void assignProblem(CoinPackedMatrix*& matrix, |
---|
895 | double*& collb, double*& colub, double*& obj, |
---|
896 | char*& rowsen, double*& rowrhs, |
---|
897 | double*& rowrng); |
---|
898 | |
---|
899 | /** Just like the other loadProblem() methods except that the matrix is |
---|
900 | given as a ClpMatrixBase. */ |
---|
901 | virtual void loadProblem(const ClpMatrixBase& matrix, |
---|
902 | const double* collb, const double* colub, |
---|
903 | const double* obj, |
---|
904 | const double* rowlb, const double* rowub) ; |
---|
905 | |
---|
906 | /** Just like the other loadProblem() methods except that the matrix is |
---|
907 | given in a standard column major ordered format (without gaps). */ |
---|
908 | virtual void loadProblem(const int numcols, const int numrows, |
---|
909 | const CoinBigIndex * start, const int* index, |
---|
910 | const double* value, |
---|
911 | const double* collb, const double* colub, |
---|
912 | const double* obj, |
---|
913 | const double* rowlb, const double* rowub); |
---|
914 | |
---|
915 | /** Just like the other loadProblem() methods except that the matrix is |
---|
916 | given in a standard column major ordered format (without gaps). */ |
---|
917 | virtual void loadProblem(const int numcols, const int numrows, |
---|
918 | const CoinBigIndex * start, const int* index, |
---|
919 | const double* value, |
---|
920 | const double* collb, const double* colub, |
---|
921 | const double* obj, |
---|
922 | const char* rowsen, const double* rowrhs, |
---|
923 | const double* rowrng); |
---|
924 | /// This loads a model from a coinModel object - returns number of errors |
---|
925 | virtual int loadFromCoinModel ( CoinModel & modelObject, bool keepSolution=false); |
---|
926 | |
---|
927 | using OsiSolverInterface::readMps ; |
---|
928 | /** Read an mps file from the given filename (defaults to Osi reader) - returns |
---|
929 | number of errors (see OsiMpsReader class) */ |
---|
930 | virtual int readMps(const char *filename, |
---|
931 | const char *extension = "mps") ; |
---|
932 | /** Read an mps file from the given filename returns |
---|
933 | number of errors (see OsiMpsReader class) */ |
---|
934 | int readMps(const char *filename,bool keepNames,bool allowErrors); |
---|
935 | /// Read an mps file |
---|
936 | virtual int readMps (const char *filename, const char*extension, |
---|
937 | int & numberSets, CoinSet ** & sets); |
---|
938 | |
---|
939 | /** Write the problem into an mps file of the given filename. |
---|
940 | If objSense is non zero then -1.0 forces the code to write a |
---|
941 | maximization objective and +1.0 to write a minimization one. |
---|
942 | If 0.0 then solver can do what it wants */ |
---|
943 | virtual void writeMps(const char *filename, |
---|
944 | const char *extension = "mps", |
---|
945 | double objSense=0.0) const; |
---|
946 | /** Write the problem into an mps file of the given filename, |
---|
947 | names may be null. formatType is |
---|
948 | 0 - normal |
---|
949 | 1 - extra accuracy |
---|
950 | 2 - IEEE hex (later) |
---|
951 | |
---|
952 | Returns non-zero on I/O error |
---|
953 | */ |
---|
954 | virtual int writeMpsNative(const char *filename, |
---|
955 | const char ** rowNames, const char ** columnNames, |
---|
956 | int formatType=0,int numberAcross=2, |
---|
957 | double objSense=0.0) const ; |
---|
958 | /// Read file in LP format (with names) |
---|
959 | virtual int readLp(const char *filename, const double epsilon = 1e-5); |
---|
960 | /** Write the problem into an Lp file of the given filename. |
---|
961 | If objSense is non zero then -1.0 forces the code to write a |
---|
962 | maximization objective and +1.0 to write a minimization one. |
---|
963 | If 0.0 then solver can do what it wants. |
---|
964 | This version calls writeLpNative with names */ |
---|
965 | virtual void writeLp(const char *filename, |
---|
966 | const char *extension = "lp", |
---|
967 | double epsilon = 1e-5, |
---|
968 | int numberAcross = 10, |
---|
969 | int decimals = 5, |
---|
970 | double objSense = 0.0, |
---|
971 | bool useRowNames = true) const; |
---|
972 | /** Write the problem into the file pointed to by the parameter fp. |
---|
973 | Other parameters are similar to |
---|
974 | those of writeLp() with first parameter filename. |
---|
975 | */ |
---|
976 | virtual void writeLp(FILE *fp, |
---|
977 | double epsilon = 1e-5, |
---|
978 | int numberAcross = 10, |
---|
979 | int decimals = 5, |
---|
980 | double objSense = 0.0, |
---|
981 | bool useRowNames = true) const; |
---|
982 | /** |
---|
983 | I (JJF) am getting annoyed because I can't just replace a matrix. |
---|
984 | The default behavior of this is do nothing so only use where that would not matter |
---|
985 | e.g. strengthening a matrix for MIP |
---|
986 | */ |
---|
987 | virtual void replaceMatrixOptional(const CoinPackedMatrix & matrix); |
---|
988 | /// And if it does matter (not used at present) |
---|
989 | virtual void replaceMatrix(const CoinPackedMatrix & matrix) ; |
---|
990 | //@} |
---|
991 | |
---|
992 | /**@name Message handling (extra for Clp messages). |
---|
993 | Normally I presume you would want the same language. |
---|
994 | If not then you could use underlying model pointer */ |
---|
995 | //@{ |
---|
996 | /** Pass in a message handler |
---|
997 | |
---|
998 | It is the client's responsibility to destroy a message handler installed |
---|
999 | by this routine; it will not be destroyed when the solver interface is |
---|
1000 | destroyed. |
---|
1001 | */ |
---|
1002 | virtual void passInMessageHandler(CoinMessageHandler * handler); |
---|
1003 | /// Set language |
---|
1004 | void newLanguage(CoinMessages::Language language); |
---|
1005 | void setLanguage(CoinMessages::Language language) |
---|
1006 | {newLanguage(language);} |
---|
1007 | /// Set log level (will also set underlying solver's log level) |
---|
1008 | void setLogLevel(int value); |
---|
1009 | /// Create C++ lines to get to current state |
---|
1010 | void generateCpp( FILE * fp); |
---|
1011 | //@} |
---|
1012 | //--------------------------------------------------------------------------- |
---|
1013 | |
---|
1014 | /**@name Clp specific public interfaces */ |
---|
1015 | //@{ |
---|
1016 | /// Get pointer to Clp model |
---|
1017 | ClpSimplex * getModelPtr() const ; |
---|
1018 | /// Set pointer to Clp model and return old |
---|
1019 | inline ClpSimplex * swapModelPtr(ClpSimplex * newModel) |
---|
1020 | { ClpSimplex * model = modelPtr_; modelPtr_=newModel;return model;} |
---|
1021 | /// Get special options |
---|
1022 | inline unsigned int specialOptions() const |
---|
1023 | { return specialOptions_;} |
---|
1024 | void setSpecialOptions(unsigned int value); |
---|
1025 | /// Last algorithm used , 1 = primal, 2 = dual other unknown |
---|
1026 | inline int lastAlgorithm() const |
---|
1027 | { return lastAlgorithm_;} |
---|
1028 | /// Set last algorithm used , 1 = primal, 2 = dual other unknown |
---|
1029 | inline void setLastAlgorithm(int value) |
---|
1030 | { lastAlgorithm_ = value;} |
---|
1031 | /// Get scaling action option |
---|
1032 | inline int cleanupScaling() const |
---|
1033 | { return cleanupScaling_;} |
---|
1034 | /** Set Scaling option |
---|
1035 | When scaling is on it is possible that the scaled problem |
---|
1036 | is feasible but the unscaled is not. Clp returns a secondary |
---|
1037 | status code to that effect. This option allows for a cleanup. |
---|
1038 | If you use it I would suggest 1. |
---|
1039 | This only affects actions when scaled optimal |
---|
1040 | 0 - no action |
---|
1041 | 1 - clean up using dual if primal infeasibility |
---|
1042 | 2 - clean up using dual if dual infeasibility |
---|
1043 | 3 - clean up using dual if primal or dual infeasibility |
---|
1044 | 11,12,13 - as 1,2,3 but use primal |
---|
1045 | */ |
---|
1046 | inline void setCleanupScaling(int value) |
---|
1047 | { cleanupScaling_=value;} |
---|
1048 | /** Get smallest allowed element in cut. |
---|
1049 | If smaller than this then ignored */ |
---|
1050 | inline double smallestElementInCut() const |
---|
1051 | { return smallestElementInCut_;} |
---|
1052 | /** Set smallest allowed element in cut. |
---|
1053 | If smaller than this then ignored */ |
---|
1054 | inline void setSmallestElementInCut(double value) |
---|
1055 | { smallestElementInCut_=value;} |
---|
1056 | /** Get smallest change in cut. |
---|
1057 | If (upper-lower)*element < this then element is |
---|
1058 | taken out and cut relaxed. |
---|
1059 | (upper-lower) is taken to be at least 1.0 and |
---|
1060 | this is assumed >= smallestElementInCut_ |
---|
1061 | */ |
---|
1062 | inline double smallestChangeInCut() const |
---|
1063 | { return smallestChangeInCut_;} |
---|
1064 | /** Set smallest change in cut. |
---|
1065 | If (upper-lower)*element < this then element is |
---|
1066 | taken out and cut relaxed. |
---|
1067 | (upper-lower) is taken to be at least 1.0 and |
---|
1068 | this is assumed >= smallestElementInCut_ |
---|
1069 | */ |
---|
1070 | inline void setSmallestChangeInCut(double value) |
---|
1071 | { smallestChangeInCut_=value;} |
---|
1072 | /// Pass in initial solve options |
---|
1073 | inline void setSolveOptions(const ClpSolve & options) |
---|
1074 | { solveOptions_ = options;} |
---|
1075 | /** Tighten bounds - lightweight or very lightweight |
---|
1076 | 0 - normal, 1 lightweight but just integers, 2 lightweight and all |
---|
1077 | */ |
---|
1078 | virtual int tightenBounds(int lightweight=0); |
---|
1079 | /// Return number of entries in L part of current factorization |
---|
1080 | virtual CoinBigIndex getSizeL() const; |
---|
1081 | /// Return number of entries in U part of current factorization |
---|
1082 | virtual CoinBigIndex getSizeU() const; |
---|
1083 | /// Get disaster handler |
---|
1084 | const OsiClpDisasterHandler * disasterHandler() const |
---|
1085 | { return disasterHandler_;} |
---|
1086 | /// Pass in disaster handler |
---|
1087 | void passInDisasterHandler(OsiClpDisasterHandler * handler); |
---|
1088 | /// Get fake objective |
---|
1089 | ClpLinearObjective * fakeObjective() const |
---|
1090 | { return fakeObjective_;} |
---|
1091 | /// Set fake objective (and take ownership) |
---|
1092 | void setFakeObjective(ClpLinearObjective * fakeObjective); |
---|
1093 | /// Set fake objective |
---|
1094 | void setFakeObjective(double * fakeObjective); |
---|
1095 | /*! \brief Set up solver for repeated use by Osi interface. |
---|
1096 | |
---|
1097 | The normal usage does things like keeping factorization around so can be |
---|
1098 | used. Will also do things like keep scaling and row copy of matrix if |
---|
1099 | matrix does not change. |
---|
1100 | |
---|
1101 | \p senseOfAdventure: |
---|
1102 | - 0 - safe stuff as above |
---|
1103 | - 1 - will take more risks - if it does not work then bug which will be |
---|
1104 | fixed |
---|
1105 | - 2 - don't bother doing most extreme termination checks e.g. don't bother |
---|
1106 | re-factorizing if less than 20 iterations. |
---|
1107 | - 3 - Actually safer than 1 (mainly just keeps factorization) |
---|
1108 | |
---|
1109 | \p printOut |
---|
1110 | - -1 always skip round common messages instead of doing some work |
---|
1111 | - 0 skip if normal defaults |
---|
1112 | - 1 leaves |
---|
1113 | */ |
---|
1114 | void setupForRepeatedUse(int senseOfAdventure=0, int printOut=0); |
---|
1115 | /// Synchronize model (really if no cuts in tree) |
---|
1116 | virtual void synchronizeModel(); |
---|
1117 | /*! \brief Set special options in underlying clp solver. |
---|
1118 | |
---|
1119 | Safe as const because #modelPtr_ is mutable. |
---|
1120 | */ |
---|
1121 | void setSpecialOptionsMutable(unsigned int value) const; |
---|
1122 | |
---|
1123 | //@} |
---|
1124 | |
---|
1125 | //--------------------------------------------------------------------------- |
---|
1126 | |
---|
1127 | /**@name Constructors and destructors */ |
---|
1128 | //@{ |
---|
1129 | /// Default Constructor |
---|
1130 | OsiClpSolverInterface (); |
---|
1131 | |
---|
1132 | /// Clone |
---|
1133 | virtual OsiSolverInterface * clone(bool copyData = true) const; |
---|
1134 | |
---|
1135 | /// Copy constructor |
---|
1136 | OsiClpSolverInterface (const OsiClpSolverInterface &); |
---|
1137 | |
---|
1138 | /// Borrow constructor - only delete one copy |
---|
1139 | OsiClpSolverInterface (ClpSimplex * rhs, bool reallyOwn=false); |
---|
1140 | |
---|
1141 | /// Releases so won't error |
---|
1142 | void releaseClp(); |
---|
1143 | |
---|
1144 | /// Assignment operator |
---|
1145 | OsiClpSolverInterface & operator=(const OsiClpSolverInterface& rhs); |
---|
1146 | |
---|
1147 | /// Destructor |
---|
1148 | virtual ~OsiClpSolverInterface (); |
---|
1149 | |
---|
1150 | /// Resets as if default constructor |
---|
1151 | virtual void reset(); |
---|
1152 | //@} |
---|
1153 | |
---|
1154 | //--------------------------------------------------------------------------- |
---|
1155 | |
---|
1156 | protected: |
---|
1157 | ///@name Protected methods |
---|
1158 | //@{ |
---|
1159 | /** Apply a row cut (append to constraint matrix). */ |
---|
1160 | virtual void applyRowCut(const OsiRowCut& rc); |
---|
1161 | |
---|
1162 | /** Apply a column cut (adjust one or more bounds). */ |
---|
1163 | virtual void applyColCut(const OsiColCut& cc); |
---|
1164 | //@} |
---|
1165 | |
---|
1166 | //--------------------------------------------------------------------------- |
---|
1167 | |
---|
1168 | protected: |
---|
1169 | /**@name Protected methods */ |
---|
1170 | //@{ |
---|
1171 | /// The real work of a copy constructor (used by copy and assignment) |
---|
1172 | void gutsOfDestructor(); |
---|
1173 | |
---|
1174 | /// Deletes all mutable stuff |
---|
1175 | void freeCachedResults() const; |
---|
1176 | |
---|
1177 | /// Deletes all mutable stuff for row ranges etc |
---|
1178 | void freeCachedResults0() const; |
---|
1179 | |
---|
1180 | /// Deletes all mutable stuff for matrix etc |
---|
1181 | void freeCachedResults1() const; |
---|
1182 | |
---|
1183 | /// A method that fills up the rowsense_, rhs_ and rowrange_ arrays |
---|
1184 | void extractSenseRhsRange() const; |
---|
1185 | |
---|
1186 | /// |
---|
1187 | void fillParamMaps(); |
---|
1188 | /** Warm start |
---|
1189 | |
---|
1190 | NOTE artificials are treated as +1 elements so for <= rhs |
---|
1191 | artificial will be at lower bound if constraint is tight |
---|
1192 | |
---|
1193 | This means that Clpsimplex flips artificials as it works |
---|
1194 | in terms of row activities |
---|
1195 | */ |
---|
1196 | CoinWarmStartBasis getBasis(ClpSimplex * model) const; |
---|
1197 | /** Sets up working basis as a copy of input |
---|
1198 | |
---|
1199 | NOTE artificials are treated as +1 elements so for <= rhs |
---|
1200 | artificial will be at lower bound if constraint is tight |
---|
1201 | |
---|
1202 | This means that Clpsimplex flips artificials as it works |
---|
1203 | in terms of row activities |
---|
1204 | */ |
---|
1205 | void setBasis( const CoinWarmStartBasis & basis, ClpSimplex * model); |
---|
1206 | /// Crunch down problem a bit |
---|
1207 | void crunch(); |
---|
1208 | /// Extend scale factors |
---|
1209 | void redoScaleFactors(int numberRows,const CoinBigIndex * starts, |
---|
1210 | const int * indices, const double * elements); |
---|
1211 | public: |
---|
1212 | /** Sets up working basis as a copy of input and puts in as basis |
---|
1213 | */ |
---|
1214 | void setBasis( const CoinWarmStartBasis & basis); |
---|
1215 | /// Just puts current basis_ into ClpSimplex model |
---|
1216 | inline void setBasis( ) |
---|
1217 | { setBasis(basis_,modelPtr_);} |
---|
1218 | /// Warm start difference from basis_ to statusArray |
---|
1219 | CoinWarmStartDiff * getBasisDiff(const unsigned char * statusArray) const ; |
---|
1220 | /// Warm start from statusArray |
---|
1221 | CoinWarmStartBasis * getBasis(const unsigned char * statusArray) const ; |
---|
1222 | /// Delete all scale factor stuff and reset option |
---|
1223 | void deleteScaleFactors(); |
---|
1224 | /// If doing fast hot start then ranges are computed |
---|
1225 | inline const double * upRange() const |
---|
1226 | { return rowActivity_;} |
---|
1227 | inline const double * downRange() const |
---|
1228 | { return columnActivity_;} |
---|
1229 | /// Pass in range array |
---|
1230 | inline void passInRanges(int * array) |
---|
1231 | { whichRange_=array;} |
---|
1232 | /// Pass in sos stuff from AMPl |
---|
1233 | void setSOSData(int numberSOS,const char * type, |
---|
1234 | const int * start,const int * indices, const double * weights=NULL); |
---|
1235 | /// Compute largest amount any at continuous away from bound |
---|
1236 | void computeLargestAway(); |
---|
1237 | /// Get largest amount continuous away from bound |
---|
1238 | inline double largestAway() const |
---|
1239 | { return largestAway_;} |
---|
1240 | /// Set largest amount continuous away from bound |
---|
1241 | inline void setLargestAway(double value) |
---|
1242 | { largestAway_ = value;} |
---|
1243 | /// Sort of lexicographic resolve |
---|
1244 | void lexSolve(); |
---|
1245 | //@} |
---|
1246 | |
---|
1247 | protected: |
---|
1248 | /**@name Protected member data */ |
---|
1249 | //@{ |
---|
1250 | /// Clp model represented by this class instance |
---|
1251 | mutable ClpSimplex * modelPtr_; |
---|
1252 | //@} |
---|
1253 | /**@name Cached information derived from the OSL model */ |
---|
1254 | //@{ |
---|
1255 | /// Pointer to dense vector of row sense indicators |
---|
1256 | mutable char *rowsense_; |
---|
1257 | |
---|
1258 | /// Pointer to dense vector of row right-hand side values |
---|
1259 | mutable double *rhs_; |
---|
1260 | |
---|
1261 | /** Pointer to dense vector of slack upper bounds for range |
---|
1262 | constraints (undefined for non-range rows) |
---|
1263 | */ |
---|
1264 | mutable double *rowrange_; |
---|
1265 | |
---|
1266 | /** A pointer to the warmstart information to be used in the hotstarts. |
---|
1267 | This is NOT efficient and more thought should be given to it... */ |
---|
1268 | mutable CoinWarmStartBasis* ws_; |
---|
1269 | /** also save row and column information for hot starts |
---|
1270 | only used in hotstarts so can be casual */ |
---|
1271 | mutable double * rowActivity_; |
---|
1272 | mutable double * columnActivity_; |
---|
1273 | /// Stuff for fast dual |
---|
1274 | ClpNodeStuff stuff_; |
---|
1275 | /// Number of SOS sets |
---|
1276 | int numberSOS_; |
---|
1277 | /// SOS set info |
---|
1278 | CoinSet * setInfo_; |
---|
1279 | /// Alternate model (hot starts) - but also could be permanent and used for crunch |
---|
1280 | ClpSimplex * smallModel_; |
---|
1281 | /// factorization for hot starts |
---|
1282 | ClpFactorization * factorization_; |
---|
1283 | /** Smallest allowed element in cut. |
---|
1284 | If smaller than this then ignored */ |
---|
1285 | double smallestElementInCut_; |
---|
1286 | /** Smallest change in cut. |
---|
1287 | If (upper-lower)*element < this then element is |
---|
1288 | taken out and cut relaxed. */ |
---|
1289 | double smallestChangeInCut_; |
---|
1290 | /// Largest amount continuous away from bound |
---|
1291 | double largestAway_; |
---|
1292 | /// Arrays for hot starts |
---|
1293 | char * spareArrays_; |
---|
1294 | /** Warmstart information to be used in resolves. */ |
---|
1295 | CoinWarmStartBasis basis_; |
---|
1296 | /** The original iteration limit before hotstarts started. */ |
---|
1297 | int itlimOrig_; |
---|
1298 | |
---|
1299 | /*! \brief Last algorithm used |
---|
1300 | |
---|
1301 | Coded as |
---|
1302 | - 0 invalid |
---|
1303 | - 1 primal |
---|
1304 | - 2 dual |
---|
1305 | - -911 disaster in the algorithm that was attempted |
---|
1306 | - 999 current solution no longer optimal due to change in problem or |
---|
1307 | basis |
---|
1308 | */ |
---|
1309 | mutable int lastAlgorithm_; |
---|
1310 | |
---|
1311 | /// To say if destructor should delete underlying model |
---|
1312 | bool notOwned_; |
---|
1313 | |
---|
1314 | /// Pointer to row-wise copy of problem matrix coefficients. |
---|
1315 | mutable CoinPackedMatrix *matrixByRow_; |
---|
1316 | |
---|
1317 | /// Pointer to row-wise copy of continuous problem matrix coefficients. |
---|
1318 | CoinPackedMatrix *matrixByRowAtContinuous_; |
---|
1319 | |
---|
1320 | /// Pointer to integer information |
---|
1321 | char * integerInformation_; |
---|
1322 | |
---|
1323 | /** Pointer to variables for which we want range information |
---|
1324 | The number is in [0] |
---|
1325 | memory is not owned by OsiClp |
---|
1326 | */ |
---|
1327 | int * whichRange_; |
---|
1328 | |
---|
1329 | //std::map<OsiIntParam, ClpIntParam> intParamMap_; |
---|
1330 | //std::map<OsiDblParam, ClpDblParam> dblParamMap_; |
---|
1331 | //std::map<OsiStrParam, ClpStrParam> strParamMap_; |
---|
1332 | |
---|
1333 | /*! \brief Faking min to get proper dual solution signs in simplex API */ |
---|
1334 | mutable bool fakeMinInSimplex_ ; |
---|
1335 | /*! \brief Linear objective |
---|
1336 | |
---|
1337 | Normally a pointer to the linear coefficient array in the clp objective. |
---|
1338 | An independent copy when #fakeMinInSimplex_ is true, because we need |
---|
1339 | something permanent to point to when #getObjCoefficients is called. |
---|
1340 | */ |
---|
1341 | mutable double *linearObjective_; |
---|
1342 | |
---|
1343 | /// To save data in OsiSimplex stuff |
---|
1344 | mutable ClpDataSave saveData_; |
---|
1345 | /// Options for initialSolve |
---|
1346 | ClpSolve solveOptions_; |
---|
1347 | /** Scaling option |
---|
1348 | When scaling is on it is possible that the scaled problem |
---|
1349 | is feasible but the unscaled is not. Clp returns a secondary |
---|
1350 | status code to that effect. This option allows for a cleanup. |
---|
1351 | If you use it I would suggest 1. |
---|
1352 | This only affects actions when scaled optimal |
---|
1353 | 0 - no action |
---|
1354 | 1 - clean up using dual if primal infeasibility |
---|
1355 | 2 - clean up using dual if dual infeasibility |
---|
1356 | 3 - clean up using dual if primal or dual infeasibility |
---|
1357 | 11,12,13 - as 1,2,3 but use primal |
---|
1358 | */ |
---|
1359 | int cleanupScaling_; |
---|
1360 | /** Special options |
---|
1361 | 0x80000000 off |
---|
1362 | 0 simple stuff for branch and bound |
---|
1363 | 1 try and keep work regions as much as possible |
---|
1364 | 2 do not use any perturbation |
---|
1365 | 4 allow exit before re-factorization |
---|
1366 | 8 try and re-use factorization if no cuts |
---|
1367 | 16 use standard strong branching rather than clp's |
---|
1368 | 32 Just go to first factorization in fast dual |
---|
1369 | 64 try and tighten bounds in crunch |
---|
1370 | 128 Model will only change in column bounds |
---|
1371 | 256 Clean up model before hot start |
---|
1372 | 512 Give user direct access to Clp regions in getBInvARow etc (i.e., |
---|
1373 | do not unscale, and do not return result in getBInv parameters; |
---|
1374 | you have to know where to look for the answer) |
---|
1375 | 1024 Don't "borrow" model in initialSolve |
---|
1376 | 2048 Don't crunch |
---|
1377 | 4096 quick check for optimality |
---|
1378 | Bits above 8192 give where called from in Cbc |
---|
1379 | At present 0 is normal, 1 doing fast hotstarts, 2 is can do quick check |
---|
1380 | 65536 Keep simple i.e. no crunch etc |
---|
1381 | 131072 Try and keep scaling factors around |
---|
1382 | 262144 Don't try and tighten bounds (funny global cuts) |
---|
1383 | 524288 Fake objective and 0-1 |
---|
1384 | 1048576 Don't recompute ray after crunch |
---|
1385 | 2097152 |
---|
1386 | */ |
---|
1387 | mutable unsigned int specialOptions_; |
---|
1388 | /// Copy of model when option 131072 set |
---|
1389 | ClpSimplex * baseModel_; |
---|
1390 | /// Number of rows when last "scaled" |
---|
1391 | int lastNumberRows_; |
---|
1392 | /// Continuous model |
---|
1393 | ClpSimplex * continuousModel_; |
---|
1394 | /// Possible disaster handler |
---|
1395 | OsiClpDisasterHandler * disasterHandler_ ; |
---|
1396 | /// Fake objective |
---|
1397 | ClpLinearObjective * fakeObjective_; |
---|
1398 | /// Row scale factors (has inverse at end) |
---|
1399 | CoinDoubleArrayWithLength rowScale_; |
---|
1400 | /// Column scale factors (has inverse at end) |
---|
1401 | CoinDoubleArrayWithLength columnScale_; |
---|
1402 | //@} |
---|
1403 | }; |
---|
1404 | |
---|
1405 | class OsiClpDisasterHandler : public ClpDisasterHandler { |
---|
1406 | public: |
---|
1407 | /**@name Virtual methods that the derived classe should provide. |
---|
1408 | */ |
---|
1409 | //@{ |
---|
1410 | /// Into simplex |
---|
1411 | virtual void intoSimplex(); |
---|
1412 | /// Checks if disaster |
---|
1413 | virtual bool check() const ; |
---|
1414 | /// saves information for next attempt |
---|
1415 | virtual void saveInfo(); |
---|
1416 | /// Type of disaster 0 can fix, 1 abort |
---|
1417 | virtual int typeOfDisaster(); |
---|
1418 | //@} |
---|
1419 | |
---|
1420 | |
---|
1421 | /**@name Constructors, destructor */ |
---|
1422 | |
---|
1423 | //@{ |
---|
1424 | /** Default constructor. */ |
---|
1425 | OsiClpDisasterHandler(OsiClpSolverInterface * model = NULL); |
---|
1426 | /** Destructor */ |
---|
1427 | virtual ~OsiClpDisasterHandler(); |
---|
1428 | // Copy |
---|
1429 | OsiClpDisasterHandler(const OsiClpDisasterHandler&); |
---|
1430 | // Assignment |
---|
1431 | OsiClpDisasterHandler& operator=(const OsiClpDisasterHandler&); |
---|
1432 | /// Clone |
---|
1433 | virtual ClpDisasterHandler * clone() const; |
---|
1434 | |
---|
1435 | //@} |
---|
1436 | |
---|
1437 | /**@name Sets/gets */ |
---|
1438 | |
---|
1439 | //@{ |
---|
1440 | /** set model. */ |
---|
1441 | void setOsiModel(OsiClpSolverInterface * model); |
---|
1442 | /// Get model |
---|
1443 | inline OsiClpSolverInterface * osiModel() const |
---|
1444 | { return osiModel_;} |
---|
1445 | /// Set where from |
---|
1446 | inline void setWhereFrom(int value) |
---|
1447 | { whereFrom_=value;} |
---|
1448 | /// Get where from |
---|
1449 | inline int whereFrom() const |
---|
1450 | { return whereFrom_;} |
---|
1451 | /// Set phase |
---|
1452 | inline void setPhase(int value) |
---|
1453 | { phase_=value;} |
---|
1454 | /// Get phase |
---|
1455 | inline int phase() const |
---|
1456 | { return phase_;} |
---|
1457 | /// are we in trouble |
---|
1458 | inline bool inTrouble() const |
---|
1459 | { return inTrouble_;} |
---|
1460 | |
---|
1461 | //@} |
---|
1462 | |
---|
1463 | |
---|
1464 | protected: |
---|
1465 | /**@name Data members |
---|
1466 | The data members are protected to allow access for derived classes. */ |
---|
1467 | //@{ |
---|
1468 | /// Pointer to model |
---|
1469 | OsiClpSolverInterface * osiModel_; |
---|
1470 | /** Where from |
---|
1471 | 0 dual (resolve) |
---|
1472 | 1 crunch |
---|
1473 | 2 primal (resolve) |
---|
1474 | 4 dual (initialSolve) |
---|
1475 | 6 primal (initialSolve) |
---|
1476 | */ |
---|
1477 | int whereFrom_; |
---|
1478 | /** phase |
---|
1479 | 0 initial |
---|
1480 | 1 trying continuing with back in and maybe different perturb |
---|
1481 | 2 trying continuing with back in and different scaling |
---|
1482 | 3 trying dual from all slack |
---|
1483 | 4 trying primal from previous stored basis |
---|
1484 | */ |
---|
1485 | int phase_; |
---|
1486 | /// Are we in trouble |
---|
1487 | bool inTrouble_; |
---|
1488 | //@} |
---|
1489 | }; |
---|
1490 | // So unit test can find out if NDEBUG set |
---|
1491 | bool OsiClpHasNDEBUG(); |
---|
1492 | //############################################################################# |
---|
1493 | /** A function that tests the methods in the OsiClpSolverInterface class. */ |
---|
1494 | void OsiClpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir); |
---|
1495 | #endif |
---|