exprVar.cpp
Go to the documentation of this file.
1 /* $Id: exprVar.cpp 490 2011-01-14 16:07:12Z pbelotti $
2  *
3  * Name: exprVar.cpp
4  * Author: Pietro Belotti
5  * Purpose: methods of the class for defining variables
6  *
7  * (C) Carnegie-Mellon University, 2006-10.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include "CouenneCutGenerator.hpp"
12 #include "CouenneProblem.hpp"
13 #include "CouenneObject.hpp"
14 #include "CouenneExprAux.hpp"
15 #include "CouenneExprVar.hpp"
16 #include "CouenneExprBound.hpp"
17 #include "CouenneDepGraph.hpp"
18 
19 using namespace Couenne;
20 
21 // Get lower and upper bound of a variable expression (if any)
23 
24  lb = new exprLowerBound (varIndex_, domain_);
25  ub = new exprUpperBound (varIndex_, domain_);
26 }
27 
28 
29 // Get value of lower and upper bound of a variable expression (if any)
31 
32  lb = domain_ -> lb (varIndex_);
33  ub = domain_ -> ub (varIndex_);
34 }
35 
36 
37 // generate convexification cut for constraint w = this
38 void exprVar::generateCuts (expression *w, //const OsiSolverInterface &si,
39  OsiCuts &cs, const CouenneCutGenerator *cg,
40  t_chg_bounds *chg, int,
42  if (cg -> isFirst ())
43  cg -> createCut (cs, 0., cg -> Problem () -> Var (w -> Index ()) -> sign (), w -> Index (), 1., varIndex_, -1);
44 }
45 
46 
49 bool exprVar::impliedBound (int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign sign) {
50 
51  bool res = false;
52 
53  if (updateBound (-1, l + varIndex_, sign == expression::AUX_GEQ ? -COIN_DBL_MAX : l [wind])) {res = true; chg [varIndex_].setLower(t_chg_bounds::CHANGED);}
54  if (updateBound (+1, u + varIndex_, sign == expression::AUX_LEQ ? COIN_DBL_MAX : u [wind])) {res = true; chg [varIndex_].setUpper(t_chg_bounds::CHANGED);}
55 
56  return res;
57 }
58 
59 
61 void exprVar::fillDepSet (std::set <DepNode *, compNode> *dep, DepGraph *g)
62 {dep -> insert (g -> lookup (varIndex_));}
63 
64 
67 
68 
69 // dummy function -- the real one is in exprAux and returns either a
70 // CouenneObject or a CouenneComplObject
72  CouenneProblem *p,
73  Bonmin::BabSetupBase *base,
74  JnlstPtr jnlst_) {
75  return new CouenneObject ();
76 }
Cut Generator for linear convexifications.
bool updateBound(register int sign, register CouNumber *dst, register CouNumber src)
updates maximum violation.
OsiObject for auxiliary variables $w=f(x)$.
virtual expression * Lb()
Get lower bound expression.
Definition: exprVar.cpp:65
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
void setLower(ChangeStatus lower)
Domain * domain_
Pointer to a descriptor of the current point/bounds.
virtual expression * Ub()
Get upper bound expression.
Definition: exprVar.cpp:66
void setUpper(ChangeStatus upper)
A class to have all elements necessary to setup a branch-and-bound.
virtual bool impliedBound(int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign=expression::AUX_EQ)
implied bound processing
Definition: exprVar.cpp:49
auxSign
&quot;sign&quot; of the constraint defining an auxiliary.
virtual CouNumber & ub()
Get/set upper bound value.
Class for MINLP problems with symbolic information.
virtual void getBounds(expression *&, expression *&)
Get expressions of lower and upper bound of an expression (if any)
Definition: exprVar.cpp:22
double CouNumber
main number type in Couenne
int Index() const
Get variable index in problem.
Dependence graph.
virtual enum auxSign sign() const
return its sign in the definition constraint
void fint fint fint real fint real real real real real real * g
Expression base class.
int varIndex_
The index of the variable.
void fint fint fint real fint real real real real real real real real * w
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...
Definition: exprVar.cpp:71
These are bound expression classes.
virtual void fillDepSet(std::set< DepNode *, compNode > *, DepGraph *)
update dependence set with index of this variable
Definition: exprVar.cpp:61
real c
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 CouNumber & lb()
Get/set lower bound value.