# CouenneDomain.hpp

Go to the documentation of this file.

    00001 /* $Id: CouenneDomain.hpp 927 2012-11-28 15:25:47Z stefan $
    00002  *
    00003  * Name:    domain.hpp
    00004  * Author:  Pietro Belotti
    00005  * Purpose: class for point and bounding box
    00006  *
    00007  * (C) Carnegie-Mellon University, 2008-09.
    00008  * This file is licensed under the Eclipse Public License (EPL)
    00009  */
    00010
    00011 #ifndef COUENNE_DOMAIN_HPP
    00012 #define COUENNE_DOMAIN_HPP
    00013
    00014 #include <stdlib.h>
    00015 #include <stack>
    00016
    00017 #include "CouenneTypes.hpp"
    00018
    00019 namespace Osi {
    00020
    00021   class OsiSolverInterface;
    00022   class OsiCuts;
    00023 }
    00024
    00025
    00026 namespace Couenne {
    00027
    00029
    00030 class DomainPoint {
    00031
    00032   friend class Domain;
    00033
    00034 protected:
    00035
    00036   int dimension_;
    00037
    00038   CouNumber *x_;
    00039   CouNumber *lb_;
    00040   CouNumber *ub_;
    00041
    00042   bool copied_;
    00043
    00044
    00045   bool isNlp_;
    00046
    00047 public:
    00048
    00050   DomainPoint (int dim,
    00051                CouNumber *x,
    00052                CouNumber *lb,
    00053                CouNumber *ub,
    00054                bool copy = true);
    00055
    00057   DomainPoint (int dim = 0,
    00058                const CouNumber *x   = NULL,
    00059                const CouNumber *lb  = NULL,
    00060                const CouNumber *ub  = NULL,
    00061                bool copy = true);
    00062
    00064   ~DomainPoint () {
    00065     if (copied_) {
    00066       if (x_)  free (x_);
    00067       if (lb_) free (lb_);
    00068       if (ub_) free (ub_);
    00069     }
    00070   }
    00071
    00073   DomainPoint (const DomainPoint &src);
    00074
    00076   void resize (int newdim);
    00077
    00079   int size () const {return dimension_;}
    00080
    00082   inline int Dimension () {return dimension_;}
    00083
    00084   inline CouNumber &x  (register int index) {return x_  [index];}
    00085   inline CouNumber &lb (register int index) {return lb_ [index];}
    00086   inline CouNumber &ub (register int index) {return ub_ [index];}
    00087
    00088   inline CouNumber *x  () {return x_ ;}
    00089   inline CouNumber *lb () {return lb_;}
    00090   inline CouNumber *ub () {return ub_;}
    00091
    00093   DomainPoint &operator= (const DomainPoint &src);
    00094
    00096   bool &isNlp ()
    00097   {return isNlp_;}
    00098 };
    00099
    00100
    00103
    00104 class Domain {
    00105
    00106 protected:
    00107
    00108   DomainPoint *point_;
    00109   std::stack <DomainPoint *> domStack_;
    00110
    00111 public:
    00112
    00114   Domain (): point_ (NULL) {}
    00115
    00117   Domain (const Domain &src) {
    00118     point_ = new DomainPoint (*(src.point_));
    00119     // TODO -- not important, discard previous points when copying problem
    00120     /*for (std::stack <DomainPoint *>::iterator i = src.domStack_.begin ();
    00121          i != src.domStack_.end (); ++i)
    00122          domStack_.push (new DomainPoint (**i));*/
    00123   }
    00124
    00126   ~Domain ();
    00127
    00129   void push (int dim,
    00130              CouNumber *x,
    00131              CouNumber *lb,
    00132              CouNumber *ub,
    00133              bool copy = true);
    00134
    00136   void push (int dim,
    00137              const CouNumber *x,
    00138              const CouNumber *lb,
    00139              const CouNumber *ub,
    00140              bool copy = true);
    00141
    00144   void push (const OsiSolverInterface *si,
    00145              OsiCuts *cs = NULL,
    00146              bool copy = true);
    00147
    00149   void push (const DomainPoint &dp, bool copy = true);
    00150
    00152   void pop ();
    00153
    00154   inline DomainPoint *current ()   {return point_;}
    00155
    00156   inline CouNumber &x  (register int index) {return point_ -> x  (index);}
    00157   inline CouNumber &lb (register int index) {return point_ -> lb (index);}
    00158   inline CouNumber &ub (register int index) {return point_ -> ub (index);}
    00159
    00160   inline CouNumber *x  () {return point_ -> x  ();}
    00161   inline CouNumber *lb () {return point_ -> lb ();}
    00162   inline CouNumber *ub () {return point_ -> ub ();}
    00163 };
    00164
    00165 }
    00166
    00167 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines