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

Last change on this file since 1321 was 1321, checked in by forrest, 12 years ago

out compiler warnings and stability improvements

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