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

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

ClpInterior? compiles

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.2 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 ClpDualRowPivot;
19class ClpPrimalColumnPivot;
20class ClpFactorization;
21class CoinIndexedVector;
22class ClpNonLinearCost;
23class ClpInteriorProgress;
24
25/** This solves LPs using interior point methods
26
27    It inherits from ClpModel and all its arrays are created at
28    algorithm time.
29
30*/
31
32class ClpInterior : public ClpModel {
33   friend void ClpInteriorUnitTest(const std::string & mpsDir,
34                                  const std::string & netlibDir);
35
36public:
37
38  /**@name Constructors and destructor and copy */
39  //@{
40  /// Default constructor
41    ClpInterior (  );
42
43  /// Copy constructor.
44  ClpInterior(const ClpInterior &);
45  /// Copy constructor from model.
46  ClpInterior(const ClpModel &);
47  /** Subproblem constructor.  A subset of whole model is created from the
48      row and column lists given.  The new order is given by list order and
49      duplicates are allowed.  Name and integer information can be dropped
50  */
51  ClpInterior (const ClpModel * wholeModel,
52              int numberRows, const int * whichRows,
53              int numberColumns, const int * whichColumns,
54              bool dropNames=true, bool dropIntegers=true);
55  /// Assignment operator. This copies the data
56    ClpInterior & operator=(const ClpInterior & rhs);
57  /// Destructor
58   ~ClpInterior (  );
59  // Ones below are just ClpModel with some changes
60  /** Loads a problem (the constraints on the
61        rows are given by lower and upper bounds). If a pointer is 0 then the
62        following values are the default:
63        <ul>
64          <li> <code>colub</code>: all columns have upper bound infinity
65          <li> <code>collb</code>: all columns have lower bound 0
66          <li> <code>rowub</code>: all rows have upper bound infinity
67          <li> <code>rowlb</code>: all rows have lower bound -infinity
68          <li> <code>obj</code>: all variables have 0 objective coefficient
69        </ul>
70    */
71  void loadProblem (  const ClpMatrixBase& matrix,
72                     const double* collb, const double* colub,   
73                     const double* obj,
74                     const double* rowlb, const double* rowub,
75                      const double * rowObjective=NULL);
76  void loadProblem (  const CoinPackedMatrix& matrix,
77                     const double* collb, const double* colub,   
78                     const double* obj,
79                     const double* rowlb, const double* rowub,
80                      const double * rowObjective=NULL);
81
82  /** Just like the other loadProblem() method except that the matrix is
83        given in a standard column major ordered format (without gaps). */
84  void loadProblem (  const int numcols, const int numrows,
85                     const CoinBigIndex* start, const int* index,
86                     const double* value,
87                     const double* collb, const double* colub,   
88                     const double* obj,
89                      const double* rowlb, const double* rowub,
90                      const double * rowObjective=NULL);
91  /// This one is for after presolve to save memory
92  void loadProblem (  const int numcols, const int numrows,
93                     const CoinBigIndex* start, const int* index,
94                      const double* value,const int * length,
95                     const double* collb, const double* colub,   
96                     const double* obj,
97                      const double* rowlb, const double* rowub,
98                      const double * rowObjective=NULL);
99  /// Read an mps file from the given filename
100  int readMps(const char *filename,
101              bool keepNames=false,
102              bool ignoreErrors = false);
103  //@}
104
105  /**@name Functions most useful to user */
106  //@{
107  /** Pdco algorithm - see ClpPdco.hpp for method */
108  int pdco();
109  //@}
110
111  /**@name Needed for functionality of OsiSimplexInterface */
112  //@{
113  /// LSQR
114  void lsqr();
115  //@}
116
117  /**@name most useful gets and sets */
118  //@{
119  /// If problem is primal feasible
120  inline bool primalFeasible() const
121         { return (sumPrimalInfeasibilities_<=1.0e-5);};
122  /// If problem is dual feasible
123  inline bool dualFeasible() const
124         { return (sumDualInfeasibilities_<=1.0e-5);};
125  /// Current (or last) algorithm
126  inline int algorithm() const 
127  {return algorithm_; } ;
128  /// Set algorithm
129  inline void setAlgorithm(int value)
130  {algorithm_=value; } ;
131  /// Sum of dual infeasibilities
132  inline double sumDualInfeasibilities() const 
133          { return sumDualInfeasibilities_;} ;
134  /// Sum of primal infeasibilities
135  inline double sumPrimalInfeasibilities() const 
136          { return sumPrimalInfeasibilities_;} ;
137  //@}
138
139  /******************** End of most useful part **************/
140  /**@name Functions less likely to be useful to casual user */
141  //@{
142  //@}
143  /**@name Matrix times vector methods
144     They can be faster if scalar is +- 1
145     These are covers so user need not worry about scaling
146     Also for simplex I am not using basic/non-basic split */
147  //@{
148    /** Return <code>y + A * x * scalar</code> in <code>y</code>.
149        @pre <code>x</code> must be of size <code>numColumns()</code>
150        @pre <code>y</code> must be of size <code>numRows()</code> */
151   void times(double scalar,
152                       const double * x, double * y) const;
153    /** Return <code>y + x * scalar * A</code> in <code>y</code>.
154        @pre <code>x</code> must be of size <code>numRows()</code>
155        @pre <code>y</code> must be of size <code>numColumns()</code> */
156    void transposeTimes(double scalar,
157                                const double * x, double * y) const ;
158  //@}
159
160  /**@name most useful gets and sets */
161  //@{
162  /// Largest error on Ax-b
163  inline double largestPrimalError() const
164          { return largestPrimalError_;} ;
165  /// Largest error on basic duals
166  inline double largestDualError() const
167          { return largestDualError_;} ;
168  //@}
169
170  protected:
171  /**@name protected methods */
172  //@{
173  /// Does most of deletion
174  void gutsOfDelete();
175  /// Does most of copying
176  void gutsOfCopy(const ClpInterior & rhs);
177  /// Returns true if data looks okay, false if not
178  bool createWorkingData();
179  void deleteWorkingData();
180  /// Sanity check on input rim data
181  bool sanityCheck();
182  ///  This does housekeeping
183  int housekeeping();
184  //@}
185  public:
186  /**@name public methods */
187  //@{
188  /// Raw objective value (so always minimize)
189  inline double rawObjectiveValue() const
190  { return objectiveValue_;};
191  /// Returns 1 if sequence indicates column
192  inline int isColumn(int sequence) const
193  { return sequence<numberColumns_ ? 1 : 0;};
194  /// Returns sequence number within section
195  inline int sequenceWithin(int sequence) const
196  { return sequence<numberColumns_ ? sequence : sequence-numberColumns_;};
197  //@}
198
199////////////////// data //////////////////
200protected:
201
202  /**@name data.  Many arrays have a row part and a column part.
203   There is a single array with both - columns then rows and
204   then normally two arrays pointing to rows and columns.  The
205   single array is the owner of memory
206  */
207  //@{
208  /// Largest error on Ax-b
209  double largestPrimalError_;
210  /// Largest error on basic duals
211  double largestDualError_;
212  /// Sum of dual infeasibilities
213  double sumDualInfeasibilities_;
214  /// Sum of primal infeasibilities
215  double sumPrimalInfeasibilities_;
216  /// Working copy of lower bounds (Owner of arrays below)
217  double * lower_;
218  /// Row lower bounds - working copy
219  double * rowLowerWork_;
220  /// Column lower bounds - working copy
221  double * columnLowerWork_;
222  /// Working copy of upper bounds (Owner of arrays below)
223  double * upper_;
224  /// Row upper bounds - working copy
225  double * rowUpperWork_;
226  /// Column upper bounds - working copy
227  double * columnUpperWork_;
228  /// Working copy of objective
229  double * cost_;
230  /// Which algorithm being used
231  int algorithm_;
232  //@}
233};
234//#############################################################################
235/** A function that tests the methods in the ClpInterior class. The
236    only reason for it not to be a member method is that this way it doesn't
237    have to be compiled into the library. And that's a gain, because the
238    library should be compiled with optimization on, but this method should be
239    compiled with debugging.
240
241    It also does some testing of ClpFactorization class
242 */
243void
244ClpInteriorUnitTest(const std::string & mpsDir,
245                   const std::string & netlibDir);
246
247
248#endif
Note: See TracBrowser for help on using the repository browser.