/home/coin/SVN-release/OS-2.0.0/Couenne/src/problem/CouenneProblemElem.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneProblemElem.hpp 154 2009-06-16 18:52:53Z pbelotti $ */
00002 /*
00003  * Name:    CouenneProblemElem.hpp
00004  * Author:  Pietro Belotti
00005  * Purpose: define the classes used by class CouenneProblem
00006  *
00007  * (C) Carnegie-Mellon University, 2006-08. 
00008  * This file is licensed under the Common Public License (CPL)
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 "expression.hpp"
00018 #include "exprConst.hpp"
00019 
00020 
00038 class CouenneConstraint {
00039 
00040  protected:
00041 
00042   expression *body_; 
00043   expression *lb_;   
00044   expression *ub_;   
00045 
00046  public:
00047 
00049   CouenneConstraint  (expression *body = NULL, 
00050                       expression *lb   = NULL, 
00051                       expression *ub   = NULL):
00052     body_     (body), 
00053     lb_       (lb), 
00054     ub_       (ub) {
00055 
00056     if (!lb_) 
00057       if (!ub_) {
00058         lb_ = new exprConst (0.);
00059         ub_ = new exprConst (0.);
00060       } 
00061       else         lb_ = new exprConst (- COUENNE_INFINITY);
00062     else if (!ub_) ub_ = new exprConst   (COUENNE_INFINITY);
00063   }
00064 
00066   ~CouenneConstraint () {
00067     delete body_; 
00068     delete lb_; 
00069     delete ub_;
00070   }
00071 
00073   CouenneConstraint  (const CouenneConstraint &c, Domain *d = NULL):
00074     body_  (c.Body () -> clone (d)),
00075     lb_    (c.Lb   () -> clone (d)),
00076     ub_    (c.Ub   () -> clone (d)) {}
00077 
00079   inline CouenneConstraint *clone (Domain *d = NULL) const
00080   {return new CouenneConstraint (*this, d);}
00081 
00082   // Get constraint's elements
00083   inline expression *Lb   () const {return lb_;}   
00084   inline expression *Ub   () const {return ub_;}   
00085   inline expression *Body () const {return body_;} 
00086 
00088   inline expression *Body (expression *newBody) 
00089   {body_ = newBody; return body_;}
00090 
00092   exprAux *standardize (CouenneProblem *);
00093 
00095   void print (std::ostream & = std::cout);
00096 };
00097 
00098 
00099 
00108 class CouenneObjective {
00109 
00110  protected:
00111 
00113   expression *body_;
00114 
00115  public:
00116 
00118   CouenneObjective (expression *body):
00119     body_ (body) {}
00120 
00122   ~CouenneObjective () 
00123   {delete body_;}
00124 
00126   CouenneObjective  (const CouenneObjective &o, Domain *d = NULL):
00127     body_  (o.body_ -> clone (d)) {}
00128 
00130   inline CouenneObjective *clone (Domain *d = NULL) const
00131   {return new CouenneObjective (*this, d);}
00132 
00134   inline expression *Body () const
00135   {return body_;}
00136 
00138   expression *Body (expression *newBody) 
00139   {body_ = newBody; return body_;}
00140 
00142   inline exprAux *standardize (CouenneProblem *p) 
00143   {return body_ -> standardize (p);}
00144 
00146   void print (std::ostream &out = std::cout) {
00147     out << "min ";
00148     body_ -> print (out);
00149     out << std::endl;
00150   }
00151 };
00152 
00153 #endif

Generated on Mon Aug 3 03:02:21 2009 by  doxygen 1.4.7