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

Last change on this file since 2007 was 1972, checked in by forrest, 7 years ago

changes to allow more options and stop on feasible (and a few other things)

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