source: trunk/Clp/src/OsiClp/OsiClpSolverInterface.hpp @ 1559

Last change on this file since 1559 was 1559, checked in by stefan, 10 years ago

merge split branch into trunk

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