Couenne 0.5.8
CouenneExprVar.hpp
Go to the documentation of this file.
1/* $Id: CouenneExprVar.hpp 911 2012-10-28 19:50:15Z pbelotti $
2 *
3 * Name: exprVar.hpp
4 * Author: Pietro Belotti
5 * Purpose: definition of the class exprVar for variables
6 *
7 * (C) Carnegie-Mellon University, 2006-10.
8 * This file is licensed under the Eclipse Public License (EPL)
9 */
10
11#ifndef COUENNE_EXPRVAR_HPP
12#define COUENNE_EXPRVAR_HPP
13
14#include <iostream>
15#include <set>
16
17#include "CouenneTypes.hpp"
18#include "CouenneExpression.hpp"
19#include "CouenneExprConst.hpp"
20#include "CouenneDomain.hpp"
21
22namespace Ipopt {
23 template <class T> class SmartPtr;
24 class OptionsList;
25 class Journalist;
26}
27
28namespace Bonmin {
29 class BabSetupBase;
30}
31
32namespace Couenne {
33
36
37
39
44
45class exprVar: public expression {
46
47 protected:
48
51
52 public:
53
55 virtual inline enum nodeType Type () const
56 {return VAR;}
57
59 exprVar (int varIndex, Domain *d = NULL):
60 varIndex_ (varIndex),
61 domain_ (d) {}
62
64 virtual ~exprVar () {}
65
67 exprVar (const exprVar &e, Domain *d = NULL):
69 domain_ (d) {}
70
72 virtual inline exprVar *clone (Domain *d = NULL) const
73 {return new exprVar (*this, d);}
74
76 inline int Index () const
77 {return varIndex_;}
78
79 // Bounds
80 virtual expression *Lb ();
81 virtual expression *Ub ();
82
83 // Bounds
84 virtual inline CouNumber &lb () {return domain_ -> lb (varIndex_);}
85 virtual inline CouNumber &ub () {return domain_ -> ub (varIndex_);}
86
88 virtual void print (std::ostream &out = std::cout,
89 bool = false) const
90 {out << "x_" << varIndex_;}
91
93 virtual inline CouNumber operator () ()
94 {return domain_ -> x (varIndex_);}
95
97 virtual inline CouNumber gradientNorm (const double *x)
98 {return 1.;}
99
101 virtual inline expression *differentiate (int index)
102 {return new exprConst ((index == varIndex_) ? 1. : 0.);}
103
106 virtual inline int DepList (std::set <int> &deplist,
107 enum dig_type type = ORIG_ONLY) {
108
109 if (deplist.find (varIndex_) == deplist.end ()) {
110 deplist.insert (varIndex_);
111 return 1;
112 }
113 return 0;
114 }
115
118 virtual inline void crossBounds () {}
119
121 virtual inline expression *simplify ()
122 {return NULL;}
123
125 virtual inline int Linearity ()
126 {return LINEAR;}
127
129 virtual inline bool isDefinedInteger ()
130 {return false;}
131
133 virtual inline bool isInteger () {
134
135 // we definitely want to be very conservative here. A continuous
136 // variable is integer if and only if its current value is really
137 // integer (no round-off) -- see globallib/bearing and term x^(-3.55)
138
140 return (lb == domain_ -> ub (varIndex_)) && (COUENNE_round (lb) == lb);
141 }
142
144 virtual void getBounds (expression *&, expression *&);
145
147 virtual void getBounds (CouNumber &lb, CouNumber &ub);
148
150 //virtual inline void getBounds (CouNumber &lb, CouNumber &ub) {
151 //lb = domain_ -> lb (varIndex_);
152 //ub = domain_ -> ub (varIndex_);
153 //}
154
156 virtual void generateCuts (//const OsiSolverInterface &,
157 OsiCuts &, const CouenneCutGenerator *,
158 t_chg_bounds * = NULL, int = -1,
161
163 virtual void generateCuts (expression *w,
164 //const OsiSolverInterface &si,
165 OsiCuts &cs, const CouenneCutGenerator *cg,
166 t_chg_bounds * = NULL, int = -1,
169
171 virtual inline enum expr_type code ()
172 {return COU_EXPRVAR;}
173
176
178 virtual inline int rank ()
179 {return 1;}
180
182 virtual void fillDepSet (std::set <DepNode *, compNode> *, DepGraph *);
183
185 virtual inline bool isFixed ()
186 {return (fabs (lb () - ub ()) < COUENNE_EPS);}
187
189 virtual inline void linkDomain (Domain *d)
190 {domain_ = d;}
191
193 virtual inline Domain *domain ()
194 {return domain_;}
195
196 // empty for compatibility
197 virtual inline void decreaseMult () {}
198
200 virtual inline void zeroMult () {}
201
203 virtual inline void setInteger (bool value) {}
204
206 virtual enum convexity convexity () const
207 {return AFFINE;}
208
212 CouenneProblem *p,
214 JnlstPtr jnlst_);
215
217 virtual inline enum auxSign sign () const
218 {return expression::AUX_UNDEF;}
219};
220
221}
222
223#endif
#define COUENNE_EPS
#define COUENNE_INFINITY
#define COUENNE_round(x)
Cut Generator for linear convexifications.
OsiObject for auxiliary variables $w=f(x)$.
Class for MINLP problems with symbolic information.
Dependence graph.
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
constant-type operator
variable-type operator
virtual bool isInteger()
is this variable integer?
virtual CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
virtual void getBounds(expression *&, expression *&)
Get expressions of lower and upper bound of an expression (if any)
virtual void decreaseMult()
virtual enum nodeType Type() const
Node type.
virtual expression * Lb()
Get lower bound expression.
virtual CouNumber & ub()
Get/set upper bound value.
int varIndex_
The index of the variable.
virtual expression * simplify()
simplify
virtual enum auxSign sign() const
return its sign in the definition constraint
virtual exprVar * clone(Domain *d=NULL) const
Cloning method.
virtual bool isDefinedInteger()
is this expression defined as an integer?
virtual enum convexity convexity() const
either CONVEX, CONCAVE, AFFINE, or NONCONVEX
virtual void generateCuts(expression *w, OsiCuts &cs, const CouenneCutGenerator *cg, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
generate convexification cut for constraint w = this
virtual void crossBounds()
set bounds depending on both branching rules and propagated bounds.
virtual CouNumber & lb()
Get/set lower bound value.
virtual enum expr_type code()
code for comparison
virtual void linkDomain(Domain *d)
link this variable to a domain
virtual bool isFixed()
is this variable fixed?
virtual void zeroMult()
Disable variable (empty for compatibility with exprAux)
exprVar(const exprVar &e, Domain *d=NULL)
Copy constructor.
int Index() const
Get variable index in problem.
virtual void fillDepSet(std::set< DepNode *, compNode > *, DepGraph *)
update dependence set with index of this variable
virtual int Linearity()
get a measure of "how linear" the expression is (see CouenneTypes.hpp)
virtual void print(std::ostream &out=std::cout, bool=false) const
print
virtual int rank()
rank of an original variable is always one
virtual void generateCuts(OsiCuts &, const CouenneCutGenerator *, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
Get values of lower and upper bound of an expression (if any)
virtual void setInteger(bool value)
Set this variable as integer (empty for compatibility with exprAux)
virtual expression * Ub()
Get upper bound expression.
virtual CouNumber operator()()
return the value of the variable
virtual expression * differentiate(int index)
differentiation
virtual void getBounds(CouNumber &lb, CouNumber &ub)
Get value of lower and upper bound of an expression (if any)
exprVar(int varIndex, Domain *d=NULL)
Constructor.
Domain * domain_
Pointer to a descriptor of the current point/bounds.
virtual int DepList(std::set< int > &deplist, enum dig_type type=ORIG_ONLY)
fill in the set with all indices of variables appearing in the expression
virtual Domain * domain()
return pointer to variable domain
virtual bool impliedBound(int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign=expression::AUX_EQ)
implied bound processing
virtual CouenneObject * properObject(CouenneCutGenerator *c, CouenneProblem *p, Bonmin::BabSetupBase *base, JnlstPtr jnlst_)
return proper object to handle expression associated with this variable (NULL if this is not an auxil...
virtual ~exprVar()
destructor
Expression base class.
auxSign
"sign" of the constraint defining an auxiliary.
status of lower/upper bound of a variable, to be checked/modified in bound tightening
general include file for different compilers
nodeType
type of a node in an expression tree
Ipopt::SmartPtr< Ipopt::Journalist > JnlstPtr
dig_type
type of digging when filling the dependence list
double CouNumber
main number type in Couenne
Ipopt::SmartPtr< const Ipopt::Journalist > ConstJnlstPtr
convexity
convexity type of an expression
expr_type
code returned by the method expression::code()