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

Go to the documentation of this file.
00001 /* $Id: exprVar.cpp 490 2011-01-14 16:07:12Z 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-10.
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #include "CouenneCutGenerator.hpp"
00012 #include "CouenneProblem.hpp"
00013 #include "CouenneObject.hpp"
00014 #include "CouenneExprAux.hpp"
00015 #include "CouenneExprVar.hpp"
00016 #include "CouenneExprBound.hpp"
00017 #include "CouenneDepGraph.hpp"
00018 
00019 using namespace Couenne;
00020 
00021 // Get lower and upper bound of a variable expression (if any)
00022 void exprVar::getBounds (expression *&lb, expression *&ub) {
00023 
00024   lb = new exprLowerBound (varIndex_, domain_); 
00025   ub = new exprUpperBound (varIndex_, domain_);
00026 }
00027 
00028 
00029 // Get value of lower and upper bound of a variable expression (if any)
00030 void exprVar::getBounds (CouNumber &lb, CouNumber &ub) {
00031 
00032   lb = domain_ -> lb (varIndex_);
00033   ub = domain_ -> ub (varIndex_);
00034 }
00035 
00036 
00037 // generate convexification cut for constraint w = this
00038 void exprVar::generateCuts (expression *w, //const OsiSolverInterface &si, 
00039                             OsiCuts &cs, const CouenneCutGenerator *cg, 
00040                             t_chg_bounds *chg, int,
00041                             CouNumber, CouNumber) {
00042   if (cg -> isFirst ())
00043     cg -> createCut (cs, 0., cg -> Problem () -> Var (w -> Index ()) -> sign (), w -> Index (), 1., varIndex_, -1);
00044 }
00045 
00046 
00049 bool exprVar::impliedBound (int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign sign) {
00050 
00051   bool res = false;
00052 
00053   if (updateBound (-1, l + varIndex_, sign == expression::AUX_GEQ ? -COIN_DBL_MAX : l [wind])) {res = true; chg [varIndex_].setLower(t_chg_bounds::CHANGED);}
00054   if (updateBound (+1, u + varIndex_, sign == expression::AUX_LEQ ?  COIN_DBL_MAX : u [wind])) {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 (CouenneCutGenerator *c,
00072                                       CouenneProblem *p, 
00073                                       Bonmin::BabSetupBase *base, 
00074                                       JnlstPtr jnlst_) {
00075   return new CouenneObject ();
00076 }

Generated on Thu Sep 22 03:05:57 2011 by  doxygen 1.4.7