00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "CouenneProblemElem.hpp"
00012 #include "CouenneProblem.hpp"
00013
00014 #include "exprAux.hpp"
00015 #include "depGraph.hpp"
00016
00017
00018
00020
00021 exprAux *CouenneConstraint::standardize (CouenneProblem *p) {
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifdef DEBUG
00031 printf ("################################\nStandardizing constraint: "); print ();
00032
00033 printf (" ["); fflush (stdout); lb_ -> print ();
00034 printf (","); fflush (stdout); ub_ -> print (); fflush (stdout);
00035
00036
00037
00038
00039
00040
00041 printf ("]\n");
00042 #endif
00043
00044 if (compareExpr (&lb_, &ub_) == 0) {
00045
00046
00047
00048
00049 expression *rest;
00050
00051
00052 int wind = p -> splitAux ((*lb_) (), body_, rest, p -> Commuted ());
00053
00054 if (wind >= 0) {
00055
00056 p -> Commuted () [wind] = true;
00057
00058 #ifdef DEBUG
00059 printf ("---> %d & ", wind); fflush (stdout);
00060 rest -> print (); printf ("\n");
00061 #endif
00062
00063 assert (p -> Var (wind) -> Type () == VAR);
00064
00065
00066 exprAux *w = new exprAux (rest, wind, 1 + rest -> rank (),
00067 p -> Var (wind) -> isInteger () ?
00068 exprAux::Integer : exprAux::Continuous,
00069 p -> domain ());
00070
00071 std::set <exprAux *, compExpr>::iterator i = p -> AuxSet () -> find (w);
00072
00073
00074 if (i == p -> AuxSet () -> end ()) {
00075
00076 p -> AuxSet () -> insert (w);
00077 p -> getDepGraph () -> insert (w);
00078
00079 #ifdef DEBUG
00080 printf ("now replacing x [%d] with ", wind);
00081 w -> print (); printf (" := ");
00082 w -> Image () -> print (); printf ("\n");
00083 #endif
00084
00085
00086
00087 p -> auxiliarize (w);
00088 }
00089
00090 #ifdef DEBUG
00091 else {
00092 printf ("found aux occurrence of ");
00093 w -> print (); printf (" := ");
00094 w -> Image () -> print (); printf (" ... ");
00095 (*i) -> print (); printf (" := ");
00096 (*i) -> Image () -> print (); printf ("\n");
00097 }
00098 #endif
00099
00100 return NULL;
00101 }
00102 }
00103
00104 #ifdef DEBUG
00105 printf ("\nnormal\n-----------------\n");
00106 #endif
00107
00108 return body_ -> standardize (p);
00109 }