CouenneComplObject.cpp
Go to the documentation of this file.
1 /* $Id: CouenneComplObject.cpp 694 2011-06-18 20:13:17Z stefan $
2  *
3  * Name: CouenneComplObject.cpp
4  * Authors: Pietro Belotti, Lehigh University
5  * Purpose: Implementation of branching rules for complementarity constraints
6  *
7  * (C) Carnegie-Mellon University, 2008-09.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include "CouenneComplObject.hpp"
13 
14 using namespace Ipopt;
15 using namespace Couenne;
16 
18 CouenneComplObject::CouenneComplObject (CouenneCutGenerator *c,
19  CouenneProblem *p,
20  exprVar *ref, Bonmin::BabSetupBase *base, JnlstPtr jnlst,
21  int sign):
22  CouenneObject (c, p, ref, base, jnlst),
23  sign_ (sign) {
24  jnlst -> Printf (J_DETAILED, J_BRANCHING,
25  "[created Complementarity constraint object with sign %d]\n", sign);
26 }
27 
28 
31  int sign):
32  CouenneObject (ref, base, jnlst),
33  sign_ (sign) {}
34 
35 
38  CouenneObject (src),
39  sign_ (src.sign_) {}
40 
41 
44 double CouenneComplObject::infeasibility (const OsiBranchingInformation *info, int &way) const {
45 
46  expression **arglist = reference_ -> Image () -> ArgList ();
47 
48  int index0 = arglist [0] -> Index (),
49  index1 = arglist [1] -> Index ();
50 
51  if (sign_) { // it is a xy <= 0 or a xy >= 0 object
52 
53  CouNumber
54  x0 = info -> solution_ [index0],
55  x1 = info -> solution_ [index1],
56  prod = x0*x1;
57 
58  if (sign_ < 0) {
59 
60  if (prod <= 0) return 0; // object feasible
61 
62  way = (x1<=x0); // zero if closer to second orthant (prefer to
63  // branch on "more feasible" variable)
64 
65  } else {
66 
67  if (prod >= 0) return 0; // object feasible
68 
69  way = (x1<=-x0); // zero if closer to second orthant (prefer to
70  // branch on "more feasible" variable)
71  }
72 
73  // if x1 < x0, it is preferrable to branch with x1=0 instead of x0=0
74  // as this is closer to the point
75  //way = (x1 < x0) ? 1 : 0;
76  return fabs (prod);
77 
78  } else { // it is a xy=0 object, use old infeasibility
79 
80  CouNumber
81  x0 = fabs (info -> solution_ [index0]),
82  x1 = fabs (info -> solution_ [index1]);
83 
84  // if x1 < x0, it is preferrable to branch with x1=0 instead of x0=0
85  // as this is closer to the point
86  way = (x1 < x0) ? 1 : 0;
87 
88  return x0 * x1;
89  }
90 }
91 
92 
95 double CouenneComplObject::checkInfeasibility (const OsiBranchingInformation * info) const {
96 
97  expression **arglist = reference_ -> Image () -> ArgList ();
98 
99  int index0 = arglist [0] -> Index (),
100  index1 = arglist [1] -> Index ();
101 
102  CouNumber
103  x0 = info -> solution_ [index0],
104  x1 = info -> solution_ [index1],
105  prod = x0*x1;
106 
107  if (!sign_)
108  return fabs (prod);
109  else return
110  ((sign_ < 0) && (prod >= 0)) ||
111  ((sign_ > 0) && (prod <= 0)) ? fabs (prod) : 0.;
112 }
113 
114 
117 OsiBranchingObject *CouenneComplObject::createBranch (OsiSolverInterface *solver,
118  const OsiBranchingInformation *info,
119  int way) const {
120 
121  expression **args = reference_ -> Image () -> ArgList ();
122 
123  /* printf ("creating CCobj: %d %d.%d\n", reference_ -> Index (),
124  args [0] -> Index (),
125  args [1] -> Index ());*/
126 
127  return new CouenneComplBranchingObject (solver, this, jnlst_,
128  cutGen_,
129  problem_,
130  args [0],
131  args [1],
132  way, 0, doFBBT_, doConvCuts_, sign_);
133 }
Cut Generator for linear convexifications.
virtual double infeasibility(const OsiBranchingInformation *info, int &way) const
compute infeasibility of this variable, |w - f(x)| (where w is the auxiliary variable defined as w = ...
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real fint fint fint fint * info
OsiObject for auxiliary variables $w=f(x)$.
exprVar * reference_
The (auxiliary) variable this branching object refers to.
OsiObject for complementarity constraints .
const Ipopt::EJournalCategory J_BRANCHING(Ipopt::J_USER1)
virtual double checkInfeasibility(const OsiBranchingInformation *info) const
compute infeasibility of this variable, |w - f(x)|, where w is the auxiliary variable defined as w = ...
bool doFBBT_
shall we do Feasibility based Bound Tightening (FBBT) at branching?
CouenneComplObject(CouenneCutGenerator *c, CouenneProblem *p, exprVar *ref, Bonmin::BabSetupBase *base, JnlstPtr jnlst, int sign)
Constructor with information for branching point selection strategy.
CouenneProblem * problem_
pointer to Couenne problem
ULong * x0
Definition: OSdtoa.cpp:1776
A class to have all elements necessary to setup a branch-and-bound.
ULong x1
Definition: OSdtoa.cpp:1776
bool doConvCuts_
shall we add convexification cuts at branching?
&quot;Spatial&quot; branching object for complementarity constraints.
Class for MINLP problems with symbolic information.
double CouNumber
main number type in Couenne
virtual OsiBranchingObject * createBranch(OsiSolverInterface *, const OsiBranchingInformation *, int way) const
create CouenneBranchingObject or CouenneThreeWayBranchObj based on this object
variable-type operator
CouenneCutGenerator * cutGen_
pointer to cut generator (not necessary, can be NULL)
Expression base class.
JnlstPtr jnlst_
SmartPointer to the Journalist.
int sign_
-1 if object is for xi * xj &lt;= 0 +1 if object is for xi * xj &lt;= 0 0 if object is for xi * xj = 0 (cla...
real c