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

Last change on this file since 1288 was 1288, checked in by forrest, 11 years ago

add isObjectiveLimitTestValid

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