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