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

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

changes for factorization and aux region

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 53.7 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  /// Sum of dual infeasibilities
543  inline double sumDualInfeasibilities() const 
544          { return sumDualInfeasibilities_;} 
545  inline void setSumDualInfeasibilities(double value)
546          { sumDualInfeasibilities_=value;} 
547  /// Sum of relaxed dual infeasibilities
548  inline double sumOfRelaxedDualInfeasibilities() const 
549          { return sumOfRelaxedDualInfeasibilities_;} 
550  inline void setSumOfRelaxedDualInfeasibilities(double value)
551          { sumOfRelaxedDualInfeasibilities_=value;} 
552  /// Number of dual infeasibilities
553  inline int numberDualInfeasibilities() const 
554          { return numberDualInfeasibilities_;} 
555  inline void setNumberDualInfeasibilities(int value)
556          { numberDualInfeasibilities_=value;} 
557  /// Number of dual infeasibilities (without free)
558  inline int numberDualInfeasibilitiesWithoutFree() const 
559          { return numberDualInfeasibilitiesWithoutFree_;} 
560  /// Sum of primal infeasibilities
561  inline double sumPrimalInfeasibilities() const 
562          { return sumPrimalInfeasibilities_;} 
563  inline void setSumPrimalInfeasibilities(double value)
564          { sumPrimalInfeasibilities_=value;} 
565  /// Sum of relaxed primal infeasibilities
566  inline double sumOfRelaxedPrimalInfeasibilities() const 
567          { return sumOfRelaxedPrimalInfeasibilities_;} 
568  inline void setSumOfRelaxedPrimalInfeasibilities(double value)
569          { sumOfRelaxedPrimalInfeasibilities_=value;} 
570  /// Number of primal infeasibilities
571  inline int numberPrimalInfeasibilities() const 
572          { return numberPrimalInfeasibilities_;} 
573  inline void setNumberPrimalInfeasibilities(int value)
574          { numberPrimalInfeasibilities_=value;} 
575  /** Save model to file, returns 0 if success.  This is designed for
576      use outside algorithms so does not save iterating arrays etc.
577  It does not save any messaging information.
578  Does not save scaling values.
579  It does not know about all types of virtual functions.
580  */
581  int saveModel(const char * fileName);
582  /** Restore model from file, returns 0 if success,
583      deletes current model */
584  int restoreModel(const char * fileName);
585 
586  /** Just check solution (for external use) - sets sum of
587      infeasibilities etc.
588      If setToBounds 0 then primal column values not changed
589      and used to compute primal row activity values.  If 1 or 2
590      then status used - so all nonbasic variables set to
591      indicated bound and if any values changed (or ==2)  basic values re-computed.
592  */
593  void checkSolution(int setToBounds=false);
594  /** Just check solution (for internal use) - sets sum of
595      infeasibilities etc. */
596  void checkSolutionInternal();
597  /// Useful row length arrays (0,1,2,3,4,5)
598  inline CoinIndexedVector * rowArray(int index) const
599  { return rowArray_[index];}
600  /// Useful column length arrays (0,1,2,3,4,5)
601  inline CoinIndexedVector * columnArray(int index) const
602  { return columnArray_[index];}
603  //@}
604
605  /******************** End of most useful part **************/
606  /**@name Functions less likely to be useful to casual user */
607  //@{
608  /** Given an existing factorization computes and checks
609      primal and dual solutions.  Uses input arrays for variables at
610      bounds.  Returns feasibility states */
611  int getSolution (  const double * rowActivities,
612                     const double * columnActivities);
613  /** Given an existing factorization computes and checks
614      primal and dual solutions.  Uses current problem arrays for
615      bounds.  Returns feasibility states */
616  int getSolution ();
617  /** Constructs a non linear cost from list of non-linearities (columns only)
618      First lower of each column is taken as real lower
619      Last lower is taken as real upper and cost ignored
620
621      Returns nonzero if bad data e.g. lowers not monotonic
622  */
623  int createPiecewiseLinearCosts(const int * starts,
624                   const double * lower, const double * gradient);
625  /// dual row pivot choice
626  ClpDualRowPivot * dualRowPivot() const
627  { return dualRowPivot_;}
628  /// Returns true if model looks OK
629  inline bool goodAccuracy() const
630  { return (largestPrimalError_<1.0e-7&&largestDualError_<1.0e-7);}
631  /** Return model - updates any scalars */
632  void returnModel(ClpSimplex & otherModel);
633  /** Factorizes using current basis. 
634      solveType - 1 iterating, 0 initial, -1 external
635      If 10 added then in primal values pass
636      Return codes are as from ClpFactorization unless initial factorization
637      when total number of singularities is returned.
638      Special case is numberRows_+1 -> all slack basis.
639  */
640  int internalFactorize(int solveType);
641  /// Save data
642  ClpDataSave saveData() ;
643  /// Restore data
644  void restoreData(ClpDataSave saved);
645  /// Clean up status
646  void cleanStatus();
647  /// Factorizes using current basis. For external use
648  int factorize();
649  /** Computes duals from scratch. If givenDjs then
650      allows for nonzero basic djs */
651  void computeDuals(double * givenDjs);
652  /// Computes primals from scratch
653  void computePrimals (  const double * rowActivities,
654                     const double * columnActivities);
655  /** Adds multiple of a column into an array */
656  void add(double * array,
657                   int column, double multiplier) const;
658  /**
659     Unpacks one column of the matrix into indexed array
660     Uses sequenceIn_
661     Also applies scaling if needed
662  */
663  void unpack(CoinIndexedVector * rowArray) const ;
664  /**
665     Unpacks one column of the matrix into indexed array
666     Slack if sequence>= numberColumns
667     Also applies scaling if needed
668  */
669  void unpack(CoinIndexedVector * rowArray,int sequence) const;
670  /**
671     Unpacks one column of the matrix into indexed array
672     ** as packed vector
673     Uses sequenceIn_
674     Also applies scaling if needed
675  */
676  void unpackPacked(CoinIndexedVector * rowArray) ;
677  /**
678     Unpacks one column of the matrix into indexed array
679     ** as packed vector
680     Slack if sequence>= numberColumns
681     Also applies scaling if needed
682  */
683  void unpackPacked(CoinIndexedVector * rowArray,int sequence);
684protected: 
685  /**
686      This does basis housekeeping and does values for in/out variables.
687      Can also decide to re-factorize
688  */
689  int housekeeping(double objectiveChange);
690  /** This sets largest infeasibility and most infeasible and sum
691      and number of infeasibilities (Primal) */
692  void checkPrimalSolution(const double * rowActivities=NULL,
693                           const double * columnActivies=NULL);
694  /** This sets largest infeasibility and most infeasible and sum
695      and number of infeasibilities (Dual) */
696  void checkDualSolution();
697  /** This sets sum and number of infeasibilities (Dual and Primal) */
698  void checkBothSolutions();
699public:
700  /** For advanced use.  When doing iterative solves things can get
701      nasty so on values pass if incoming solution has largest
702      infeasibility < incomingInfeasibility throw out variables
703      from basis until largest infeasibility < allowedInfeasibility
704      or incoming largest infeasibility.
705      If allowedInfeasibility>= incomingInfeasibility this is
706      always possible altough you may end up with an all slack basis.
707
708      Defaults are 1.0,10.0
709  */
710  void setValuesPassAction(double incomingInfeasibility,
711                           double allowedInfeasibility);
712  //@}
713  /**@name most useful gets and sets */
714  //@{
715public: 
716  /// Initial value for alpha accuracy calculation (-1.0 off)
717  inline double alphaAccuracy() const
718          { return alphaAccuracy_;} 
719  inline void setAlphaAccuracy(double value)
720          { alphaAccuracy_ = value;} 
721public:
722  /// Set disaster handler
723  inline void setDisasterHandler(ClpDisasterHandler * handler)
724  { disasterArea_= handler;}
725  /// Get disaster handler
726  inline ClpDisasterHandler * disasterHandler() const
727  { return disasterArea_;}
728  /// Large bound value (for complementarity etc)
729  inline double largeValue() const 
730          { return largeValue_;} 
731  void setLargeValue( double value) ;
732  /// Largest error on Ax-b
733  inline double largestPrimalError() const
734          { return largestPrimalError_;} 
735  /// Largest error on basic duals
736  inline double largestDualError() const
737          { return largestDualError_;} 
738  /// Largest error on Ax-b
739  inline void setLargestPrimalError(double value)
740          { largestPrimalError_=value;} 
741  /// Largest error on basic duals
742  inline void setLargestDualError(double value)
743          { largestDualError_=value;} 
744  /// Basic variables pivoting on which rows
745  inline int * pivotVariable() const
746          { return pivotVariable_;}
747  /// If automatic scaling on
748  inline bool automaticScaling() const
749  { return automaticScale_!=0;}
750  inline void setAutomaticScaling(bool onOff)
751  { automaticScale_ = onOff ? 1: 0;} 
752  /// Current dual tolerance
753  inline double currentDualTolerance() const 
754          { return dualTolerance_;} 
755  inline void setCurrentDualTolerance(double value)
756          { dualTolerance_ = value;} 
757  /// Current primal tolerance
758  inline double currentPrimalTolerance() const 
759          { return primalTolerance_;} 
760  inline void setCurrentPrimalTolerance(double value)
761          { primalTolerance_ = value;} 
762  /// How many iterative refinements to do
763  inline int numberRefinements() const 
764          { return numberRefinements_;} 
765  void setNumberRefinements( int value) ;
766  /// Alpha (pivot element) for use by classes e.g. steepestedge
767  inline double alpha() const { return alpha_;}
768  inline void setAlpha(double value) { alpha_ = value;}
769  /// Reduced cost of last incoming for use by classes e.g. steepestedge
770  inline double dualIn() const { return dualIn_;}
771  /// Pivot Row for use by classes e.g. steepestedge
772  inline int pivotRow() const{ return pivotRow_;}
773  inline void setPivotRow(int value) { pivotRow_=value;}
774  /// value of incoming variable (in Dual)
775  double valueIncomingDual() const;
776  //@}
777
778  protected:
779  /**@name protected methods */
780  //@{
781  /** May change basis and then returns number changed.
782      Computation of solutions may be overriden by given pi and solution
783  */
784  int gutsOfSolution ( double * givenDuals,
785                       const double * givenPrimals,
786                       bool valuesPass=false);
787  /// Does most of deletion (0 = all, 1 = most, 2 most + factorization)
788  void gutsOfDelete(int type);
789  /// Does most of copying
790  void gutsOfCopy(const ClpSimplex & rhs);
791  /** puts in format I like (rowLower,rowUpper) also see StandardMatrix
792      1 bit does rows (now and columns), (2 bit does column bounds), 4 bit does objective(s).
793      8 bit does solution scaling in
794      16 bit does rowArray and columnArray indexed vectors
795      and makes row copy if wanted, also sets columnStart_ etc
796      Also creates scaling arrays if needed.  It does scaling if needed.
797      16 also moves solutions etc in to work arrays
798      On 16 returns false if problem "bad" i.e. matrix or bounds bad
799      If startFinishOptions is -1 then called by user in getSolution
800      so do arrays but keep pivotVariable_
801  */
802  bool createRim(int what,bool makeRowCopy=false,int startFinishOptions=0);
803  /// Does rows and columns
804  void createRim1(bool initial);
805  /// Does objective
806  void createRim4(bool initial);
807  /// Does rows and columns and objective
808  void createRim5(bool initial);
809  /** releases above arrays and does solution scaling out.  May also
810      get rid of factorization data -
811      0 get rid of nothing, 1 get rid of arrays, 2 also factorization
812  */
813  void deleteRim(int getRidOfFactorizationData=2);
814  /// Sanity check on input rim data (after scaling) - returns true if okay
815  bool sanityCheck();
816  //@}
817  public:
818  /**@name public methods */
819  //@{
820  /** Return row or column sections - not as much needed as it
821      once was.  These just map into single arrays */
822  inline double * solutionRegion(int section) const
823  { if (!section) return rowActivityWork_; else return columnActivityWork_;}
824  inline double * djRegion(int section) const
825  { if (!section) return rowReducedCost_; else return reducedCostWork_;}
826  inline double * lowerRegion(int section) const
827  { if (!section) return rowLowerWork_; else return columnLowerWork_;}
828  inline double * upperRegion(int section) const
829  { if (!section) return rowUpperWork_; else return columnUpperWork_;}
830  inline double * costRegion(int section) const
831  { if (!section) return rowObjectiveWork_; else return objectiveWork_;}
832  /// Return region as single array
833  inline double * solutionRegion() const
834  { return solution_;}
835  inline double * djRegion() const
836  { return dj_;}
837  inline double * lowerRegion() const
838  { return lower_;}
839  inline double * upperRegion() const
840  { return upper_;}
841  inline double * costRegion() const
842  { return cost_;}
843  inline Status getStatus(int sequence) const
844  {return static_cast<Status> (status_[sequence]&7);}
845  inline void setStatus(int sequence, Status status)
846  {
847    unsigned char & st_byte = status_[sequence];
848    st_byte = static_cast<unsigned char>(st_byte & ~7);
849    st_byte = static_cast<unsigned char>(st_byte | status);
850  }
851  /// Start or reset using maximumRows_ and Columns_ - true if change
852  bool startPermanentArrays();
853  /** Normally the first factorization does sparse coding because
854      the factorization could be singular.  This allows initial dense
855      factorization when it is known to be safe
856  */
857  void setInitialDenseFactorization(bool onOff);
858  bool  initialDenseFactorization() const;
859  /** Return sequence In or Out */
860  inline int sequenceIn() const
861  {return sequenceIn_;}
862  inline int sequenceOut() const
863  {return sequenceOut_;}
864  /** Set sequenceIn or Out */
865  inline void  setSequenceIn(int sequence)
866  { sequenceIn_=sequence;}
867  inline void  setSequenceOut(int sequence)
868  { sequenceOut_=sequence;}
869  /** Return direction In or Out */
870  inline int directionIn() const
871  {return directionIn_;}
872  inline int directionOut() const
873  {return directionOut_;}
874  /** Set directionIn or Out */
875  inline void  setDirectionIn(int direction)
876  { directionIn_=direction;}
877  inline void  setDirectionOut(int direction)
878  { directionOut_=direction;}
879  /// Value of Out variable
880  inline double valueOut() const
881  { return valueOut_;}
882  /// Returns 1 if sequence indicates column
883  inline int isColumn(int sequence) const
884  { return sequence<numberColumns_ ? 1 : 0;}
885  /// Returns sequence number within section
886  inline int sequenceWithin(int sequence) const
887  { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;}
888  /// Return row or column values
889  inline double solution(int sequence)
890  { return solution_[sequence];}
891  /// Return address of row or column values
892  inline double & solutionAddress(int sequence)
893  { return solution_[sequence];}
894  inline double reducedCost(int sequence)
895   { return dj_[sequence];}
896  inline double & reducedCostAddress(int sequence)
897   { return dj_[sequence];}
898  inline double lower(int sequence)
899  { return lower_[sequence];}
900  /// Return address of row or column lower bound
901  inline double & lowerAddress(int sequence)
902  { return lower_[sequence];}
903  inline double upper(int sequence)
904  { return upper_[sequence];}
905  /// Return address of row or column upper bound
906  inline double & upperAddress(int sequence)
907  { return upper_[sequence];}
908  inline double cost(int sequence)
909  { return cost_[sequence];}
910  /// Return address of row or column cost
911  inline double & costAddress(int sequence)
912  { return cost_[sequence];}
913  /// Return original lower bound
914  inline double originalLower(int iSequence) const
915  { if (iSequence<numberColumns_) return columnLower_[iSequence]; else
916    return rowLower_[iSequence-numberColumns_];}
917  /// Return original lower bound
918  inline double originalUpper(int iSequence) const
919  { if (iSequence<numberColumns_) return columnUpper_[iSequence]; else
920    return rowUpper_[iSequence-numberColumns_];}
921  /// Theta (pivot change)
922  inline double theta() const
923  { return theta_;}
924  /// Return pointer to details of costs
925  inline ClpNonLinearCost * nonLinearCost() const
926  { return nonLinearCost_;}
927  /** Return more special options
928      1 bit - if presolve says infeasible in ClpSolve return
929      2 bit - if presolved problem infeasible return
930      4 bit - keep arrays like upper_ around
931      8 bit - if factorization kept can still declare optimal at once
932      16 bit - if checking replaceColumn accuracy before updating
933  */
934  inline int moreSpecialOptions() const
935  { return moreSpecialOptions_;}
936  /** Set more special options
937      1 bit - if presolve says infeasible in ClpSolve return
938      2 bit - if presolved problem infeasible return
939      4 bit - keep arrays like upper_ around
940  */
941  inline void setMoreSpecialOptions(int value)
942  { moreSpecialOptions_ = value;}
943  //@}
944  /**@name status methods */
945  //@{
946  inline void setFakeBound(int sequence, FakeBound fakeBound)
947  {
948    unsigned char & st_byte = status_[sequence];
949    st_byte = static_cast<unsigned char>(st_byte & ~24);
950    st_byte = static_cast<unsigned char>(st_byte | (fakeBound<<3));
951  }
952  inline FakeBound getFakeBound(int sequence) const
953  {return static_cast<FakeBound> ((status_[sequence]>>3)&3);}
954  inline void setRowStatus(int sequence, Status status)
955  {
956    unsigned char & st_byte = status_[sequence+numberColumns_];
957    st_byte = static_cast<unsigned char>(st_byte & ~7);
958    st_byte = static_cast<unsigned char>(st_byte | status);
959  }
960  inline Status getRowStatus(int sequence) const
961  {return static_cast<Status> (status_[sequence+numberColumns_]&7);}
962  inline void setColumnStatus(int sequence, Status status)
963  {
964    unsigned char & st_byte = status_[sequence];
965    st_byte = static_cast<unsigned char>(st_byte & ~7);
966    st_byte = static_cast<unsigned char>(st_byte | status);
967  }
968  inline Status getColumnStatus(int sequence) const
969  {return static_cast<Status> (status_[sequence]&7);}
970  inline void setPivoted( int sequence)
971  { status_[sequence] = static_cast<unsigned char>(status_[sequence] | 32);}
972  inline void clearPivoted( int sequence)
973  { status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32);}
974  inline bool pivoted(int sequence) const
975  {return (((status_[sequence]>>5)&1)!=0);}
976  /// To flag a variable (not inline to allow for column generation)
977  void setFlagged( int sequence);
978  inline void clearFlagged( int sequence)
979  {
980    status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64);
981  }
982  inline bool flagged(int sequence) const
983  {return ((status_[sequence]&64)!=0);}
984  /// To say row active in primal pivot row choice
985  inline void setActive( int iRow)
986  {
987    status_[iRow] = static_cast<unsigned char>(status_[iRow] | 128);
988  }
989  inline void clearActive( int iRow)
990  {
991    status_[iRow] = static_cast<unsigned char>(status_[iRow] & ~128);
992  }
993  inline bool active(int iRow) const
994  {return ((status_[iRow]&128)!=0);}
995  /** Set up status array (can be used by OsiClp).
996      Also can be used to set up all slack basis */
997  void createStatus() ;
998  /** Sets up all slack basis and resets solution to
999      as it was after initial load or readMps */
1000  void allSlackBasis(bool resetSolution=false);
1001   
1002  /// So we know when to be cautious
1003  inline int lastBadIteration() const
1004  {return lastBadIteration_;}
1005  /// Progress flag - at present 0 bit says artificials out
1006  inline int progressFlag() const
1007  {return progressFlag_;}
1008  /// Force re-factorization early
1009  inline void forceFactorization(int value)
1010  { forceFactorization_ = value;}
1011  /// Raw objective value (so always minimize in primal)
1012  inline double rawObjectiveValue() const
1013  { return objectiveValue_;}
1014   /// Compute objective value from solution and put in objectiveValue_
1015  void computeObjectiveValue(bool useWorkingSolution=false);
1016  /// Compute minimization objective value from internal solution without perturbation
1017  double computeInternalObjectiveValue();
1018  /** Number of extra rows.  These are ones which will be dynamically created
1019      each iteration.  This is for GUB but may have other uses.
1020  */
1021  inline int numberExtraRows() const
1022  { return numberExtraRows_;}
1023  /** Maximum number of basic variables - can be more than number of rows if GUB
1024  */
1025  inline int maximumBasic() const
1026  { return maximumBasic_;}
1027  /// Iteration when we entered dual or primal
1028  inline int baseIteration() const
1029  { return baseIteration_;}
1030  /// Create C++ lines to get to current state
1031  void generateCpp( FILE * fp,bool defaultFactor=false);
1032  /// Gets clean and emptyish factorization
1033  ClpFactorization * getEmptyFactorization();
1034  /// May delete or may make clean and emptyish factorization
1035  void setEmptyFactorization();
1036  /// Move status and solution across
1037  void moveInfo(const ClpSimplex & rhs, bool justStatus=false);
1038  //@}
1039
1040  ///@name Basis handling
1041  // These are only to be used using startFinishOptions (ClpSimplexDual, ClpSimplexPrimal)
1042  // *** At present only without scaling
1043  // *** Slacks havve -1.0 element (so == row activity) - take care
1044  ///Get a row of the tableau (slack part in slack if not NULL)
1045  void getBInvARow(int row, double* z, double * slack=NULL);
1046 
1047  ///Get a row of the basis inverse
1048  void getBInvRow(int row, double* z);
1049 
1050  ///Get a column of the tableau
1051  void getBInvACol(int col, double* vec);
1052 
1053  ///Get a column of the basis inverse
1054  void getBInvCol(int col, double* vec);
1055 
1056  /** Get basic indices (order of indices corresponds to the
1057      order of elements in a vector retured by getBInvACol() and
1058      getBInvCol()).
1059  */
1060  void getBasics(int* index);
1061 
1062  //@}
1063    //-------------------------------------------------------------------------
1064    /**@name Changing bounds on variables and constraints */
1065    //@{
1066       /** Set an objective function coefficient */
1067       void setObjectiveCoefficient( int elementIndex, double elementValue );
1068       /** Set an objective function coefficient */
1069       inline void setObjCoeff( int elementIndex, double elementValue )
1070       { setObjectiveCoefficient( elementIndex, elementValue);}
1071
1072      /** Set a single column lower bound<br>
1073          Use -DBL_MAX for -infinity. */
1074       void setColumnLower( int elementIndex, double elementValue );
1075     
1076      /** Set a single column upper bound<br>
1077          Use DBL_MAX for infinity. */
1078       void setColumnUpper( int elementIndex, double elementValue );
1079
1080      /** Set a single column lower and upper bound */
1081      void setColumnBounds( int elementIndex,
1082        double lower, double upper );
1083
1084      /** Set the bounds on a number of columns simultaneously<br>
1085          The default implementation just invokes setColLower() and
1086          setColUpper() over and over again.
1087          @param indexFirst,indexLast pointers to the beginning and after the
1088                 end of the array of the indices of the variables whose
1089                 <em>either</em> bound changes
1090          @param boundList the new lower/upper bound pairs for the variables
1091      */
1092      void setColumnSetBounds(const int* indexFirst,
1093                                   const int* indexLast,
1094                                   const double* boundList);
1095     
1096      /** Set a single column lower bound<br>
1097          Use -DBL_MAX for -infinity. */
1098       inline void setColLower( int elementIndex, double elementValue )
1099       { setColumnLower(elementIndex, elementValue);}
1100      /** Set a single column upper bound<br>
1101          Use DBL_MAX for infinity. */
1102       inline void setColUpper( int elementIndex, double elementValue )
1103       { setColumnUpper(elementIndex, elementValue);}
1104
1105      /** Set a single column lower and upper bound */
1106      inline void setColBounds( int elementIndex,
1107        double lower, double upper )
1108       { setColumnBounds(elementIndex, lower, upper);}
1109
1110      /** Set the bounds on a number of columns simultaneously<br>
1111          @param indexFirst,indexLast pointers to the beginning and after the
1112                 end of the array of the indices of the variables whose
1113                 <em>either</em> bound changes
1114          @param boundList the new lower/upper bound pairs for the variables
1115      */
1116      inline void setColSetBounds(const int* indexFirst,
1117                                   const int* indexLast,
1118                                   const double* boundList)
1119      { setColumnSetBounds(indexFirst, indexLast, boundList);}
1120     
1121      /** Set a single row lower bound<br>
1122          Use -DBL_MAX for -infinity. */
1123      void setRowLower( int elementIndex, double elementValue );
1124     
1125      /** Set a single row upper bound<br>
1126          Use DBL_MAX for infinity. */
1127      void setRowUpper( int elementIndex, double elementValue ) ;
1128   
1129      /** Set a single row lower and upper bound */
1130      void setRowBounds( int elementIndex,
1131                                 double lower, double upper ) ;
1132   
1133      /** Set the bounds on a number of rows simultaneously<br>
1134          @param indexFirst,indexLast pointers to the beginning and after the
1135                 end of the array of the indices of the constraints whose
1136                 <em>either</em> bound changes
1137          @param boundList the new lower/upper bound pairs for the constraints
1138      */
1139      void setRowSetBounds(const int* indexFirst,
1140                                   const int* indexLast,
1141                                   const double* boundList);
1142   
1143    //@}
1144
1145////////////////// data //////////////////
1146protected:
1147
1148  /**@name data.  Many arrays have a row part and a column part.
1149   There is a single array with both - columns then rows and
1150   then normally two arrays pointing to rows and columns.  The
1151   single array is the owner of memory
1152  */
1153  //@{
1154  /// Worst column primal infeasibility
1155  double columnPrimalInfeasibility_;
1156  /// Worst row primal infeasibility
1157  double rowPrimalInfeasibility_;
1158  /// Sequence of worst (-1 if feasible)
1159  int columnPrimalSequence_;
1160  /// Sequence of worst (-1 if feasible)
1161  int rowPrimalSequence_;
1162  /// Worst column dual infeasibility
1163  double columnDualInfeasibility_;
1164  /// Worst row dual infeasibility
1165  double rowDualInfeasibility_;
1166  /// More special options - see set for details
1167  int moreSpecialOptions_;
1168  /// Iteration when we entered dual or primal
1169  int baseIteration_;
1170  /// Primal tolerance needed to make dual feasible (<largeTolerance)
1171  double primalToleranceToGetOptimal_;
1172  /// Remaining largest dual infeasibility
1173  double remainingDualInfeasibility_;
1174  /// Large bound value (for complementarity etc)
1175  double largeValue_;
1176  /// Largest error on Ax-b
1177  double largestPrimalError_;
1178  /// Largest error on basic duals
1179  double largestDualError_;
1180  /// For computing whether to re-factorize
1181  double alphaAccuracy_;
1182  /// Dual bound
1183  double dualBound_;
1184  /// Alpha (pivot element)
1185  double alpha_;
1186  /// Theta (pivot change)
1187  double theta_;
1188  /// Lower Bound on In variable
1189  double lowerIn_;
1190  /// Value of In variable
1191  double valueIn_;
1192  /// Upper Bound on In variable
1193  double upperIn_;
1194  /// Reduced cost of In variable
1195  double dualIn_;
1196  /// Lower Bound on Out variable
1197  double lowerOut_;
1198  /// Value of Out variable
1199  double valueOut_;
1200  /// Upper Bound on Out variable
1201  double upperOut_;
1202  /// Infeasibility (dual) or ? (primal) of Out variable
1203  double dualOut_;
1204  /// Current dual tolerance for algorithm
1205  double dualTolerance_;
1206  /// Current primal tolerance for algorithm
1207  double primalTolerance_;
1208  /// Sum of dual infeasibilities
1209  double sumDualInfeasibilities_;
1210  /// Sum of primal infeasibilities
1211  double sumPrimalInfeasibilities_;
1212  /// Weight assigned to being infeasible in primal
1213  double infeasibilityCost_;
1214  /// Sum of Dual infeasibilities using tolerance based on error in duals
1215  double sumOfRelaxedDualInfeasibilities_;
1216  /// Sum of Primal infeasibilities using tolerance based on error in primals
1217  double sumOfRelaxedPrimalInfeasibilities_;
1218  /// Acceptable pivot value just after factorization
1219  double acceptablePivot_;
1220  /// Working copy of lower bounds (Owner of arrays below)
1221  double * lower_;
1222  /// Row lower bounds - working copy
1223  double * rowLowerWork_;
1224  /// Column lower bounds - working copy
1225  double * columnLowerWork_;
1226  /// Working copy of upper bounds (Owner of arrays below)
1227  double * upper_;
1228  /// Row upper bounds - working copy
1229  double * rowUpperWork_;
1230  /// Column upper bounds - working copy
1231  double * columnUpperWork_;
1232  /// Working copy of objective (Owner of arrays below)
1233  double * cost_;
1234  /// Row objective - working copy
1235  double * rowObjectiveWork_;
1236  /// Column objective - working copy
1237  double * objectiveWork_;
1238  /// Useful row length arrays
1239  CoinIndexedVector * rowArray_[6];
1240  /// Useful column length arrays
1241  CoinIndexedVector * columnArray_[6];
1242  /// Sequence of In variable
1243  int sequenceIn_;
1244  /// Direction of In, 1 going up, -1 going down, 0 not a clude
1245  int directionIn_;
1246  /// Sequence of Out variable
1247  int sequenceOut_;
1248  /// Direction of Out, 1 to upper bound, -1 to lower bound, 0 - superbasic
1249  int directionOut_;
1250  /// Pivot Row
1251  int pivotRow_;
1252  /// Last good iteration (immediately after a re-factorization)
1253  int lastGoodIteration_;
1254  /// Working copy of reduced costs (Owner of arrays below)
1255  double * dj_;
1256  /// Reduced costs of slacks not same as duals (or - duals)
1257  double * rowReducedCost_;
1258  /// Possible scaled reduced costs
1259  double * reducedCostWork_;
1260  /// Working copy of primal solution (Owner of arrays below)
1261  double * solution_;
1262  /// Row activities - working copy
1263  double * rowActivityWork_;
1264  /// Column activities - working copy
1265  double * columnActivityWork_;
1266#ifdef CLP_AUXILIARY_MODEL
1267  /// Auxiliary model
1268  ClpSimplex * auxiliaryModel_;
1269#endif
1270  /// Number of dual infeasibilities
1271  int numberDualInfeasibilities_;
1272  /// Number of dual infeasibilities (without free)
1273  int numberDualInfeasibilitiesWithoutFree_;
1274  /// Number of primal infeasibilities
1275  int numberPrimalInfeasibilities_;
1276  /// How many iterative refinements to do
1277  int numberRefinements_;
1278  /// dual row pivot choice
1279  ClpDualRowPivot * dualRowPivot_;
1280  /// primal column pivot choice
1281  ClpPrimalColumnPivot * primalColumnPivot_;
1282  /// Basic variables pivoting on which rows
1283  int * pivotVariable_;
1284  /// factorization
1285  ClpFactorization * factorization_;
1286  /// Saved version of solution
1287  double * savedSolution_;
1288  /// Number of times code has tentatively thought optimal
1289  int numberTimesOptimal_;
1290  /// Disaster handler
1291  ClpDisasterHandler * disasterArea_;
1292  /// If change has been made (first attempt at stopping looping)
1293  int changeMade_;
1294  /// Algorithm >0 == Primal, <0 == Dual
1295  int algorithm_;
1296  /** Now for some reliability aids
1297      This forces re-factorization early */
1298  int forceFactorization_;
1299  /** Perturbation:
1300      -50 to +50 - perturb by this power of ten (-6 sounds good)
1301      100 - auto perturb if takes too long (1.0e-6 largest nonzero)
1302      101 - we are perturbed
1303      102 - don't try perturbing again
1304      default is 100
1305  */
1306  int perturbation_;
1307  /// Saved status regions
1308  unsigned char * saveStatus_;
1309  /** Very wasteful way of dealing with infeasibilities in primal.
1310      However it will allow non-linearities and use of dual
1311      analysis.  If it doesn't work it can easily be replaced.
1312  */
1313  ClpNonLinearCost * nonLinearCost_;
1314  /// So we know when to be cautious
1315  int lastBadIteration_;
1316  /// So we know when to open up again
1317  int lastFlaggedIteration_;
1318  /// Can be used for count of fake bounds (dual) or fake costs (primal)
1319  int numberFake_;
1320  /// Can be used for count of changed costs (dual) or changed bounds (primal)
1321  int numberChanged_;
1322  /// Progress flag - at present 0 bit says artificials out, 1 free in
1323  int progressFlag_;
1324  /// First free/super-basic variable (-1 if none)
1325  int firstFree_;
1326  /** Number of extra rows.  These are ones which will be dynamically created
1327      each iteration.  This is for GUB but may have other uses.
1328  */
1329  int numberExtraRows_;
1330  /** Maximum number of basic variables - can be more than number of rows if GUB
1331  */
1332  int maximumBasic_;
1333  /// If may skip final factorize then allow up to this pivots (default 20)
1334  int dontFactorizePivots_;
1335  /** For advanced use.  When doing iterative solves things can get
1336      nasty so on values pass if incoming solution has largest
1337      infeasibility < incomingInfeasibility throw out variables
1338      from basis until largest infeasibility < allowedInfeasibility.
1339      if allowedInfeasibility>= incomingInfeasibility this is
1340      always possible altough you may end up with an all slack basis.
1341
1342      Defaults are 1.0,10.0
1343  */
1344  double incomingInfeasibility_;
1345  double allowedInfeasibility_;
1346  /// Automatic scaling of objective and rhs and bounds
1347  int automaticScale_;
1348  /// A copy of model with certain state - normally without cuts
1349  ClpSimplex * baseModel_;
1350  /// For dealing with all issues of cycling etc
1351  ClpSimplexProgress progress_;
1352public:
1353  /// Spare int array for passing information [0]!=0 switches on
1354  mutable int spareIntArray_[4];
1355  /// Spare double array for passing information [0]!=0 switches on
1356  mutable double spareDoubleArray_[4];
1357protected:
1358  /// Allow OsiClp certain perks
1359  friend class OsiClpSolverInterface;
1360  //@}
1361};
1362//#############################################################################
1363/** A function that tests the methods in the ClpSimplex class. The
1364    only reason for it not to be a member method is that this way it doesn't
1365    have to be compiled into the library. And that's a gain, because the
1366    library should be compiled with optimization on, but this method should be
1367    compiled with debugging.
1368
1369    It also does some testing of ClpFactorization class
1370 */
1371void
1372ClpSimplexUnitTest(const std::string & mpsDir);
1373
1374// For Devex stuff
1375#define DEVEX_TRY_NORM 1.0e-4
1376#define DEVEX_ADD_ONE 1.0
1377#endif
Note: See TracBrowser for help on using the repository browser.