17 #include "CbcModel.hpp"
18 #include "CbcBranchActual.hpp"
19 #include "CbcCutGenerator.hpp"
20 #include "CbcCompareActual.hpp"
25 using namespace Couenne;
29 OsiSolverInterface *solver,
30 OsiObject **objects) {
37 for (std::vector <exprVar *>::const_iterator v =
variables_.begin ();
40 if (((*v) -> Type () ==
AUX) &&
41 ((*v) -> Multiplicity () > 0) &&
53 int wind = (*v) -> Index ();
69 if (fabs (cterm - 1.) <
COUENNE_EPS) {defVar =
false;}
70 else if (fabs (cterm + 1.) <
COUENNE_EPS) {defVar =
false; invertSOS =
true;}
82 size_t lsz = group -> lcoeff (). size ();
84 if (((lsz <= 2) && defVar) ||
85 ((lsz <= 1) && !defVar))
101 exprGroup::lincoeff::iterator l = lcoe. begin ();
103 for (;l != lcoe.
end (); ++l) {
105 if ((fabs (l -> second - (invertSOS ? -1. : 1.)) >
COUENNE_EPS) ||
116 onlyOrigVars =
false;
119 if (!isSOS || !intSOS)
129 indStart = defVar ? 0 : 1,
130 nelem = indStart + lcoe. size (),
131 *indices =
new int [nelem];
134 indices [0] = (*v) -> Index ();
136 for (
int i=indStart,
j=0; i<nelem; i++)
137 indices [i] = lcoe [
j++]. first -> Index ();
143 CbcSOS *newsos =
new CbcSOS (CbcModelPtr, nelem, indices, NULL, nSOS, 1);
145 objects [nSOS] = newsos;
147 newsos -> setPriority (10);
148 newsos -> setIntegerValued (intSOS);
154 jnlst_ -> Printf (Ipopt::J_ERROR,
J_COUENNE,
"%d SOS constraint%s found\n", nSOS, nSOS == 1 ?
"" :
"s");
class Group, with constant, linear and nonlinear terms:
int findSOS(CbcModel *CbcModelPtr, OsiSolverInterface *solver, OsiObject **objects)
find SOS constraints in problem
std::vector< exprVar * > variables_
Variables (original, auxiliary, and defined)
CouNumber * Ub() const
Return vector of upper bounds.
std::vector< std::pair< exprVar *, CouNumber > > lincoeff
double CouNumber
main number type in Couenne
int nOrigVars_
Number of original variables.
JnlstPtr jnlst_
SmartPointer to the Journalist.
const Ipopt::EJournalCategory J_COUENNE(Ipopt::J_USER8)
CouNumber * Lb() const
Return vector of lower bounds.
bool isInteger(CouNumber x)
is this number integer?