source: stable/0.2/Couenne/src/expression/exprVar.cpp @ 159

Last change on this file since 159 was 159, checked in by pbelotti, 11 years ago

created new stable branch 0.2 from trunk (rev. 157)

File size: 2.3 KB
Line 
1/* $Id: exprVar.cpp 156 2009-06-16 20:24:38Z 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-08.
8 * This file is licensed under the Common Public License (CPL)
9 */
10
11#include "CouenneCutGenerator.hpp"
12#include "CouenneObject.hpp"
13#include "exprAux.hpp"
14#include "exprVar.hpp"
15#include "exprBound.hpp"
16#include "depGraph.hpp"
17
18
19// Get lower and upper bound of a variable expression (if any)
20void exprVar::getBounds (expression *&lb, expression *&ub) {
21
22  lb = new exprLowerBound (varIndex_, domain_); 
23  ub = new exprUpperBound (varIndex_, domain_);
24}
25
26
27// Get value of lower and upper bound of a variable expression (if any)
28void exprVar::getBounds (CouNumber &lb, CouNumber &ub) {
29
30  lb = domain_ -> lb (varIndex_);
31  ub = domain_ -> ub (varIndex_);
32}
33
34
35// generate convexification cut for constraint w = this
36void exprVar::generateCuts (expression *w, const OsiSolverInterface &si, 
37                            OsiCuts &cs, const CouenneCutGenerator *cg, 
38                            t_chg_bounds *chg, int,
39                            CouNumber, CouNumber) {
40  if (cg -> isFirst ())
41    cg -> createCut (cs, 0., 0, w -> Index (), 1., varIndex_, -1);
42}
43
44
45/// implied bound processing. Expression w = x, upon change in lower
46/// or upper bound of w, whose index is wind
47bool exprVar::impliedBound (int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg) {
48
49  bool res = false;
50
51  if (updateBound (-1, l + varIndex_, l [wind])) 
52    {res = true; chg [varIndex_].setLower(t_chg_bounds::CHANGED);}
53  if (updateBound (+1, u + varIndex_, u [wind])) 
54    {res = true; chg [varIndex_].setUpper(t_chg_bounds::CHANGED);}
55
56  return res;
57}
58
59
60/// update dependence set with index of this variable
61void exprVar::fillDepSet (std::set <DepNode *, compNode> *dep, DepGraph *g) 
62{dep -> insert (g -> lookup (varIndex_));}
63
64
65expression *exprVar::Lb () {return new exprLowerBound (varIndex_, domain_);}///< lower bound
66expression *exprVar::Ub () {return new exprUpperBound (varIndex_, domain_);}///< upper bound
67
68
69// dummy function -- the real one is in exprAux and returns either a
70// CouenneObject or a CouenneComplObject
71CouenneObject exprVar::properObject (CouenneProblem *p, 
72                                      Bonmin::BabSetupBase *base, 
73                                      JnlstPtr jnlst_) {
74  return CouenneObject ();
75}
Note: See TracBrowser for help on using the repository browser.