source: branches/devel-1/include/ClpSimplex.hpp @ 33

Last change on this file since 33 was 33, checked in by forrest, 17 years ago

Presolve in as option

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.8 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4/*
5   Authors
6   
7   John Forrest
8
9 */
10#ifndef ClpSimplex_H
11#define ClpSimplex_H
12
13#include <iostream>
14#include <cfloat>
15#include "ClpModel.hpp"
16#include "ClpMatrixBase.hpp"
17class ClpDualRowPivot;
18class ClpPrimalColumnPivot;
19class ClpFactorization;
20class CoinIndexedVector;
21class ClpNonLinearCost;
22
23/** This solves LPs using the simplex method
24
25    It inherits from ClpModel and all its arrays are created at
26    algorithm time. Originally I tried to work with model arrays
27    but for simplicity of coding I changed to single arrays with
28    structural variables then row variables.  Some coding is still
29    based on old style and needs cleaning up.
30
31    For a description of algorithms:
32
33    for dual see ClpSimplexDual.hpp and at top of ClpSimplexDual.cpp
34    for primal see ClpSimplexPrimal.hpp and at top of ClpSimplexPrimal.cpp
35
36    There is an algorithm data member.  + for primal variations
37    and - for dual variations
38
39    This file also includes (at end) a very simple class ClpSimplexProgress
40    which is where anti-looping stuff should migrate to
41
42*/
43
44class ClpSimplex : public ClpModel {
45   friend void ClpSimplexUnitTest(const std::string & mpsDir,
46                                  const std::string & netlibDir);
47
48public:
49
50  /// enums for status of various sorts (matches CoinWarmStartBasis)
51  enum Status {
52    isFree = 0x00,
53    basic = 0x01,
54    atUpperBound = 0x02,
55    atLowerBound = 0x03,
56    superBasic = 0x04
57  };
58
59  enum FakeBound {
60    noFake = 0x00,
61    bothFake = 0x01,
62    upperFake = 0x02,
63    lowerFake = 0x03
64  };
65
66  /**@name Constructors and destructor and copy */
67  //@{
68  /// Default constructor
69    ClpSimplex (  );
70
71  /// Copy constructor.
72  ClpSimplex(const ClpSimplex &);
73  /// Copy constructor from model.
74  ClpSimplex(const ClpModel &);
75  /// Assignment operator. This copies the data
76    ClpSimplex & operator=(const ClpSimplex & rhs);
77  /// Destructor
78   ~ClpSimplex (  );
79  // Ones below are just ClpModel with setti
80  /** Loads a problem (the constraints on the
81        rows are given by lower and upper bounds). If a pointer is 0 then the
82        following values are the default:
83        <ul>
84          <li> <code>colub</code>: all columns have upper bound infinity
85          <li> <code>collb</code>: all columns have lower bound 0
86          <li> <code>rowub</code>: all rows have upper bound infinity
87          <li> <code>rowlb</code>: all rows have lower bound -infinity
88          <li> <code>obj</code>: all variables have 0 objective coefficient
89        </ul>
90    */
91  void loadProblem (  const ClpMatrixBase& matrix,
92                     const double* collb, const double* colub,   
93                     const double* obj,
94                     const double* rowlb, const double* rowub,
95                      const double * rowObjective=NULL);
96  void loadProblem (  const CoinPackedMatrix& matrix,
97                     const double* collb, const double* colub,   
98                     const double* obj,
99                     const double* rowlb, const double* rowub,
100                      const double * rowObjective=NULL);
101
102  /** Just like the other loadProblem() method except that the matrix is
103        given in a standard column major ordered format (without gaps). */
104  void loadProblem (  const int numcols, const int numrows,
105                     const int* start, const int* index,
106                     const double* value,
107                     const double* collb, const double* colub,   
108                     const double* obj,
109                      const double* rowlb, const double* rowub,
110                      const double * rowObjective=NULL);
111  /// This one is for after presolve to save memory
112  void loadProblem (  const int numcols, const int numrows,
113                     const int* start, const int* index,
114                      const double* value,const int * length,
115                     const double* collb, const double* colub,   
116                     const double* obj,
117                      const double* rowlb, const double* rowub,
118                      const double * rowObjective=NULL);
119  /// Read an mps file from the given filename
120  int readMps(const char *filename,
121              bool keepNames=false,
122              bool ignoreErrors = false);
123  /** Borrow model.  This is so we dont have to copy large amounts
124      of data around.  It assumes a derived class wants to overwrite
125      an empty model with a real one - while it does an algorithm.
126      This is same as ClpModel one, but sets scaling on etc. */
127  void borrowModel(ClpModel & otherModel);
128  //@}
129
130  /**@name Functions most useful to user */
131  //@{
132  /** Dual algorithm - see ClpSimplexDual.hpp for method */
133  int dual();
134  /** Primal algorithm - see ClpSimplexPrimal.hpp for method */
135  int primal(int ifValuesPass=0);
136  /// Passes in factorization
137  void setFactorization( ClpFactorization & factorization);
138  /// Sets or unsets scaling, 0 -off, 1 on, 2 dynamic(later)
139  void scaling(int mode=1);
140  /// Gets scalingFlag
141  inline int scalingFlag() const {return scalingFlag_;};
142  /** Tightens primal bounds to make dual faster.  Unless
143      fixed, bounds are slightly looser than they could be.
144      This is to make dual go faster and is probably not needed
145      with a presolve.  Returns non-zero if problem infeasible
146  */
147  int tightenPrimalBounds();
148  /// Sets row pivot choice algorithm in dual
149  void setDualRowPivotAlgorithm(ClpDualRowPivot & choice);
150  /// Sets column pivot choice algorithm in primal
151  void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot & choice);
152  /** For strong branching.  On input lower and upper are new bounds
153      while on output they are change in objective function values
154      (>1.0e50 infeasible).
155      Return code is 0 if nothing interesting, -1 if infeasible both
156      ways and +1 if infeasible one way (check values to see which one(s))
157  */
158  int strongBranching(int numberVariables,const int * variables,
159                      double * newLower, double * newUpper,
160                      bool stopOnFirstInfeasible=true,
161                      bool alwaysFinish=false);
162  //@}
163
164  /**@name most useful gets and sets */
165  //@{
166  /// If problem is primal feasible
167  inline bool primalFeasible() const
168         { return (numberPrimalInfeasibilities_==0);};
169  /// If problem is dual feasible
170  inline bool dualFeasible() const
171         { return (numberDualInfeasibilities_==0);};
172  /// factorization
173  inline ClpFactorization * factorization() const 
174          { return factorization_;};
175  /// Sparsity on or off
176  bool sparseFactorization() const;
177  void setSparseFactorization(bool value);
178  /// Dual bound
179  inline double dualBound() const
180          { return dualBound_;};
181  void setDualBound(double value);
182  /// Infeasibility cost
183  inline double infeasibilityCost() const
184          { return infeasibilityCost_;};
185  void setInfeasibilityCost(double value);
186  /** Amount of print out:
187      0 - none
188      1 - just final
189      2 - just factorizations
190      3 - as 2 plus a bit more
191      4 - verbose
192      above that 8,16,32 etc just for selective debug
193  */
194  /** Perturbation:
195      -50 to +50 - perturb by this power of ten (-6 sounds good)
196      100 - auto perturb if takes too long (1.0e-6 largest nonzero)
197      101 - we are perturbed
198      102 - don't try perturbing again
199      default is 100
200  */
201  inline int perturbation() const
202    { return perturbation_;};
203  void setPerturbation(int value);
204  /// Current (or last) algorithm
205  inline int algorithm() const 
206  {return algorithm_; } ;
207  /// Sum of dual infeasibilities
208  inline double sumDualInfeasibilities() const 
209          { return sumDualInfeasibilities_;} ;
210  /// Number of dual infeasibilities
211  inline int numberDualInfeasibilities() const 
212          { return numberDualInfeasibilities_;} ;
213  /// Sum of primal infeasibilities
214  inline double sumPrimalInfeasibilities() const 
215          { return sumPrimalInfeasibilities_;} ;
216  /// Number of primal infeasibilities
217  inline int numberPrimalInfeasibilities() const 
218          { return numberPrimalInfeasibilities_;} ;
219  /** Save model to file, returns 0 if success.  This is designed for
220      use outside algorithms so does not save iterating arrays etc.
221  It does not save any messaging information.
222  Does not save scaling values.
223  It does not know about all types of virtual functions.
224  */
225  int saveModel(const char * fileName);
226  /** Restore model from file, returns 0 if success,
227      deletes current model */
228  int restoreModel(const char * fileName);
229 
230  /** Just check solution (for external use) - sets sum of
231      infeasibilities etc */
232  void checkSolution();
233  //@}
234
235  /******************** End of most useful part **************/
236  /**@name Functions less likely to be useful to casual user */
237  //@{
238  /** Given an existing factorization computes and checks
239      primal and dual solutions.  Uses input arrays for variables at
240      bounds.  Returns feasibility states */
241  int getSolution (  const double * rowActivities,
242                     const double * columnActivities);
243  /** Given an existing factorization computes and checks
244      primal and dual solutions.  Uses current problem arrays for
245      bounds.  Returns feasibility states */
246  int getSolution ();
247  /** Factorizes using current basis. 
248      solveType - 1 iterating, 0 initial, -1 external
249      If 10 added then in primal values pass
250      Return codes are as from ClpFactorization unless initial factorization
251      when total number of singularities is returned
252  */
253  int internalFactorize(int solveType);
254  /// Factorizes using current basis. For external use
255  int factorize();
256  /// Computes duals from scratch
257  void computeDuals();
258  /// Computes primals from scratch
259  void computePrimals (  const double * rowActivities,
260                     const double * columnActivities);
261  /**
262     Unpacks one column of the matrix into indexed array
263     Uses sequenceIn_
264     Also applies scaling if needed
265  */
266  void unpack(CoinIndexedVector * rowArray);
267  /**
268     Unpacks one column of the matrix into indexed array
269     Slack if sequence>= numberColumns
270     Also applies scaling if needed
271  */
272  void unpack(CoinIndexedVector * rowArray,int sequence);
273 
274  /**
275      This does basis housekeeping and does values for in/out variables.
276      Can also decide to re-factorize
277  */
278  int housekeeping(double objectiveChange);
279  /** This sets largest infeasibility and most infeasible and sum
280      and number of infeasibilities (Primal) */
281  void checkPrimalSolution(const double * rowActivities=NULL,
282                           const double * columnActivies=NULL);
283  /** This sets largest infeasibility and most infeasible and sum
284      and number of infeasibilities (Dual) */
285  void checkDualSolution();
286  //@}
287  /**@name Matrix times vector methods
288     They can be faster if scalar is +- 1
289     These are covers so user need not worry about scaling
290     Also for simplex I am not using basic/non-basic split */
291  //@{
292    /** Return <code>y + A * x * scalar</code> in <code>y</code>.
293        @precond <code>x<code> must be of size <code>numColumns()</code>
294        @precond <code>y<code> must be of size <code>numRows()</code> */
295   void times(double scalar,
296                       const double * x, double * y) const;
297    /** Return <code>y + x * scalar * A</code> in <code>y</code>.
298        @precond <code>x<code> must be of size <code>numRows()</code>
299        @precond <code>y<code> must be of size <code>numColumns()</code> */
300    void transposeTimes(double scalar,
301                                const double * x, double * y) const ;
302  //@}
303
304  /**@name most useful gets and sets */
305  //@{
306  /// Worst column primal infeasibility
307  inline double columnPrimalInfeasibility() const 
308          { return columnPrimalInfeasibility_;} ;
309  /// Sequence of worst (-1 if feasible)
310  inline int columnPrimalSequence() const 
311          { return columnPrimalSequence_;} ;
312  /// Worst row primal infeasibility
313  inline double rowPrimalInfeasibility() const 
314          { return rowPrimalInfeasibility_;} ;
315  /// Sequence of worst (-1 if feasible)
316  inline int rowPrimalSequence() const 
317          { return rowPrimalSequence_;} ;
318  /** Worst column dual infeasibility (note - these may not be as meaningful
319      if the problem is primal infeasible */
320  inline double columnDualInfeasibility() const 
321          { return columnDualInfeasibility_;} ;
322  /// Sequence of worst (-1 if feasible)
323  inline int columnDualSequence() const 
324          { return columnDualSequence_;} ;
325  /// Worst row dual infeasibility
326  inline double rowDualInfeasibility() const 
327          { return rowDualInfeasibility_;} ;
328  /// Sequence of worst (-1 if feasible)
329  inline int rowDualSequence() const 
330          { return rowDualSequence_;} ;
331  /// Primal tolerance needed to make dual feasible (<largeTolerance)
332  inline double primalToleranceToGetOptimal() const 
333          { return primalToleranceToGetOptimal_;} ;
334  /// Remaining largest dual infeasibility
335  inline double remainingDualInfeasibility() const 
336          { return remainingDualInfeasibility_;} ;
337  /// Large bound value (for complementarity etc)
338  inline double largeValue() const 
339          { return largeValue_;} ;
340  void setLargeValue( double value) ;
341  /// Largest error on Ax-b
342  inline double largestPrimalError() const
343          { return largestPrimalError_;} ;
344  /// Largest error on basic duals
345  inline double largestDualError() const
346          { return largestDualError_;} ;
347  /// Largest difference between input primal solution and computed
348  inline double largestSolutionError() const
349          { return largestSolutionError_;} ;
350  /// Basic variables pivoting on which rows
351  inline const int * pivotVariable() const
352          { return pivotVariable_;};
353  /// Current dual tolerance
354  inline double currentDualTolerance() const 
355          { return dualTolerance_;} ;
356  inline void setCurrentDualTolerance(double value)
357          { dualTolerance_ = value;} ;
358  /// Current primal tolerance
359  inline double currentPrimalTolerance() const 
360          { return primalTolerance_;} ;
361  inline void setCurrentPrimalTolerance(double value)
362          { primalTolerance_ = value;} ;
363  /// How many iterative refinements to do
364  inline int numberRefinements() const 
365          { return numberRefinements_;} ;
366  void setnumberRefinements( int value) ;
367  /// Alpha (pivot element) for use by classes e.g. steepestedge
368  inline double alpha() const { return alpha_;};
369  /// Reduced cost of last incoming for use by classes e.g. steepestedge
370  inline double dualIn() const { return dualIn_;};
371  /// Pivot Row for use by classes e.g. steepestedge
372  inline int pivotRow() const{ return pivotRow_;};
373  /// value of incoming variable (in Dual)
374  double valueIncomingDual() const;
375  //@}
376
377  protected:
378  /**@name protected methods */
379  //@{
380  /// May change basis and then returns number changed
381  int gutsOfSolution ( const double * rowActivities,
382                       const double * columnActivities,
383                       bool valuesPass=false);
384  /// Does most of deletion (0 = all, 1 = most, 2 most + factorization)
385  void gutsOfDelete(int type);
386  /// Does most of copying
387  void gutsOfCopy(const ClpSimplex & rhs);
388  /** puts in format I like (rowLower,rowUpper) also see StandardMatrix
389      1 bit does rows, 2 bit does column bounds, 4 bit does objective(s).
390      8 bit does solution scaling in
391      16 bit does rowArray and columnArray indexed vectors
392      and makes row copy if wanted, also sets columnStart_ etc
393      Also creates scaling arrays if needed.  It does scaling if needed.
394      16 also moves solutions etc in to work arrays
395      On 16 returns false if problem "bad" i.e. matrix or bounds bad
396  */
397  bool createRim(int what,bool makeRowCopy=false);
398  /** releases above arrays and does solution scaling out.  May also
399      get rid of factorization data */
400  void deleteRim(bool getRidOfFactorizationData=true);
401  /// Sanity check on input rim data (after scaling) - returns true if okay
402  bool sanityCheck();
403  //@}
404  public:
405  /**@name public methods */
406  //@{
407  /** Return row or column sections - not as much needed as it
408      once was.  These just map into single arrays */
409  inline double * solutionRegion(int section)
410  { if (!section) return rowActivityWork_; else return columnActivityWork_;};
411  inline double * djRegion(int section)
412  { if (!section) return rowReducedCost_; else return reducedCostWork_;};
413  inline double * lowerRegion(int section)
414  { if (!section) return rowLowerWork_; else return columnLowerWork_;};
415  inline double * upperRegion(int section)
416  { if (!section) return rowUpperWork_; else return columnUpperWork_;};
417  inline double * costRegion(int section)
418  { if (!section) return rowObjectiveWork_; else return objectiveWork_;};
419  /// Return region as single array
420  inline double * solutionRegion()
421  { return solution_;};
422  inline double * djRegion()
423  { return dj_;};
424  inline double * lowerRegion()
425  { return lower_;};
426  inline double * upperRegion()
427  { return upper_;};
428  inline double * costRegion()
429  { return cost_;};
430  inline Status getStatus(int sequence) const
431  {return static_cast<Status> (status_[sequence]&7);};
432  inline void setStatus(int sequence, Status status)
433  {
434    unsigned char & st_byte = status_[sequence];
435    st_byte &= ~7;
436    st_byte |= status;
437  };
438  /** Return sequence In or Out */
439  inline int sequenceIn() const
440  {return sequenceIn_;};
441  inline int sequenceOut() const
442  {return sequenceOut_;};
443  /** Set sequenceIn or Out */
444  inline void  setSequenceIn(int sequence)
445  { sequenceIn_=sequence;};
446  inline void  setSequenceOut(int sequence)
447  { sequenceOut_=sequence;};
448  /// Returns 1 if sequence indicates column
449  inline int isColumn(int sequence) const
450  { return sequence<numberColumns_ ? 1 : 0;};
451  /// Returns sequence number within section
452  inline int sequenceWithin(int sequence) const
453  { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;};
454  /// Return row or column values
455  inline double solution(int sequence)
456  { return solution_[sequence];};
457  /// Return address of row or column values
458  inline double & solutionAddress(int sequence)
459  { return solution_[sequence];};
460  inline double reducedCost(int sequence)
461   { return dj_[sequence];};
462  inline double & reducedCostAddress(int sequence)
463   { return dj_[sequence];};
464  inline double lower(int sequence)
465  { return lower_[sequence];};
466  /// Return address of row or column lower bound
467  inline double & lowerAddress(int sequence)
468  { return lower_[sequence];};
469  inline double upper(int sequence)
470  { return upper_[sequence];};
471  /// Return address of row or column upper bound
472  inline double & upperAddress(int sequence)
473  { return upper_[sequence];};
474  inline double cost(int sequence)
475  { return cost_[sequence];};
476  /// Return address of row or column cost
477  inline double & costAddress(int sequence)
478  { return cost_[sequence];};
479  /// Scaling
480  const double * rowScale() const {return rowScale_;};
481  const double * columnScale() const {return columnScale_;};
482  void setRowScale(double * scale) { rowScale_ = scale;};
483  void setColumnScale(double * scale) { columnScale_ = scale;};
484  //@}
485  /**@name status methods */
486  //@{
487  inline void setFakeBound(int sequence, FakeBound fakeBound)
488  {
489    unsigned char & st_byte = status_[sequence];
490    st_byte &= ~24;
491    st_byte |= fakeBound<<3;
492  };
493  inline FakeBound getFakeBound(int sequence) const
494  {return static_cast<FakeBound> ((status_[sequence]>>3)&3);};
495  inline void setRowStatus(int sequence, Status status)
496  {
497    unsigned char & st_byte = status_[sequence+numberColumns_];
498    st_byte &= ~7;
499    st_byte |= status;
500  };
501  inline Status getRowStatus(int sequence) const
502  {return static_cast<Status> (status_[sequence+numberColumns_]&7);};
503  inline void setColumnStatus(int sequence, Status status)
504  {
505    unsigned char & st_byte = status_[sequence];
506    st_byte &= ~7;
507    st_byte |= status;
508  };
509  inline Status getColumnStatus(int sequence) const
510  {return static_cast<Status> (status_[sequence]&7);};
511  inline void setFixed( int sequence)
512  { status_[sequence] |= 32;};
513  inline void clearFixed( int sequence)
514  { status_[sequence] &= ~32; };
515  inline bool fixed(int sequence) const
516  {return (((status_[sequence]>>5)&1)!=0);};
517  inline void setFlagged( int sequence)
518  {
519    status_[sequence] |= 64;
520  };
521  inline void clearFlagged( int sequence)
522  {
523    status_[sequence] &= ~64;
524  };
525  inline bool flagged(int sequence) const
526  {return (((status_[sequence]>>6)&1)!=0);};
527  /** Set up status array (can be used by OsiClp).
528      Also can be used to set up all slack basis */
529  void createStatus() ;
530   
531  /// So we know when to be cautious
532  inline int lastBadIteration() const
533  {return lastBadIteration_;};
534  /// Progress flag - at present 0 bit says artificials out
535  inline int progressFlag() const
536  {return progressFlag_;};
537  //@}
538
539////////////////// data //////////////////
540protected:
541
542  /**@name data.  Many arrays have a row part and a column part.
543   There is a single array with both - columns then rows and
544   then normally two arrays pointing to rows and columns.  The
545   single array is the owner of memory
546  */
547  //@{
548  /// Worst column primal infeasibility
549  double columnPrimalInfeasibility_;
550  /// Sequence of worst (-1 if feasible)
551  int columnPrimalSequence_;
552  /// Worst row primal infeasibility
553  double rowPrimalInfeasibility_;
554  /// Sequence of worst (-1 if feasible)
555  int rowPrimalSequence_;
556  /// Worst column dual infeasibility
557  double columnDualInfeasibility_;
558  /// Sequence of worst (-1 if feasible)
559  int columnDualSequence_;
560  /// Worst row dual infeasibility
561  double rowDualInfeasibility_;
562  /// Sequence of worst (-1 if feasible)
563  int rowDualSequence_;
564  /// Primal tolerance needed to make dual feasible (<largeTolerance)
565  double primalToleranceToGetOptimal_;
566  /// Remaining largest dual infeasibility
567  double remainingDualInfeasibility_;
568  /// Large bound value (for complementarity etc)
569  double largeValue_;
570  /// Largest error on Ax-b
571  double largestPrimalError_;
572  /// Largest error on basic duals
573  double largestDualError_;
574  /// Largest difference between input primal solution and computed
575  double largestSolutionError_;
576  /// Dual bound
577  double dualBound_;
578  /// Working copy of lower bounds (Owner of arrays below)
579  double * lower_;
580  /// Row lower bounds - working copy
581  double * rowLowerWork_;
582  /// Column lower bounds - working copy
583  double * columnLowerWork_;
584  /// Working copy of upper bounds (Owner of arrays below)
585  double * upper_;
586  /// Row upper bounds - working copy
587  double * rowUpperWork_;
588  /// Column upper bounds - working copy
589  double * columnUpperWork_;
590  /// Working copy of objective (Owner of arrays below)
591  double * cost_;
592  /// Row objective - working copy
593  double * rowObjectiveWork_;
594  /// Column objective - working copy
595  double * objectiveWork_;
596  /// Useful row length arrays
597  CoinIndexedVector * rowArray_[6];
598  /// Useful column length arrays
599  CoinIndexedVector * columnArray_[6];
600  /// Alpha (pivot element)
601  double alpha_;
602  /// Theta (pivot change)
603  double theta_;
604  /// Lower Bound on In variable
605  double lowerIn_;
606  /// Value of In variable
607  double valueIn_;
608  /// Upper Bound on In variable
609  double upperIn_;
610  /// Reduced cost of In variable
611  double dualIn_;
612  /// Sequence of In variable
613  int sequenceIn_;
614  /// Direction of In, 1 going up, -1 going down, 0 not a clude
615  int directionIn_;
616  /// Lower Bound on Out variable
617  double lowerOut_;
618  /// Value of Out variable
619  double valueOut_;
620  /// Upper Bound on Out variable
621  double upperOut_;
622  /// Infeasibility (dual) or ? (primal) of Out variable
623  double dualOut_;
624  /// Sequence of Out variable
625  int sequenceOut_;
626  /// Direction of Out, 1 to upper bound, -1 to lower bound, 0 - superbasic
627  int directionOut_;
628  /// Pivot Row
629  int pivotRow_;
630  /// Working copy of reduced costs (Owner of arrays below)
631  double * dj_;
632  /// Reduced costs of slacks not same as duals (or - duals)
633  double * rowReducedCost_;
634  /// Possible scaled reduced costs
635  double * reducedCostWork_;
636  /// Working copy of primal solution (Owner of arrays below)
637  double * solution_;
638  /// Row activities - working copy
639  double * rowActivityWork_;
640  /// Column activities - working copy
641  double * columnActivityWork_;
642  /// Current dual tolerance for algorithm
643  double dualTolerance_;
644  /// Current primal tolerance for algorithm
645  double primalTolerance_;
646  /// Sum of dual infeasibilities
647  double sumDualInfeasibilities_;
648  /// Number of dual infeasibilities
649  int numberDualInfeasibilities_;
650  /// Number of dual infeasibilities (without free)
651  int numberDualInfeasibilitiesWithoutFree_;
652  /// Sum of primal infeasibilities
653  double sumPrimalInfeasibilities_;
654  /// Number of primal infeasibilities
655  int numberPrimalInfeasibilities_;
656  /// dual row pivot choice
657  ClpDualRowPivot * dualRowPivot_;
658  /// primal column pivot choice
659  ClpPrimalColumnPivot * primalColumnPivot_;
660  /// Basic variables pivoting on which rows
661  int * pivotVariable_;
662  /// factorization
663  ClpFactorization * factorization_;
664  /// How many iterative refinements to do
665  int numberRefinements_;
666  /// Row scale factors for matrix
667  // ****** get working simply then make coding more efficient
668  // on full matrix operations
669  double * rowScale_;
670  /// Saved version of solution
671  double * savedSolution_;
672  /// Column scale factors
673  double * columnScale_;
674  /// Scale flag, 0 none, 1 normal, 2 dynamic
675  int scalingFlag_;
676  /// Number of times code has tentatively thought optimal
677  int numberTimesOptimal_;
678  /// If change has been made (first attempt at stopping looping)
679  int changeMade_;
680  /// Algorithm >0 == Primal, <0 == Dual
681  int algorithm_;
682  /** Now for some reliability aids
683      This forces re-factorization early */
684  int forceFactorization_;
685  /// Saved status regions
686  unsigned char * saveStatus_;
687  /** Perturbation:
688      -50 to +50 - perturb by this power of ten (-6 sounds good)
689      100 - auto perturb if takes too long (1.0e-6 largest nonzero)
690      101 - we are perturbed
691      102 - don't try perturbing again
692      default is 100
693  */
694  int perturbation_;
695  /// Weight assigned to being infeasible in primal
696  double infeasibilityCost_;
697  /** Very wasteful way of dealing with infeasibilities in primal.
698      However it will allow non-linearities and use of dual
699      analysis.  If it doesn't work it can easily be replaced.
700  */
701  ClpNonLinearCost * nonLinearCost_;
702  /// For advanced options
703  unsigned int specialOptions_;
704  /// So we know when to be cautious
705  int lastBadIteration_;
706  /// Can be used for count of fake bounds (dual) or fake costs (primal)
707  int numberFake_;
708  /// Progress flag - at present 0 bit says artificials out
709  int progressFlag_;
710  /// Sum of Dual infeasibilities using tolerance based on error in duals
711  double sumOfRelaxedDualInfeasibilities_;
712  /// Sum of Primal infeasibilities using tolerance based on error in primals
713  double sumOfRelaxedPrimalInfeasibilities_;
714  //@}
715};
716//#############################################################################
717/** A function that tests the methods in the ClpSimplex class. The
718    only reason for it not to be a member method is that this way it doesn't
719    have to be compiled into the library. And that's a gain, because the
720    library should be compiled with optimization on, but this method should be
721    compiled with debugging.
722
723    It also does some testing of ClpFactorization class
724 */
725void
726ClpSimplexUnitTest(const std::string & mpsDir,
727                   const std::string & netlibDir);
728
729
730/// For saving extra information to see if looping. not worth a Class
731class ClpSimplexProgress {
732
733public:
734
735
736  /**@name Constructors and destructor and copy */
737  //@{
738  /// Default constructor
739    ClpSimplexProgress (  );
740
741  /// Constructor from model
742    ClpSimplexProgress ( ClpSimplex * model );
743
744  /// Copy constructor.
745  ClpSimplexProgress(const ClpSimplexProgress &);
746
747  /// Assignment operator. This copies the data
748    ClpSimplexProgress & operator=(const ClpSimplexProgress & rhs);
749  /// Destructor
750   ~ClpSimplexProgress (  );
751  //@}
752
753  /**@name Check progress */
754  //@{
755  /** Returns -1 if okay, -n+1 (n number of times bad) if bad but action taken,
756      >=0 if give up and use as problem status
757  */
758    int looping (  );
759
760  //@}
761  /**@name Data  */
762#define CLP_PROGRESS 4
763  //@{
764  /// Objective values
765  double objective_[CLP_PROGRESS];
766  /// Sum of infeasibilities for algorithm
767  double infeasibility_[CLP_PROGRESS];
768  /// Number of infeasibilities
769  int numberInfeasibilities_[CLP_PROGRESS];
770  /// Number of times checked (so won't stop too early)
771  int numberTimes_;
772  /// Number of times it looked like loop
773  int numberBadTimes_;
774  /// Pointer back to model so we can get information
775  ClpSimplex * model_;
776  //@}
777};
778#endif
Note: See TracBrowser for help on using the repository browser.