source: branches/devel-1/include/Presolve.hpp @ 39

Last change on this file since 39 was 39, checked in by forrest, 19 years ago

Messing about with presolve

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 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  // taken out for now
29#if 0
30  /**@name presolve - presolves a model, transforming the model
31   * and saving information in the Presolve object needed for postsolving.
32   * This is method is virtual; the idea is that in the future,
33   * one could override this method to customize how the various
34   * presolve techniques are applied.
35   */
36  virtual void presolve(ClpSimplex& si);
37
38  /**@name postsolve - postsolve the problem.  The problem must
39    have been solved to optimality.
40   If you are using an algorithm like simplex that has a concept
41   of "basic" rows/cols, then pass in two arrays
42   that indicate which cols/rows are basic in the problem passed in (si);
43   on return, they will indicate which rows/cols in the original
44   problem are basic in the solution.
45   These two arrays must have enough room for ncols/nrows in the
46   *original* problem, not the problem being passed in.
47   If you aren't interested in this information, or it doesn't make
48   sense, then pass in 0 for each array.
49 
50   Note that if you modified the problem after presolving it,
51   then you must ``undo'' these modifications before calling postsolve.
52  */
53  virtual void postsolve(ClpSimplex& si,
54                         unsigned char *colstat,
55                         unsigned char *rowstat);
56#endif
57  /**@name presolve - presolves a model, transforming the model
58   * and saving information in the Presolve object needed for postsolving.
59   * This is method is virtual; the idea is that in the future,
60   * one could override this method to customize how the various
61   * presolve techniques are applied.
62
63   This version of presolve returns a pointer to a new presolved
64      model.  NULL if infeasible or unbounded. 
65      This should be paired with postsolve
66      below.  The adavantage of going back to original model is that it
67      will be exactly as it was i.e. 0.0 will not become 1.0e-19.
68      If keepIntegers is true then bounds may be tightened in
69      original.  Bounds will be moved by up to feasibilityTolerance
70      to try and stay feasible.
71  */
72  virtual ClpSimplex * presolvedModel(ClpSimplex & si,
73                                      double feasibilityTolerance=0.0,
74                                      bool keepIntegers=true,
75                                      int numberPasses=5);
76
77  /** Return pointer to presolved model,
78      Up to user to destroy */
79  ClpSimplex * model() const;
80  /// Return pointer to original model
81  ClpSimplex * originalModel() const;
82  /// Set pointer to original model
83  void setOriginalModel(ClpSimplex * model);
84   
85  /// return pointer to original columns
86  const int * originalColumns() const;
87
88
89  /**@name postsolve - postsolve the problem.  If the problem
90    has not been solved to optimality, there are no guarantees.
91   If you are using an algorithm like simplex that has a concept
92   of "basic" rows/cols, then set updateStatus
93 
94   Note that if you modified the original problem after presolving,
95   then you must ``undo'' these modifications before calling postsolve.
96  This version updates original*/
97  virtual void postsolve(bool updateStatus=true);
98
99  /**@name private or protected data */
100private:
101  /// Original model - must not be destroyed before postsolve
102  ClpSimplex * originalModel_;
103
104  /// Presolved model - up to user to destroy
105  ClpSimplex * presolvedModel_;
106  /// Original column numbers
107  int * originalColumn_;
108  /// The list of transformations applied.
109  const PresolveAction *paction_;
110
111  /// The postsolved problem will expand back to its former size
112  /// as postsolve transformations are applied.
113  /// It is efficient to allocate data structures for the final size
114  /// of the problem rather than expand them as needed.
115  /// These fields give the size of the original problem.
116  int ncols_;
117  int nrows_;
118  int nelems_;
119  /// Number of major passes
120  int numberPasses_;
121
122protected:
123  /// If you want to apply the individual presolve routines differently,
124  /// or perhaps add your own to the mix,
125  /// define a derived class and override this method
126  virtual const PresolveAction *presolve(PresolveMatrix *prob);
127
128  /// Postsolving is pretty generic; just apply the transformations
129  /// in reverse order.
130  /// You will probably only be interested in overriding this method
131  /// if you want to add code to test for consistency
132  /// while debugging new presolve techniques.
133  virtual void postsolve(PostsolveMatrix &prob);
134};
135#endif
Note: See TracBrowser for help on using the repository browser.