/home/coin/SVN-release/OS-2.0.0/Couenne/src/branch/CouenneComplObject.cpp

Go to the documentation of this file.
00001 /* $Id: CouenneComplObject.cpp 155 2009-06-16 20:19:39Z pbelotti $
00002  *
00003  * Name:    CouenneComplObject.cpp
00004  * Authors: Pietro Belotti, Lehigh University
00005  * Purpose: Implementation of branching rules for complementarity constraints
00006  *
00007  * (C) Carnegie-Mellon University, 2008.
00008  * This file is licensed under the Common Public License (CPL)
00009  */
00010 
00011 #include "CouenneComplObject.hpp"
00012 #include "CouenneComplBranchingObject.hpp"
00013 
00014 
00016 CouenneComplObject::CouenneComplObject (CouenneProblem *p, 
00017                                         exprVar *ref, Bonmin::BabSetupBase *base, JnlstPtr jnlst):
00018   CouenneObject (p, ref, base, jnlst) {
00019   jnlst -> Printf (J_DETAILED, J_PROBLEM, "[created Complementarity constraint object]\n");
00020 }
00021 
00022 
00024 CouenneComplObject::CouenneComplObject (exprVar *ref, Bonmin::BabSetupBase *base, JnlstPtr jnlst):
00025   CouenneObject (ref, base, jnlst) {}
00026 
00027 
00029 CouenneComplObject::CouenneComplObject (const CouenneObject &src): 
00030   CouenneObject (src) {}
00031     
00032 
00035 double CouenneComplObject::infeasibility (const OsiBranchingInformation *info, int &way) const {
00036 
00037   expression **arglist = reference_ -> Image () -> ArgList ();
00038 
00039   int index0 = arglist [0] -> Index (),
00040       index1 = arglist [1] -> Index ();
00041 
00042   CouNumber 
00043     x0 = fabs (info -> solution_ [index0]),
00044     x1 = fabs (info -> solution_ [index1]);
00045 
00046   // if x1 < x0, it is preferrable to branch with x1=0 instead of x0=0
00047   // as this is closer to the point
00048   way = (x1 < x0) ? 1 : 0;
00049 
00050   return x0 * x1;
00051 }
00052 
00053 
00056 double CouenneComplObject::checkInfeasibility (const OsiBranchingInformation * info) const {
00057 
00058   expression **arglist = reference_ -> Image () -> ArgList ();
00059 
00060   int index0 = arglist [0] -> Index (),
00061       index1 = arglist [1] -> Index ();
00062 
00063   return 
00064     fabs (info -> solution_ [index0]) * 
00065     fabs (info -> solution_ [index1]);
00066 }
00067 
00068 
00071 OsiBranchingObject *CouenneComplObject::createBranch (OsiSolverInterface *solver, 
00072                                                       const OsiBranchingInformation *info, 
00073                                                       int way) const {
00074 
00075   expression **args = reference_ -> Image () -> ArgList ();
00076 
00077   /*  printf ("creating CCobj: %d %d.%d\n", reference_ -> Index (), 
00078           args [0] -> Index (),
00079           args [1] -> Index ());*/
00080 
00081   return new CouenneComplBranchingObject (solver, this, jnlst_,
00082                                           args [0],
00083                                           args [1], 
00084                                           way, 0, doFBBT_, doConvCuts_);
00085 }

Generated on Mon Aug 3 03:02:19 2009 by  doxygen 1.4.7