Changeset 769 for stable/0.4


Ignore:
Timestamp:
Aug 26, 2011 12:08:18 PM (9 years ago)
Author:
pbelotti
Message:

merging fix for constant objective

Location:
stable/0.4
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • stable/0.4

    • Property svn:mergeinfo changed
      /trunkmerged: 768
  • stable/0.4/Couenne

  • stable/0.4/Couenne/src/branch

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • stable/0.4/Couenne/src/expression/operators/exprGroup.cpp

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • stable/0.4/Couenne/src/problem/CouenneProblem.hpp

    r728 r769  
    315315  enum TrilinDecompType trilinDecompType_;
    316316
     317  /// constant value of the objective if no variable is declared in it
     318  double constObjVal_;
     319
    317320 public:
    318321
     
    688691  Bonmin::BabSetupBase *bonBase () const {return bonBase_;}
    689692
     693  /// returns constant objective value if it contains no variables
     694  inline double constObjVal () const {return constObjVal_;}
     695
    690696protected:
    691697
  • stable/0.4/Couenne/src/problem/CouenneProblemConstructors.cpp

    r728 r769  
    7979  multilinSep_ (CouenneProblem::MulSepNone),
    8080  max_fbbt_iter_ (MAX_FBBT_ITER),
    81   orbitalBranching_ (false) {
     81  orbitalBranching_ (false),
     82  constObjVal_ (0.) {
    8283
    8384  double now = CoinCpuTime ();
     
    153154  multilinSep_  (p.multilinSep_),
    154155  max_fbbt_iter_  (p.max_fbbt_iter_),
    155   orbitalBranching_  (p.orbitalBranching_) {
     156  orbitalBranching_  (p.orbitalBranching_),
     157  constObjVal_       (p.constObjVal_) {
    156158
    157159  for (int i=0; i < p.nVars (); i++)
  • stable/0.4/Couenne/src/problem/CouenneSolverInterface.cpp

    r660 r769  
    7474  // printf (")\n");
    7575
    76   if (T::getObjValue () <= - Couenne_large_bound)
     76  if (getObjValue () <= - Couenne_large_bound)
    7777    knowDualInfeasible_ = true;
    7878
     
    140140  // printf (")\n");
    141141
    142   if (T::getObjValue () <= - Couenne_large_bound)
     142  if (getObjValue () <= - Couenne_large_bound)
    143143    knowDualInfeasible_ = true;
    144144
     
    151151  bool isChecked = false; 
    152152#ifdef FM_CHECKNLP2
    153   double curBestVal = 1e50;                                                   
     153  double curBestVal = 1.e50;
    154154  if(cutgen_->Problem()->getRecordBestSol()->getHasSol()) {
    155155    curBestVal =  cutgen_->Problem()->getRecordBestSol()->getVal();
     
    265265
    266266      if (csi -> isProvenOptimal () &&
    267           (fabs (csi -> getObjValue () - T::getObjValue ()) /
    268            (1. + fabs (csi -> getObjValue ()) + fabs (T::getObjValue ())) > 1e-2))
     267          (fabs (csi -> getObjValue () - getObjValue ()) /
     268           (1. + fabs (csi -> getObjValue ()) + fabs (getObjValue ())) > 1e-2))
    269269
    270270        printf ("Warning: discrepancy between cloned %g and current %g [%g]\n",
    271                 csi -> getObjValue (),  T::getObjValue (),
    272                 csi -> getObjValue () - T::getObjValue ());
     271                csi -> getObjValue (),  getObjValue (),
     272                csi -> getObjValue () - getObjValue ());
    273273    }
    274274
     
    306306  resolve();
    307307
    308   if (T::getObjValue () <= - Couenne_large_bound)
     308  if (getObjValue () <= - Couenne_large_bound)
    309309    knowDualInfeasible_ = true;
    310310
     
    324324}
    325325
    326 }
     326/// Get the objective function value. Modified due to possible
     327/// constant objectives passed to Couenne
     328template <class T>
     329inline double CouenneSolverInterface<T>::getObjValue() const {
     330  return cutgen_ -> Problem () -> constObjVal () + T::getObjValue();
     331}
     332
     333
     334}
  • stable/0.4/Couenne/src/problem/CouenneSolverInterface.hpp

    r560 r769  
    9595  //{return knowDualInfeasible_;}
    9696
     97  /// Get the objective function value. Modified due to possible
     98  /// constant objectives passed to Couenne
     99  virtual double getObjValue() const;
     100
    97101protected:
    98102
  • stable/0.4/Couenne/src/standardize/standardize.cpp

    r752 r769  
    180180    }
    181181
    182     exprAux *aux = (*i) -> standardize (this);
    183 
    184     if (jnlst_ -> ProduceOutput (J_ALL, J_REFORMULATE)) {
    185       printf (" objective "); (*i) -> print ();
    186       if (aux) {printf (" admits aux "); aux -> print ();}
    187     }
    188 
    189     if (aux) {
    190       //delete ((*i) -> Body ());
    191       (*i) -> Body (new exprClone (aux));
    192     }
    193 
    194     if (jnlst_ -> ProduceOutput (J_ALL, J_REFORMULATE)) {
    195       printf (". New obj: "); (*i) -> print (); printf ("\n");
     182    // check for constant objective
     183
     184    std::set <int> deplist;
     185
     186    if (0 == (*i) -> Body () -> DepList (deplist,  TAG_AND_RECURSIVE)) {
     187
     188      // This objective is constant. Store the value and use it in
     189      // CouenneSolverInterface.
     190
     191      constObjVal_ = (*i) -> Body () -> Value ();
     192
     193    } else {
     194
     195      exprAux *aux = (*i) -> standardize (this);
     196
     197      if (jnlst_ -> ProduceOutput (J_ALL, J_REFORMULATE)) {
     198        printf (" objective "); (*i) -> print ();
     199        if (aux) {printf (" admits aux "); aux -> print ();}
     200      }
     201
     202      if (aux) {
     203        //delete ((*i) -> Body ());
     204        (*i) -> Body (new exprClone (aux));
     205      }
     206
     207      if (jnlst_ -> ProduceOutput (J_ALL, J_REFORMULATE)) {
     208        printf (". New obj: "); (*i) -> print (); printf ("\n");
     209      }
    196210    }
    197211  }
Note: See TracChangeset for help on using the changeset viewer.