21 using namespace Couenne;
29 if (
graph_ && subst && aux -> Index () != subst -> Index ())
30 graph_ -> replaceIndex (aux -> Index (), subst -> Index ());
33 printf (
"replacing ");
if (aux) aux ->
print ();
34 if (subst) {printf (
" with "); subst ->
print ();}
38 bool same_var = (subst == NULL);
45 int index = aux -> Index ();
49 std::vector <exprVar *>::iterator orig;
54 if ((((*orig) -> Type () ==
VAR) || !same_var) &&
55 ((*orig) -> Index () == index))
62 printf (
"CouenneProblem::auxiliarize: no original variables correspond\n");
68 for (std::vector <expression *>::iterator i =
commonexprs_.begin ();
76 printf (
"replacing within common expression [%d]: ", i -
commonexprs_.begin ()); fflush (stdout); (*i) ->
print (); printf (
"\n");
79 if ((body -> Type () ==
VAR) ||
80 (body -> Type () ==
AUX)) {
82 if (body -> Index () == (*orig) -> Index ()) {
87 }
else body ->
replace (*orig, subst);
93 for (std::vector <CouenneObjective *>::iterator i =
objectives_.begin ();
101 printf (
"replacing within objective: "); fflush (stdout); (*i) ->
print ();
104 if ((body -> Type () ==
VAR) ||
105 (body -> Type () ==
AUX)) {
107 if (body -> Index () == (*orig) -> Index ()) {
112 }
else body ->
replace (*orig, subst);
118 for (std::vector <CouenneConstraint *>::iterator i =
constraints_.begin ();
126 printf (
"replacing within constraint [%d]: ", i -
constraints_.begin ()); fflush (stdout); (*i) ->
print ();
129 if ((body -> Type () ==
VAR) ||
130 (body -> Type () ==
AUX)) {
132 if (body -> Index () == (*orig) -> Index ()) {
137 }
else body ->
replace (*orig, subst);
143 for (std::vector <exprVar *>::iterator i =
variables_.begin ();
146 if (((*i) -> Type () ==
AUX) &&
147 ((*i) -> Multiplicity () > 0) &&
148 ((*i) -> Index () != (*orig) -> Index ())) {
151 printf (
"replacing aux "); fflush (stdout); (*i) ->
print ();
152 printf (
" := "); fflush (stdout); (*i) -> Image () ->
print ();
158 if ((image -> Type () ==
VAR) ||
159 (image -> Type () ==
AUX)) {
161 if (image -> Index () == (*orig) -> Index ()) {
167 }
else image ->
replace (*orig, subst);
std::vector< CouenneObjective * > objectives_
Objectives.
DepGraph * graph_
Dependence (acyclic) graph: shows dependence of all auxiliary variables on one another and on origina...
void print(std::ostream &=std::cout)
Display current representation of problem: objective, linear and nonlinear constraints, and auxiliary variables.
void replace(CouenneProblem *p, int wind, int xind)
std::vector< expression * > commonexprs_
AMPL's common expressions (read from AMPL through structures cexps and cexps1)
std::vector< CouenneConstraint * > constraints_
Constraints.
expression clone (points to another expression)
const Ipopt::EJournalCategory J_REFORMULATE(Ipopt::J_USER7)
std::vector< exprVar * > variables_
Variables (original, auxiliary, and defined)
JnlstPtr jnlst_
SmartPointer to the Journalist.
void auxiliarize(exprVar *, exprVar *=NULL)
Replace all occurrences of original variable with new aux given as argument.