Changeset 547


Ignore:
Timestamp:
May 22, 2007 11:40:41 AM (12 years ago)
Author:
pbelotti
Message:

added initial values to (original+aux) variables

Location:
branches/Couenne/Couenne
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/Couenne/Couenne/TODO

    r545 r547  
    22- trisection
    33- variable lhs/rhs of bounds containing expression defining aux vars
    4 - OBBT
    54- cut currValue_ from expressions
    65- documentation
  • branches/Couenne/Couenne/src/convex/generateCuts.cpp

    r545 r547  
    183183    genColCuts (si, cs, nchanged, changed);
    184184
     185  //#define USE_OBBT
    185186#ifdef USE_OBBT
    186187  if ((info.pass == 0) &&
  • branches/Couenne/Couenne/src/convex/obbt.cpp

    r545 r547  
    1212#include <CouenneProblem.h>
    1313
     14
     15/// reoptimize and change bound of a variable if needed
     16bool updateBound (OsiSolverInterface *csi, /// interface to use as a solver
     17                  int sense,               /// 1: minimize, -1: maximize
     18                  CouNumber &bound) {      /// bound to be updated
     19
     20  double opt;
     21
     22  csi -> setObjSense  (sense); // MINIMIZE
     23  csi -> resolve ();
     24
     25  if (csi -> isProvenOptimal () &&
     26      ((sense > 0) && ((opt = csi -> getObjValue ()) > bound + COUENNE_EPS)) ||
     27      ((sense < 0) && ((opt = csi -> getObjValue ()) < bound - COUENNE_EPS))) {
     28
     29    bound = opt;
     30    return true;
     31  }
     32  else return false;
     33}
    1434
    1535/// Optimality based bound tightening
     
    4363
    4464    // minimize and then maximize x_i on si.
    45     csi -> setObjSense  (1); // MINIMIZE
    46     csi -> resolve ();
    4765
    48     if (csi -> isProvenOptimal () &&
    49         ((opt = csi -> getObjValue ()) > problem_ -> Lb (i) + COUENNE_EPS)) {
    50 
    51       problem_ -> Lb (i) = opt;
    52       chg = true;
    53     }
    54 
    55     csi -> setObjSense (-1); // MAXIMIZE
    56     csi -> resolve ();
    57 
    58     if (csi -> isProvenOptimal () &&
    59         ((opt = csi -> getObjValue ()) < problem_ -> Ub (i) - COUENNE_EPS)) {
    60 
    61       problem_ -> Ub (i) = opt;
    62       chg = true;
    63     }
     66    chg = updateBound (csi,  1, problem_ -> Lb (i));
     67    chg = updateBound (csi, -1, problem_ -> Ub (i)) || chg;
    6468
    6569    if (chg) {
  • branches/Couenne/Couenne/src/problem/problemIO.cpp

    r545 r547  
    7171    if (ub_ [i] < + COUENNE_INFINITY - 1) f << " <= " << ub_ [i];
    7272    if (variables_ [i] -> isInteger ())   f << " integer";
    73     f << ';' << std::endl;
     73    f << " default " << x_ [i] << ';' << std::endl;
    7474  }
    7575
     
    7878
    7979  if (aux) {
     80
     81    initAuxs (x_, lb_, ub_);
    8082
    8183    f << std::endl << "# auxiliary variables" << std::endl << std::endl;
     
    9496        if ((bound = (*((*i) -> Ub ())) ()) <   COUENNE_INFINITY) f << " <= " << bound;
    9597        if ((*i) -> isInteger ()) f << " integer";
    96         f << ';' << std::endl;
     98        f << " default " << (*((*i) -> Image ())) () << ';' << std::endl;
    9799      }
    98100  }
     
    192194    }
    193195  }
     196  /*
     197  // initial values, original variables /////////////////////////////////////////////
     198
     199  f << std::endl << "# initial values, original" << std::endl << std::endl;
     200
     201  for (int i=0; i < nVars (); i++) {
     202
     203    f << "let ";
     204    variables_ [i] -> print (f);
     205    f << ".init0 := " << x_ [i] << ';' << std::endl;
     206  }
     207
     208  // initial values, auxiliary variables ////////////////////////////////////////////
     209
     210  if (aux) {
     211
     212    f << std::endl << "# initial values, auxiliary variables" << std::endl << std::endl;
     213
     214    for (std::vector <exprAux *>::iterator i = auxiliaries_.begin ();
     215         i != auxiliaries_.end ();
     216         i++)
     217
     218      if ((*i) -> Multiplicity () > 0) {
     219
     220        f << "let ";
     221        (*i) -> print (f, false, this);
     222        f << ".init0 := " << (*((*i) -> Image ())) () << ';' << std::endl;
     223      }
     224  }
     225  */
    194226}
Note: See TracChangeset for help on using the changeset viewer.