/home/coin/SVN-release/OS-2.0.1/Couenne/src/expression/exprVar.cpp

Go to the documentation of this file.
00001 /* $Id: exprVar.cpp 156 2009-06-16 20:24:38Z pbelotti $ 
00002  *
00003  * Name:    exprVar.cpp
00004  * Author:  Pietro Belotti
00005  * Purpose: methods of the class for defining variables
00006  *
00007  * (C) Carnegie-Mellon University, 2006-08.
00008  * This file is licensed under the Common Public License (CPL)
00009  */
00010 
00011 #include "CouenneCutGenerator.hpp"
00012 #include "CouenneObject.hpp"
00013 #include "exprAux.hpp"
00014 #include "exprVar.hpp"
00015 #include "exprBound.hpp"
00016 #include "depGraph.hpp"
00017 
00018 
00019 // Get lower and upper bound of a variable expression (if any)
00020 void exprVar::getBounds (expression *&lb, expression *&ub) {
00021 
00022   lb = new exprLowerBound (varIndex_, domain_); 
00023   ub = new exprUpperBound (varIndex_, domain_);
00024 }
00025 
00026 
00027 // Get value of lower and upper bound of a variable expression (if any)
00028 void exprVar::getBounds (CouNumber &lb, CouNumber &ub) {
00029 
00030   lb = domain_ -> lb (varIndex_);
00031   ub = domain_ -> ub (varIndex_);
00032 }
00033 
00034 
00035 // generate convexification cut for constraint w = this
00036 void exprVar::generateCuts (expression *w, const OsiSolverInterface &si, 
00037                             OsiCuts &cs, const CouenneCutGenerator *cg, 
00038                             t_chg_bounds *chg, int,
00039                             CouNumber, CouNumber) {
00040   if (cg -> isFirst ())
00041     cg -> createCut (cs, 0., 0, w -> Index (), 1., varIndex_, -1);
00042 }
00043 
00044 
00047 bool exprVar::impliedBound (int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg) {
00048 
00049   bool res = false;
00050 
00051   if (updateBound (-1, l + varIndex_, l [wind])) 
00052     {res = true; chg [varIndex_].setLower(t_chg_bounds::CHANGED);}
00053   if (updateBound (+1, u + varIndex_, u [wind])) 
00054     {res = true; chg [varIndex_].setUpper(t_chg_bounds::CHANGED);}
00055 
00056   return res;
00057 }
00058 
00059 
00061 void exprVar::fillDepSet (std::set <DepNode *, compNode> *dep, DepGraph *g) 
00062 {dep -> insert (g -> lookup (varIndex_));}
00063 
00064 
00065 expression *exprVar::Lb () {return new exprLowerBound (varIndex_, domain_);}
00066 expression *exprVar::Ub () {return new exprUpperBound (varIndex_, domain_);}
00067 
00068 
00069 // dummy function -- the real one is in exprAux and returns either a
00070 // CouenneObject or a CouenneComplObject
00071 CouenneObject exprVar::properObject (CouenneProblem *p, 
00072                                       Bonmin::BabSetupBase *base, 
00073                                       JnlstPtr jnlst_) {
00074   return CouenneObject ();
00075 }

Generated on Thu Oct 8 03:02:56 2009 by  doxygen 1.4.7