Changeset 269 for stable/0.2/Couenne


Ignore:
Timestamp:
Oct 22, 2009 10:04:26 AM (11 years ago)
Author:
pbelotti
Message:

merged changeset 268 (fix standardize bug)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stable/0.2/Couenne/src/standardize/constrStandardize.cpp

    r253 r269  
    8888      assert (p -> Var (wind) -> Type () == VAR);
    8989
    90       // create new variable, it has to be integer if original variable was integer
    91       exprAux *w = new exprAux (rest, wind, 1 + rest -> rank (),
    92                                 p -> Var (wind) -> isInteger () ?
    93                                 exprAux::Integer : exprAux::Continuous,
    94                                 p -> domain ());
     90      // check if constraint now reduces to w_k = x_h, and if so
     91      // replace all occurrences of x_k with x_h
    9592
    96       std::set <exprAux *, compExpr>::iterator i = p -> AuxSet () -> find (w);
     93      int xind = rest -> Index ();
    9794
    98       // no such expression found in the set:
    99       if (i == p -> AuxSet () -> end ()) {
     95      if (xind >= 0) {
     96        p -> auxiliarize (p -> Var (wind), p -> Var (xind));
     97        p -> Var (wind) -> zeroMult ();
     98      } else {
    10099
    101         p -> AuxSet      () -> insert (w); // 1) beware of useless copies
    102         p -> getDepGraph () -> insert (w); // 2) introduce it in acyclic structure
     100        // create new variable, it has to be integer if original variable was integer
     101        exprAux *w = new exprAux (rest, wind, 1 + rest -> rank (),
     102                                  p -> Var (wind) -> isInteger () ?
     103                                  exprAux::Integer : exprAux::Continuous,
     104                                  p -> domain ());
     105
     106        std::set <exprAux *, compExpr>::iterator i = p -> AuxSet () -> find (w);
     107
     108        // no such expression found in the set:
     109        if (i == p -> AuxSet () -> end ()) {
     110
     111          p -> AuxSet      () -> insert (w); // 1) beware of useless copies
     112          p -> getDepGraph () -> insert (w); // 2) introduce it in acyclic structure
    103113
    104114#ifdef DEBUG
    105         printf ("now replacing x [%d] with ", wind);
    106         w -> print (); printf (" := ");
    107         w -> Image () -> print (); printf ("\n");
     115          printf ("now replacing x [%d] with ", wind); fflush (stdout);
     116          w -> print (); printf (" := ");
     117          w -> Image () -> print (); printf ("\n");
    108118#endif
    109119
    110         // replace ALL occurrences of original variable (with index
    111         // wind) with newly created auxiliary
    112         p -> auxiliarize (w);
    113       }
     120          // replace ALL occurrences of original variable (with index
     121          // wind) with newly created auxiliary
     122          p -> auxiliarize (w);
     123        }
    114124
    115125#ifdef DEBUG
    116       else {
    117         printf ("found aux occurrence of ");
    118         w -> print (); printf (" := ");
    119         w -> Image () -> print (); printf (" ... ");
    120         (*i) -> print (); printf (" := ");
    121         (*i) -> Image () -> print (); printf ("\n");
     126        else {
     127          printf ("found aux occurrence of "); fflush (stdout);
     128          w -> print (); printf (" := ");
     129          w -> Image () -> print (); printf (" ... ");
     130          (*i) -> print (); printf (" := ");
     131          (*i) -> Image () -> print (); printf ("\n");
     132        }
     133#endif
    122134      }
    123 #endif
    124135
    125136      return NULL;
Note: See TracChangeset for help on using the changeset viewer.