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

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

needed for ClpNode?

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