source: branches/BSP/trunk/Clp/src/ClpSimplex.hpp @ 1073

Last change on this file since 1073 was 1073, checked in by ladanyi, 12 years ago

Got rid of dependency on Data/Netlib?

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