source: branches/devel-1/include/Presolve.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: 4.0 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4#ifndef Presolve_H
5#define Presolve_H
6#include "ClpSimplex.hpp"
7
8class PresolveAction;
9class PresolveMatrix;
10class PostsolveMatrix;
11
12/** This class stores information generated by the presolve procedure.
13 */
14class Presolve {
15public:
16  /**@name Constructor and destructor
17     No copy method is defined.
18     I have not attempted to prevent the default copy method from being
19     generated.
20   */
21  //@{
22  /// Default constructor
23  Presolve();
24
25  /// Virtual destructor
26  virtual ~Presolve();
27  //@}
28
29  /**@name presolve - presolves a model, transforming the model
30   * and saving information in the Presolve object needed for postsolving.
31   * This is method is virtual; the idea is that in the future,
32   * one could override this method to customize how the various
33   * presolve techniques are applied.
34   */
35  virtual void presolve(ClpSimplex& si);
36
37  /**@name postsolve - postsolve the problem.  The problem must
38    have been solved to optimality.
39   If you are using an algorithm like simplex that has a concept
40   of "basic" rows/cols, then pass in two arrays
41   that indicate which cols/rows are basic in the problem passed in (si);
42   on return, they will indicate which rows/cols in the original
43   problem are basic in the solution.
44   These two arrays must have enough room for ncols/nrows in the
45   *original* problem, not the problem being passed in.
46   If you aren't interested in this information, or it doesn't make
47   sense, then pass in 0 for each array.
48 
49   Note that if you modified the problem after presolving it,
50   then you must ``undo'' these modifications before calling postsolve.
51  */
52  virtual void postsolve(ClpSimplex& si,
53                         unsigned char *colstat,
54                         unsigned char *rowstat);
55  /** This version of presolve returns a pointer to a new presolved
56      model.  NULL if infeasible or unbounded. 
57      This should be paired with postsolve
58      below.  The adavantage of going back to original model is that it
59      will be exactly as it was i.e. 0.0 will not become 1.0e-19.
60      If keepIntegers is true then bounds may be tightened in
61      original.  Bounds will be moved by up to feasibilityTolerance
62      to try and stay feasible.
63  */
64  virtual ClpSimplex * presolvedModel(ClpSimplex & si,
65                                      double feasibilityTolerance=0.0,
66                                      bool keepIntegers=true,
67                                      int numberPasses=5);
68
69  /** Return pointer to presolved model,
70      Up to user to destroy */
71  ClpSimplex * model() const;
72  /// Return pointer to original model
73  ClpSimplex * originalModel() const;
74  /// return pointer to original columns
75  const int * originalColumns() const;
76
77
78  /** This version updates original*/
79  virtual void postsolve(bool updateStatus=true);
80
81  /**@name private or protected data */
82private:
83  /// Original model - must not be destroyed before postsolve
84  ClpSimplex * originalModel_;
85
86  /// Presolved model - up to user to destroy
87  ClpSimplex * presolvedModel_;
88  /// Original column numbers
89  int * originalColumn_;
90  /// The list of transformations applied.
91  const PresolveAction *paction_;
92
93  /// The postsolved problem will expand back to its former size
94  /// as postsolve transformations are applied.
95  /// It is efficient to allocate data structures for the final size
96  /// of the problem rather than expand them as needed.
97  /// These fields give the size of the original problem.
98  int ncols_;
99  int nrows_;
100  int nelems_;
101  /// Number of major passes
102  int numberPasses_;
103
104protected:
105  /// If you want to apply the individual presolve routines differently,
106  /// or perhaps add your own to the mix,
107  /// define a derived class and override this method
108  virtual const PresolveAction *presolve(PresolveMatrix *prob);
109
110  /// Postsolving is pretty generic; just apply the transformations
111  /// in reverse order.
112  /// You will probably only be interested in overriding this method
113  /// if you want to add code to test for consistency
114  /// while debugging new presolve techniques.
115  virtual void postsolve(PostsolveMatrix &prob);
116};
117#endif
Note: See TracBrowser for help on using the repository browser.