source: branches/pre/include/ClpInterior.hpp @ 215

Last change on this file since 215 was 215, checked in by forrest, 16 years ago

Second try at pdco

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.0 KB
Line 
1// Copyright (C) 2003, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4/*
5   Authors
6   
7   John Tomlin (with some help from John Forrest)
8
9 */
10#ifndef ClpInterior_H
11#define ClpInterior_H
12
13#include <iostream>
14#include <cfloat>
15#include "ClpModel.hpp"
16#include "ClpMatrixBase.hpp"
17#include "ClpSolve.hpp"
18class ClpLsqr;
19class ClpPdcoBase;
20// ******** DATA to be moved into protected section of ClpInterior
21typedef struct{
22  double  atolmin;
23  double  r3norm;
24  double  LSdamp;
25  double* deltay;
26} Info;
27
28typedef struct{
29  double  atolold;
30  double  atolnew;
31  double  r3ratio;
32  int   istop;
33  int   itncg;
34} Outfo;
35 
36typedef struct{
37double  gamma;
38double  delta;
39int MaxIter;
40double  FeaTol;
41double  OptTol;
42double  StepTol;
43double  x0min;
44double  z0min;
45double  mu0;
46int   LSmethod;   // 1=Cholesky    2=QR    3=LSQR
47int   LSproblem;  // See below
48int LSQRMaxIter;
49double  LSQRatol1; // Initial  atol
50double  LSQRatol2; // Smallest atol (unless atol1 is smaller)
51double  LSQRconlim;
52int  wait;
53} Options;
54class Lsqr;
55// ***** END
56/** This solves LPs using interior point methods
57
58    It inherits from ClpModel and all its arrays are created at
59    algorithm time.
60
61*/
62
63class ClpInterior : public ClpModel {
64   friend void ClpInteriorUnitTest(const std::string & mpsDir,
65                                  const std::string & netlibDir);
66
67public:
68
69  /**@name Constructors and destructor and copy */
70  //@{
71  /// Default constructor
72    ClpInterior (  );
73
74  /// Copy constructor.
75  ClpInterior(const ClpInterior &);
76  /// Copy constructor from model.
77  ClpInterior(const ClpModel &);
78  /** Subproblem constructor.  A subset of whole model is created from the
79      row and column lists given.  The new order is given by list order and
80      duplicates are allowed.  Name and integer information can be dropped
81  */
82  ClpInterior (const ClpModel * wholeModel,
83              int numberRows, const int * whichRows,
84              int numberColumns, const int * whichColumns,
85              bool dropNames=true, bool dropIntegers=true);
86  /// Assignment operator. This copies the data
87    ClpInterior & operator=(const ClpInterior & rhs);
88  /// Destructor
89   ~ClpInterior (  );
90  // Ones below are just ClpModel with some changes
91  /** Loads a problem (the constraints on the
92        rows are given by lower and upper bounds). If a pointer is 0 then the
93        following values are the default:
94        <ul>
95          <li> <code>colub</code>: all columns have upper bound infinity
96          <li> <code>collb</code>: all columns have lower bound 0
97          <li> <code>rowub</code>: all rows have upper bound infinity
98          <li> <code>rowlb</code>: all rows have lower bound -infinity
99          <li> <code>obj</code>: all variables have 0 objective coefficient
100        </ul>
101    */
102  void loadProblem (  const ClpMatrixBase& matrix,
103                     const double* collb, const double* colub,   
104                     const double* obj,
105                     const double* rowlb, const double* rowub,
106                      const double * rowObjective=NULL);
107  void loadProblem (  const CoinPackedMatrix& matrix,
108                     const double* collb, const double* colub,   
109                     const double* obj,
110                     const double* rowlb, const double* rowub,
111                      const double * rowObjective=NULL);
112
113  /** Just like the other loadProblem() method except that the matrix is
114        given in a standard column major ordered format (without gaps). */
115  void loadProblem (  const int numcols, const int numrows,
116                     const CoinBigIndex* start, const int* index,
117                     const double* value,
118                     const double* collb, const double* colub,   
119                     const double* obj,
120                      const double* rowlb, const double* rowub,
121                      const double * rowObjective=NULL);
122  /// This one is for after presolve to save memory
123  void loadProblem (  const int numcols, const int numrows,
124                     const CoinBigIndex* start, const int* index,
125                      const double* value,const int * length,
126                     const double* collb, const double* colub,   
127                     const double* obj,
128                      const double* rowlb, const double* rowub,
129                      const double * rowObjective=NULL);
130  /// Read an mps file from the given filename
131  int readMps(const char *filename,
132              bool keepNames=false,
133              bool ignoreErrors = false);
134  //@}
135
136  /**@name Functions most useful to user */
137  //@{
138  /** Pdco algorithm - see ClpPdco.hpp for method */
139  int pdco();
140  // ** Temporary version
141  int  pdco( ClpPdcoBase * stuff, Options &options, Info &info, Outfo &outfo);
142  //@}
143
144  /**@name most useful gets and sets */
145  //@{
146  /// If problem is primal feasible
147  inline bool primalFeasible() const
148         { return (sumPrimalInfeasibilities_<=1.0e-5);};
149  /// If problem is dual feasible
150  inline bool dualFeasible() const
151         { return (sumDualInfeasibilities_<=1.0e-5);};
152  /// Current (or last) algorithm
153  inline int algorithm() const 
154  {return algorithm_; } ;
155  /// Set algorithm
156  inline void setAlgorithm(int value)
157  {algorithm_=value; } ;
158  /// Sum of dual infeasibilities
159  inline double sumDualInfeasibilities() const 
160          { return sumDualInfeasibilities_;} ;
161  /// Sum of primal infeasibilities
162  inline double sumPrimalInfeasibilities() const 
163          { return sumPrimalInfeasibilities_;} ;
164  //@}
165
166  /******************** End of most useful part **************/
167  /**@name Functions less likely to be useful to casual user */
168  //@{
169  //@}
170  /**@name Matrix times vector methods
171     They can be faster if scalar is +- 1
172     These are covers so user need not worry about scaling
173     Also for simplex I am not using basic/non-basic split */
174  //@{
175    /** Return <code>y + A * x * scalar</code> in <code>y</code>.
176        @pre <code>x</code> must be of size <code>numColumns()</code>
177        @pre <code>y</code> must be of size <code>numRows()</code> */
178   void times(double scalar,
179                       const double * x, double * y) const;
180    /** Return <code>y + x * scalar * A</code> in <code>y</code>.
181        @pre <code>x</code> must be of size <code>numRows()</code>
182        @pre <code>y</code> must be of size <code>numColumns()</code> */
183    void transposeTimes(double scalar,
184                                const double * x, double * y) const ;
185  //@}
186
187  /**@name most useful gets and sets */
188  //@{
189  /// Largest error on Ax-b
190  inline double largestPrimalError() const
191          { return largestPrimalError_;} ;
192  /// Largest error on basic duals
193  inline double largestDualError() const
194          { return largestDualError_;} ;
195  //@}
196
197  protected:
198  /**@name protected methods */
199  //@{
200  /// Does most of deletion
201  void gutsOfDelete();
202  /// Does most of copying
203  void gutsOfCopy(const ClpInterior & rhs);
204  /// Returns true if data looks okay, false if not
205  bool createWorkingData();
206  void deleteWorkingData();
207  /// Sanity check on input rim data
208  bool sanityCheck();
209  ///  This does housekeeping
210  int housekeeping();
211  //@}
212  public:
213  /**@name public methods */
214  //@{
215  /// Raw objective value (so always minimize)
216  inline double rawObjectiveValue() const
217  { return objectiveValue_;};
218  /// Returns 1 if sequence indicates column
219  inline int isColumn(int sequence) const
220  { return sequence<numberColumns_ ? 1 : 0;};
221  /// Returns sequence number within section
222  inline int sequenceWithin(int sequence) const
223  { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;};
224  //@}
225
226////////////////// data //////////////////
227protected:
228
229  /**@name data.  Many arrays have a row part and a column part.
230   There is a single array with both - columns then rows and
231   then normally two arrays pointing to rows and columns.  The
232   single array is the owner of memory
233  */
234  //@{
235  /// Largest error on Ax-b
236  double largestPrimalError_;
237  /// Largest error on basic duals
238  double largestDualError_;
239  /// Sum of dual infeasibilities
240  double sumDualInfeasibilities_;
241  /// Sum of primal infeasibilities
242  double sumPrimalInfeasibilities_;
243public:
244  double xsize_;
245  double zsize_;
246protected:
247  /// Working copy of lower bounds (Owner of arrays below)
248  double * lower_;
249  /// Row lower bounds - working copy
250  double * rowLowerWork_;
251  /// Column lower bounds - working copy
252  double * columnLowerWork_;
253  /// Working copy of upper bounds (Owner of arrays below)
254  double * upper_;
255  /// Row upper bounds - working copy
256  double * rowUpperWork_;
257  /// Column upper bounds - working copy
258  double * columnUpperWork_;
259  /// Working copy of objective
260  double * cost_;
261public:
262  /// Rhs
263  double * rhs_;
264  double * x_;
265  double * y_;
266  double * dj_;
267protected:
268  /// Pointer to Lsqr object
269  ClpLsqr * lsqrObject_;
270  /// Pointer to stuff
271  ClpPdcoBase * pdcoStuff_;
272  /// Which algorithm being used
273  int algorithm_;
274  //@}
275};
276//#############################################################################
277/** A function that tests the methods in the ClpInterior class. The
278    only reason for it not to be a member method is that this way it doesn't
279    have to be compiled into the library. And that's a gain, because the
280    library should be compiled with optimization on, but this method should be
281    compiled with debugging.
282
283    It also does some testing of ClpFactorization class
284 */
285void
286ClpInteriorUnitTest(const std::string & mpsDir,
287                   const std::string & netlibDir);
288
289
290#endif
Note: See TracBrowser for help on using the repository browser.