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

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

For presolve

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.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"
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  /// See if status array exists (partly for OsiClp)
528  inline bool statusExists() const
529  { return (status_!=NULL);};
530  /// Return address of status array (char[numberRows+numberColumns])
531  inline unsigned char *  statusArray() 
532  { return status_;};
533  /** Set up status array (can be used by OsiClp).
534      Also can be used to set up all slack basis */
535  void createStatus() ;
536   
537  /// So we know when to be cautious
538  inline int lastBadIteration() const
539  {return lastBadIteration_;};
540  /// Progress flag - at present 0 bit says artificials out
541  inline int progressFlag() const
542  {return progressFlag_;};
543  //@}
544
545////////////////// data //////////////////
546protected:
547
548  /**@name data.  Many arrays have a row part and a column part.
549   There is a single array with both - columns then rows and
550   then normally two arrays pointing to rows and columns.  The
551   single array is the owner of memory
552  */
553  //@{
554  /// Worst column primal infeasibility
555  double columnPrimalInfeasibility_;
556  /// Sequence of worst (-1 if feasible)
557  int columnPrimalSequence_;
558  /// Worst row primal infeasibility
559  double rowPrimalInfeasibility_;
560  /// Sequence of worst (-1 if feasible)
561  int rowPrimalSequence_;
562  /// Worst column dual infeasibility
563  double columnDualInfeasibility_;
564  /// Sequence of worst (-1 if feasible)
565  int columnDualSequence_;
566  /// Worst row dual infeasibility
567  double rowDualInfeasibility_;
568  /// Sequence of worst (-1 if feasible)
569  int rowDualSequence_;
570  /// Primal tolerance needed to make dual feasible (<largeTolerance)
571  double primalToleranceToGetOptimal_;
572  /// Remaining largest dual infeasibility
573  double remainingDualInfeasibility_;
574  /// Large bound value (for complementarity etc)
575  double largeValue_;
576  /// Largest error on Ax-b
577  double largestPrimalError_;
578  /// Largest error on basic duals
579  double largestDualError_;
580  /// Largest difference between input primal solution and computed
581  double largestSolutionError_;
582  /// Dual bound
583  double dualBound_;
584  /// Working copy of lower bounds (Owner of arrays below)
585  double * lower_;
586  /// Row lower bounds - working copy
587  double * rowLowerWork_;
588  /// Column lower bounds - working copy
589  double * columnLowerWork_;
590  /// Working copy of upper bounds (Owner of arrays below)
591  double * upper_;
592  /// Row upper bounds - working copy
593  double * rowUpperWork_;
594  /// Column upper bounds - working copy
595  double * columnUpperWork_;
596  /// Working copy of objective (Owner of arrays below)
597  double * cost_;
598  /// Row objective - working copy
599  double * rowObjectiveWork_;
600  /// Column objective - working copy
601  double * objectiveWork_;
602  /// Useful row length arrays
603  CoinIndexedVector * rowArray_[6];
604  /// Useful column length arrays
605  CoinIndexedVector * columnArray_[6];
606  /// Alpha (pivot element)
607  double alpha_;
608  /// Theta (pivot change)
609  double theta_;
610  /// Lower Bound on In variable
611  double lowerIn_;
612  /// Value of In variable
613  double valueIn_;
614  /// Upper Bound on In variable
615  double upperIn_;
616  /// Reduced cost of In variable
617  double dualIn_;
618  /// Sequence of In variable
619  int sequenceIn_;
620  /// Direction of In, 1 going up, -1 going down, 0 not a clude
621  int directionIn_;
622  /// Lower Bound on Out variable
623  double lowerOut_;
624  /// Value of Out variable
625  double valueOut_;
626  /// Upper Bound on Out variable
627  double upperOut_;
628  /// Infeasibility (dual) or ? (primal) of Out variable
629  double dualOut_;
630  /// Sequence of Out variable
631  int sequenceOut_;
632  /// Direction of Out, 1 to upper bound, -1 to lower bound, 0 - superbasic
633  int directionOut_;
634  /// Pivot Row
635  int pivotRow_;
636  /// Status Region (Owner of array below)
637  unsigned char * status_;
638  /// Working copy of reduced costs (Owner of arrays below)
639  double * dj_;
640  /// Reduced costs of slacks not same as duals (or - duals)
641  double * rowReducedCost_;
642  /// Possible scaled reduced costs
643  double * reducedCostWork_;
644  /// Working copy of primal solution (Owner of arrays below)
645  double * solution_;
646  /// Row activities - working copy
647  double * rowActivityWork_;
648  /// Column activities - working copy
649  double * columnActivityWork_;
650  /// Current dual tolerance for algorithm
651  double dualTolerance_;
652  /// Current primal tolerance for algorithm
653  double primalTolerance_;
654  /// Sum of dual infeasibilities
655  double sumDualInfeasibilities_;
656  /// Number of dual infeasibilities
657  int numberDualInfeasibilities_;
658  /// Number of dual infeasibilities (without free)
659  int numberDualInfeasibilitiesWithoutFree_;
660  /// Sum of primal infeasibilities
661  double sumPrimalInfeasibilities_;
662  /// Number of primal infeasibilities
663  int numberPrimalInfeasibilities_;
664  /// dual row pivot choice
665  ClpDualRowPivot * dualRowPivot_;
666  /// primal column pivot choice
667  ClpPrimalColumnPivot * primalColumnPivot_;
668  /// Basic variables pivoting on which rows
669  int * pivotVariable_;
670  /// factorization
671  ClpFactorization * factorization_;
672  /// How many iterative refinements to do
673  int numberRefinements_;
674  /// Row scale factors for matrix
675  // ****** get working simply then make coding more efficient
676  // on full matrix operations
677  double * rowScale_;
678  /// Saved version of solution
679  double * savedSolution_;
680  /// Column scale factors
681  double * columnScale_;
682  /// Scale flag, 0 none, 1 normal, 2 dynamic
683  int scalingFlag_;
684  /// Number of times code has tentatively thought optimal
685  int numberTimesOptimal_;
686  /// If change has been made (first attempt at stopping looping)
687  int changeMade_;
688  /// Algorithm >0 == Primal, <0 == Dual
689  int algorithm_;
690  /** Now for some reliability aids
691      This forces re-factorization early */
692  int forceFactorization_;
693  /// Saved status regions
694  unsigned char * saveStatus_;
695  /** Perturbation:
696      -50 to +50 - perturb by this power of ten (-6 sounds good)
697      100 - auto perturb if takes too long (1.0e-6 largest nonzero)
698      101 - we are perturbed
699      102 - don't try perturbing again
700      default is 100
701  */
702  int perturbation_;
703  /// Weight assigned to being infeasible in primal
704  double infeasibilityCost_;
705  /** Very wasteful way of dealing with infeasibilities in primal.
706      However it will allow non-linearities and use of dual
707      analysis.  If it doesn't work it can easily be replaced.
708  */
709  ClpNonLinearCost * nonLinearCost_;
710  /// For advanced options
711  unsigned int specialOptions_;
712  /// So we know when to be cautious
713  int lastBadIteration_;
714  /// Can be used for count of fake bounds (dual) or fake costs (primal)
715  int numberFake_;
716  /// Progress flag - at present 0 bit says artificials out
717  int progressFlag_;
718  /// Sum of Dual infeasibilities using tolerance based on error in duals
719  double sumOfRelaxedDualInfeasibilities_;
720  /// Sum of Primal infeasibilities using tolerance based on error in primals
721  double sumOfRelaxedPrimalInfeasibilities_;
722  //@}
723};
724//#############################################################################
725/** A function that tests the methods in the ClpSimplex class. The
726    only reason for it not to be a member method is that this way it doesn't
727    have to be compiled into the library. And that's a gain, because the
728    library should be compiled with optimization on, but this method should be
729    compiled with debugging.
730
731    It also does some testing of ClpFactorization class
732 */
733void
734ClpSimplexUnitTest(const std::string & mpsDir,
735                   const std::string & netlibDir);
736
737
738/// For saving extra information to see if looping. not worth a Class
739class ClpSimplexProgress {
740
741public:
742
743
744  /**@name Constructors and destructor and copy */
745  //@{
746  /// Default constructor
747    ClpSimplexProgress (  );
748
749  /// Constructor from model
750    ClpSimplexProgress ( ClpSimplex * model );
751
752  /// Copy constructor.
753  ClpSimplexProgress(const ClpSimplexProgress &);
754
755  /// Assignment operator. This copies the data
756    ClpSimplexProgress & operator=(const ClpSimplexProgress & rhs);
757  /// Destructor
758   ~ClpSimplexProgress (  );
759  //@}
760
761  /**@name Check progress */
762  //@{
763  /** Returns -1 if okay, -n+1 (n number of times bad) if bad but action taken,
764      >=0 if give up and use as problem status
765  */
766    int looping (  );
767
768  //@}
769  /**@name Data  */
770#define CLP_PROGRESS 4
771  //@{
772  /// Objective values
773  double objective_[CLP_PROGRESS];
774  /// Sum of infeasibilities for algorithm
775  double infeasibility_[CLP_PROGRESS];
776  /// Number of infeasibilities
777  int numberInfeasibilities_[CLP_PROGRESS];
778  /// Number of times checked (so won't stop too early)
779  int numberTimes_;
780  /// Number of times it looked like loop
781  int numberBadTimes_;
782  /// Pointer back to model so we can get information
783  ClpSimplex * model_;
784  //@}
785};
786#endif
Note: See TracBrowser for help on using the repository browser.