# source:branches/Couenne/Couenne/src/problem/CouenneProblem.h@534

Last change on this file since 534 was 534, checked in by pbelotti, 13 years ago

moved include files to make them doxygenable. Introduced three-way branching, with fixed intervals for now. Added check for small bound interval within all generateCuts()

File size: 4.2 KB
Line
1/*
2 * Name:    CouenneProblem.h
3 * Author:  Pietro Belotti
4 * Purpose: define the class CouenneProblem
5 *
7 */
8
9#ifndef COUENNE_PROBLEM_H
10#define COUENNE_PROBLEM_H
11
12#include <vector>
13
14#include <OsiRowCut.hpp>
15
16#include <CouenneTypes.h>
17#include <expression.h>
18#include <exprAux.h>
19#include <CouenneProblemElem.h>
20
21struct ASL;
22struct expr;
23
24struct compExpr {
25  inline bool operator () (exprAux* e0, exprAux* e1) const
26  {return (e0 -> Image () -> compare (*(e1 -> Image ())) < 0);}
27};
28
29
30/// The CouenneProblem class
31
32class CouenneProblem {
33
34 protected:
35
36  /// data of the original problem
37  std::vector <Objective         *> objectives_;
38  std::vector <CouenneConstraint *> constraints_;
39
40  /// data of the linearized problem
41  std::vector <exprAux          *> auxiliaries_;
42  std::vector <exprVar          *> variables_;
43
44  /// current value and bounds for original- and auxiliary variables
45  CouNumber *x_;
46  CouNumber *lb_;
47  CouNumber *ub_;
48
49  /// expression map for comparison in standardization
50  std::set <exprAux *, compExpr> *auxSet_; // int to count occurrences
51
52  /// number of elements in the x_, lb_, ub_ arrays
53  int curnvars_;
54
55  /// number of discrete variables
56  int nIntVars_;
57
58 public:
59
60  /// constructors, destructor
61  CouenneProblem  () {x_ = lb_ = ub_ = NULL; auxSet_ = NULL; curnvars_ = -1; nIntVars_ = 0;}
62  CouenneProblem  (const CouenneProblem &);
63  ~CouenneProblem ();
64
65  /// clone method (for use within CouenneCutGenerator::clone)
66  CouenneProblem *clone () const;
67
68  /// update value of variables and bounds
69  void update (CouNumber *, CouNumber *, CouNumber *, int = -1);
70
71  /// get size of vectors
72  int nObjs   () const {return objectives_.        size ();}
73  int nNLCons () const {return constraints_.       size ();}
74
75  int nAuxs    () const {return auxiliaries_.       size ();}
76  int nVars    () const {return variables_.         size ();}
77  int nIntVars () const {return nIntVars_;}
78
79  /// get elements from vectors
80  CouenneConstraint *NLCon (int i) const {return constraints_  [i];}
81  Objective         *Obj   (int i) const {return objectives_   [i];}
82
83  ///  LinearConstraint  *Con   (int i) const {return linearconstraints_ [i];}
84  exprAux     *Aux   (int i) const {return auxiliaries_  [i];}
85  exprVar     *Var   (int i) const {return variables_    [i];}
86
87  /// get and set current variable and bounds
88  CouNumber   &X     (int i) {return x_   [i];}
89  CouNumber   &Lb    (int i) {return lb_  [i];}
90  CouNumber   &Ub    (int i) {return ub_  [i];}
91
92  /// get and set current variable and bounds
93  CouNumber  *X     () const {return x_;}
94  CouNumber  *Lb    () const {return lb_;}
95  CouNumber  *Ub    () const {return ub_;}
96
97  /// add (non linear) objective function
98  void addObjective     (expression *, const std::string &);
99
100  /// add (non linear) "=", ">=", "<=", and range constraints
101  void addEQConstraint  (expression *, expression *);
102  void addGEConstraint  (expression *, expression *);
103  void addLEConstraint  (expression *, expression *);
104  void addRNGConstraint (expression *, expression *, expression *);
105
108
109  /// add auxiliary variable and associate it with expression given as
110  /// argument (used in standardization)
112
113  /// break problem's nonlinear constraints in simple expressions to be
114  /// convexified later
115  void standardize ();
116
117  /// output objective, linear and nonlinear constraints, and auxiliary
118  /// variables
119  void print (std::ostream &);
120
121  /// read problem from .nl file using the Ampl Solver Library (ASL)
122  int readnl (const struct ASL *);
123
124  /// read problem from .nl file using the Ampl Solver Library (ASL)
125  expression *nl2e (struct expr *);
126
127  /// store nonlinear problem into a .mod file (with lots of defined
128  /// variables)
129  void writeMod (char *);
130
131  /// initialize auxiliary variables and their bounds from original
132  /// variables
133  void initAuxs (CouNumber *, CouNumber *, CouNumber *);
134
135  /// get auxiliary variables from original variables
136  void getAuxs (CouNumber *);
137
138  /// bound tightening
139  int tightenBounds (char *) const;
140
141  /// search for implied bounds
142  int impliedBounds (char *) const;
143};
144
145#endif
Note: See TracBrowser for help on using the repository browser.