Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CouenneProblemElem.hpp
Go to the documentation of this file.
1 /* $Id: CouenneProblemElem.hpp 910 2012-10-27 13:14:44Z pbelotti $
2  *
3  * Name: CouenneProblemElem.hpp
4  * Author: Pietro Belotti
5  * Purpose: define the classes used by class CouenneProblem
6  *
7  * (C) Carnegie-Mellon University, 2006-08.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_PROBLEM_ELEM_HPP
12 #define COUENNE_PROBLEM_ELEM_HPP
13 
14 #include <iostream>
15 
16 #include "CouenneTypes.hpp"
17 #include "CouenneExpression.hpp"
18 #include "CouenneExprConst.hpp"
19 
20 namespace Couenne {
21 
40 
41  protected:
42 
46 
47  public:
48 
50  CouenneConstraint (expression *body = NULL,
51  expression *lb = NULL,
52  expression *ub = NULL):
53  body_ (body),
54  lb_ (lb),
55  ub_ (ub) {
56 
57  if (!lb_)
58  if (!ub_) {
59  lb_ = new exprConst (0.);
60  ub_ = new exprConst (0.);
61  }
62  else lb_ = new exprConst (- COUENNE_INFINITY);
63  else if (!ub_) ub_ = new exprConst (COUENNE_INFINITY);
64  }
65 
67  virtual ~CouenneConstraint () {
68  delete body_;
69  delete lb_;
70  delete ub_;
71  }
72 
75  body_ (c.Body () -> clone (d)),
76  lb_ (c.Lb () -> clone (d)),
77  ub_ (c.Ub () -> clone (d)) {}
78 
80  virtual inline CouenneConstraint *clone (Domain *d = NULL) const
81  {return new CouenneConstraint (*this, d);}
82 
83  // Get constraint's elements
84  virtual inline expression *Lb () const {return lb_;}
85  virtual inline expression *Ub () const {return ub_;}
86  virtual inline expression *Body () const {return body_;}
87 
89  virtual inline expression *Body (expression *newBody)
90  {body_ = newBody; return body_;}
91 
93  virtual exprAux *standardize (CouenneProblem *);
94 
96  virtual void print (std::ostream & = std::cout);
97 };
98 
99 
100 
110 
111  protected:
112 
115 
116  public:
117 
120  body_ (body) {}
121 
124  {delete body_;}
125 
127  CouenneObjective (const CouenneObjective &o, Domain *d = NULL):
128  body_ (o.body_ -> clone (d)) {}
129 
131  inline CouenneObjective *clone (Domain *d = NULL) const
132  {return new CouenneObjective (*this, d);}
133 
135  inline expression *Body () const
136  {return body_;}
137 
140  {body_ = newBody; return body_;}
141 
144  {return body_ -> standardize (p);}
145 
147  void print (std::ostream &out = std::cout) {
148  out << "min ";
149  body_ -> print (out);
150  out << std::endl;
151  }
152 };
153 
154 }
155 
156 #endif
virtual exprAux * standardize(CouenneProblem *)
decompose body of constraint through auxiliary variables
void print(std::ostream &out=std::cout)
Print to iostream.
virtual expression * Body(expression *newBody)
Set body of constraint.
CouenneConstraint(const CouenneConstraint &c, Domain *d=NULL)
Copy constructor.
CouenneObjective(expression *body)
constructor
expression * Body() const
get body
virtual void print(std::ostream &=std::cout)
print constraint
virtual ~CouenneConstraint()
Destructor.
constant-type operator
CouenneObjective(const CouenneObjective &o, Domain *d=NULL)
copy constructor
Class to represent nonlinear constraints.
exprAux * standardize(CouenneProblem *p)
Get standard form of this objective function.
expression * ub_
Upper bound (expression)
Class for MINLP problems with symbolic information.
expression * body_
expression to optimize
virtual CouenneConstraint * clone(Domain *d=NULL) const
Cloning method.
CouenneConstraint(expression *body=NULL, expression *lb=NULL, expression *ub=NULL)
Constructor.
expression * lb_
Lower bound (expression)
#define COUENNE_INFINITY
Auxiliary variable.
expression * Body(expression *newBody)
Set body.
Expression base class.
expression * body_
Body of constraint.
virtual expression * Lb() const
Expression of lower bound.
virtual expression * Ub() const
Expression of upper bound.
virtual expression * Body() const
Expression of body of constraint.
CouenneObjective * clone(Domain *d=NULL) const
cloning method
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...