22 using namespace Couenne;
41 switch (term -> code ()) {
46 c0 += initCoe * term -> Value ();
50 lmap.
insert (term -> Index (), initCoe);
54 decomposeTerm (term -> Argument (), -initCoe, c0, lmap, qmap);
58 decomposeTerm (term -> ArgList () [0], initCoe, c0, lmap, qmap);
59 decomposeTerm (term -> ArgList () [1], -initCoe, c0, lmap, qmap);
69 for (exprQuad::sparseQ::iterator row = M.begin ();
70 row != M.end (); ++row) {
72 int xind = row -> first -> Index ();
74 for (exprQuad::sparseQcol::iterator col = row -> second.begin ();
75 col != row -> second.end (); ++col) {
76 qmap.
insert (xind, col -> first -> Index (), initCoe * col -> second);
89 for (
int n = lcoe.size (), i=0;
n--; i++)
90 lmap.
insert (lcoe [i].first -> Index (), initCoe * lcoe [i].second);
92 c0 += initCoe * t -> getc0 ();
98 for (
int i = term -> nArgs (); i--;)
109 std::map <int, CouNumber> indices;
116 printf (
"from flattenmul: [%g] ", coe);
117 for (std::map <int, CouNumber>::iterator itt = indices.begin ();
118 itt != indices.end(); ++itt)
126 switch (indices.size ()) {
134 std::map <int, CouNumber>::iterator one = indices.begin ();
135 int index = one -> first;
147 lmap.
insert (aux -> Index (), coe);
155 std::map <int, CouNumber>::iterator one = indices.begin (),
163 ind0 = aux -> Index ();
164 }
else ind0 = one -> first;
170 ind1 = aux -> Index ();
171 }
else ind1 = two -> first;
173 qmap.
insert (ind0, ind1, coe);
181 std::map <int, CouNumber>::iterator one = indices.begin ();
183 for (
int i=0; one != indices.end (); ++one, i++)
195 lmap.
insert (aux -> Index (), coe);
206 if (al [1] -> Type () !=
CONST) {
212 if (!aux) aux = term;
213 lmap.
insert (aux -> Index (), initCoe);
224 int ind = aux -> Index ();
226 if (fabs (expon - 1.) == 0.) lmap.
insert (ind, initCoe);
227 else if (fabs (expon - 2.) == 0.) qmap.
insert (ind, ind, initCoe);
231 lmap.
insert (aux2 -> Index (), initCoe);
241 lmap.
insert (aux -> Index (), initCoe);
class Group, with constant, linear and nonlinear terms:
std::vector< std::pair< exprVar *, sparseQcol > > sparseQ
Power of an expression (binary operator), with constant.
exprAux * addAuxiliary(expression *)
Add auxiliary variable and associate it with expression given as argument (used in standardization) ...
void insert(int indI, int indJ, CouNumber coe)
insert a pair <<int,int>,CouNumber> into a map for quadratic terms
void insert(int index, CouNumber coe)
insert a pair <int,CouNumber> into a map for linear terms
expression clone (points to another expression)
const Ipopt::EJournalCategory J_REFORMULATE(Ipopt::J_USER7)
exprVar * Var(int i) const
Return pointer to i-th variable.
bool standardize()
Break problem's nonlinear constraints in simple expressions to be convexified later.
void flattenMul(expression *mul, CouNumber &coe, std::map< int, CouNumber > &indices)
re-organizes multiplication and stores indices (and exponents) of its variables
std::vector< std::pair< exprVar *, CouNumber > > lincoeff
double CouNumber
main number type in Couenne
class exprQuad, with constant, linear and quadratic terms
JnlstPtr jnlst_
SmartPointer to the Journalist.
void decomposeTerm(expression *term, CouNumber initCoe, CouNumber &c0, LinMap &lmap, QuadMap &qmap)
given (expression *) element of sum, returns (coe,ind0,ind1) depending on element: ...
class for multiplications,