00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef COUENNE_PROBLEM_ELEM_HPP
00012 #define COUENNE_PROBLEM_ELEM_HPP
00013
00014 #include <iostream>
00015
00016 #include "CouenneTypes.hpp"
00017 #include "CouenneExpression.hpp"
00018 #include "CouenneExprConst.hpp"
00019
00020 namespace Couenne {
00021
00039 class CouenneConstraint {
00040
00041 protected:
00042
00043 expression *body_;
00044 expression *lb_;
00045 expression *ub_;
00046
00047 public:
00048
00050 CouenneConstraint (expression *body = NULL,
00051 expression *lb = NULL,
00052 expression *ub = NULL):
00053 body_ (body),
00054 lb_ (lb),
00055 ub_ (ub) {
00056
00057 if (!lb_)
00058 if (!ub_) {
00059 lb_ = new exprConst (0.);
00060 ub_ = new exprConst (0.);
00061 }
00062 else lb_ = new exprConst (- COUENNE_INFINITY);
00063 else if (!ub_) ub_ = new exprConst (COUENNE_INFINITY);
00064 }
00065
00067 ~CouenneConstraint () {
00068 delete body_;
00069 delete lb_;
00070 delete ub_;
00071 }
00072
00074 CouenneConstraint (const CouenneConstraint &c, Domain *d = NULL):
00075 body_ (c.Body () -> clone (d)),
00076 lb_ (c.Lb () -> clone (d)),
00077 ub_ (c.Ub () -> clone (d)) {}
00078
00080 inline CouenneConstraint *clone (Domain *d = NULL) const
00081 {return new CouenneConstraint (*this, d);}
00082
00083
00084 inline expression *Lb () const {return lb_;}
00085 inline expression *Ub () const {return ub_;}
00086 inline expression *Body () const {return body_;}
00087
00089 inline expression *Body (expression *newBody)
00090 {body_ = newBody; return body_;}
00091
00093 exprAux *standardize (CouenneProblem *);
00094
00096 void print (std::ostream & = std::cout);
00097 };
00098
00099
00100
00109 class CouenneObjective {
00110
00111 protected:
00112
00114 expression *body_;
00115
00116 public:
00117
00119 CouenneObjective (expression *body):
00120 body_ (body) {}
00121
00123 ~CouenneObjective ()
00124 {delete body_;}
00125
00127 CouenneObjective (const CouenneObjective &o, Domain *d = NULL):
00128 body_ (o.body_ -> clone (d)) {}
00129
00131 inline CouenneObjective *clone (Domain *d = NULL) const
00132 {return new CouenneObjective (*this, d);}
00133
00135 inline expression *Body () const
00136 {return body_;}
00137
00139 expression *Body (expression *newBody)
00140 {body_ = newBody; return body_;}
00141
00143 inline exprAux *standardize (CouenneProblem *p)
00144 {return body_ -> standardize (p);}
00145
00147 void print (std::ostream &out = std::cout) {
00148 out << "min ";
00149 body_ -> print (out);
00150 out << std::endl;
00151 }
00152 };
00153
00154 }
00155
00156 #endif