Couenne 0.5.8
Loading...
Searching...
No Matches
CouenneDomain.hpp
Go to the documentation of this file.
1/* $Id: CouenneDomain.hpp 927 2012-11-28 15:25:47Z stefan $
2 *
3 * Name: domain.hpp
4 * Author: Pietro Belotti
5 * Purpose: class for point and bounding box
6 *
7 * (C) Carnegie-Mellon University, 2008-09.
8 * This file is licensed under the Eclipse Public License (EPL)
9 */
10
11#ifndef COUENNE_DOMAIN_HPP
12#define COUENNE_DOMAIN_HPP
13
14#include <stdlib.h>
15#include <stack>
16
17#include "CouenneTypes.hpp"
18
19namespace Osi {
20
22 class OsiCuts;
23}
24
25
26namespace Couenne {
27
29
31
32 friend class Domain;
33
34protected:
35
37
41
42 bool copied_;
44
45 bool isNlp_;
47public:
48
50 DomainPoint (int dim,
51 CouNumber *x,
54 bool copy = true);
55
57 DomainPoint (int dim = 0,
58 const CouNumber *x = NULL,
59 const CouNumber *lb = NULL,
60 const CouNumber *ub = NULL,
61 bool copy = true);
62
65 if (copied_) {
66 if (x_) free (x_);
67 if (lb_) free (lb_);
68 if (ub_) free (ub_);
69 }
70 }
71
74
76 void resize (int newdim);
77
79 int size () const {return dimension_;}
80
82 inline int Dimension () {return dimension_;}
83
84 inline CouNumber &x (register int index) {return x_ [index];}
85 inline CouNumber &lb (register int index) {return lb_ [index];}
86 inline CouNumber &ub (register int index) {return ub_ [index];}
87
88 inline CouNumber *x () {return x_ ;}
89 inline CouNumber *lb () {return lb_;}
90 inline CouNumber *ub () {return ub_;}
91
94
96 bool &isNlp ()
97 {return isNlp_;}
98};
99
100
103
104class Domain {
105
106protected:
107
109 std::stack <DomainPoint *> domStack_;
110
111public:
112
114 Domain (): point_ (NULL) {}
115
117 Domain (const Domain &src) {
118 point_ = new DomainPoint (*(src.point_));
119 // TODO -- not important, discard previous points when copying problem
120 /*for (std::stack <DomainPoint *>::iterator i = src.domStack_.begin ();
121 i != src.domStack_.end (); ++i)
122 domStack_.push (new DomainPoint (**i));*/
123 }
124
127
129 void push (int dim,
130 CouNumber *x,
131 CouNumber *lb,
132 CouNumber *ub,
133 bool copy = true);
134
136 void push (int dim,
137 const CouNumber *x,
138 const CouNumber *lb,
139 const CouNumber *ub,
140 bool copy = true);
141
144 void push (const OsiSolverInterface *si,
145 OsiCuts *cs = NULL,
146 bool copy = true);
147
149 void push (const DomainPoint &dp, bool copy = true);
150
152 void pop ();
153
154 inline DomainPoint *current () {return point_;}
155
156 inline CouNumber &x (register int index) {return point_ -> x (index);}
157 inline CouNumber &lb (register int index) {return point_ -> lb (index);}
158 inline CouNumber &ub (register int index) {return point_ -> ub (index);}
159
160 inline CouNumber *x () {return point_ -> x ();}
161 inline CouNumber *lb () {return point_ -> lb ();}
162 inline CouNumber *ub () {return point_ -> ub ();}
163};
164
165}
166
167#endif
Define a point in the solution space and the bounds around it.
CouNumber * ub_
upper bound
int dimension_
dimension of point
CouNumber & lb(register int index)
return current lower bound
void resize(int newdim)
resize domain point (for extending into higher space)
~DomainPoint()
destructor
CouNumber * lb()
return current lower bound vector
CouNumber * x_
current value of variables
bool copied_
true if data has been copied (so we own it, and have to delete it upon destruction)
CouNumber & ub(register int index)
return current upper bound
CouNumber * x()
return current variable vector
DomainPoint & operator=(const DomainPoint &src)
assignment operator
int size() const
return current size
bool isNlp_
true if this point comes from an NLP solver (and is thus nlp feasible)
int Dimension()
return dimension_
DomainPoint(const DomainPoint &src)
copy constructor
DomainPoint(int dim, CouNumber *x, CouNumber *lb, CouNumber *ub, bool copy=true)
constructor
CouNumber & x(register int index)
return current variable
CouNumber * lb_
lower bound
CouNumber * ub()
return current upper bound vector
bool & isNlp()
true if this point is the nlp solution
DomainPoint(int dim=0, const CouNumber *x=NULL, const CouNumber *lb=NULL, const CouNumber *ub=NULL, bool copy=true)
constructor
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
CouNumber & lb(register int index)
current lower bound
CouNumber * ub()
return current upper bound vector
void pop()
restore previous point
std::stack< DomainPoint * > domStack_
stack of saved points
CouNumber * x()
return current variable vector
Domain(const Domain &src)
copy constructor
void push(const OsiSolverInterface *si, OsiCuts *cs=NULL, bool copy=true)
save current point and start using another – retrieve information from solver interface and from prev...
~Domain()
destructor
DomainPoint * point_
current point
CouNumber * lb()
return current lower bound vector
void push(int dim, const CouNumber *x, const CouNumber *lb, const CouNumber *ub, bool copy=true)
save current point and start using another
Domain()
basic constructor
void push(const DomainPoint &dp, bool copy=true)
save current point and start using another
void push(int dim, CouNumber *x, CouNumber *lb, CouNumber *ub, bool copy=true)
save current point and start using another
CouNumber & ub(register int index)
current upper bound
DomainPoint * current()
return current point
CouNumber & x(register int index)
current variable
general include file for different compilers
double CouNumber
main number type in Couenne