source: trunk/Clp/src/ClpSimplex.hpp @ 1264

Last change on this file since 1264 was 1264, checked in by forrest, 13 years ago

BSP changes from 1247 to 1259

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