Changeset 1058


Ignore:
Timestamp:
Feb 1, 2014 8:50:36 AM (6 years ago)
Author:
pbelotti
Message:

making the FP a little more robust. Small fixes

Location:
trunk/Couenne/src/heuristics
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/heuristics/CouenneFPSolveMILP.cpp

    r1011 r1058  
    3535  if( SCIPisInfinity(scip, val) && val < infinity)
    3636    problem_ -> Jnlst () -> Printf (Ipopt::J_WARNING, J_NLPHEURISTIC,
    37                                     "Warning: %g will be considered to be Infinity by SCIP.\n");
     37                                    "Warning: %g will be considered to be Infinity by SCIP.\n", val);
    3838}
    3939#endif
  • trunk/Couenne/src/heuristics/CouenneFPSolveNLP.cpp

    r1011 r1058  
    9797    else nSol = CoinCopyOfArray (nlp_ -> getSolution (), problem_ -> nVars ());
    9898
    99   else problem_ -> Jnlst () -> Printf
    100       (J_WARNING, J_NLPHEURISTIC, "FP: warning, NLP returns a NULL solution\n");
     99  else problem_ -> Jnlst () -> Printf (J_WARNING, J_NLPHEURISTIC, "FP: warning, NLP returns a NULL solution\n");
    101100
    102101  if (nlp_ -> getSolution () && (problem_ -> Jnlst () -> ProduceOutput (J_ALL, J_NLPHEURISTIC))) { // check if non-NULL
  • trunk/Couenne/src/heuristics/CouenneFPpool.cpp

    r1011 r1058  
    135135    case SUM_NINF:     return (nNLinf_   + nIinf_   < other.nNLinf_   + other.nIinf_);
    136136    case SUM_INF:      return (maxNLinf_ + maxIinf_ < other.maxNLinf_ + other.maxIinf_);
    137     case OBJVAL:       return (objVal_              < other.objVal_);
     137    case OBJVAL:       return (objVal_              < other.objVal_ - COUENNE_EPS * CoinMax (1., CoinMax (objVal_, other.objVal_)));
     138    // so that if objective is close these two solutions will be deemed equal
     139
    138140    case ALL_VARS: {
    139141      // lexicographical comparison: unless the two solutions have the
     
    142144      for (std::vector <exprVar *>::iterator i = problem_ -> Variables (). begin ();
    143145           i != problem_ -> Variables (). end ();
    144            ++i) {
    145 
    146         int indVar = (*i) -> Index ();
    147 
    148         if (((*i) -> Multiplicity () > 0) &&
    149             (x_ [indVar] < other.x_ [indVar] - COUENNE_EPS))
    150 
    151           return true;
    152       }
     146           ++i)
     147
     148        if ((*i) -> Multiplicity () > 0) {
     149
     150          int indVar = (*i) -> Index ();
     151
     152          if (x_ [indVar] < other.x_ [indVar] - COUENNE_EPS)
     153            return true;
     154        }
    153155
    154156      return false;
    155157    }
     158
    156159    case INTEGER_VARS: {
    157160
     
    161164      for (std::vector <exprVar *>::iterator i = problem_ -> Variables (). begin ();
    162165           i != problem_ -> Variables (). end ();
    163            ++i) {
    164 
    165         int indVar = (*i) -> Index ();
    166 
    167         if (((*i) -> Multiplicity () > 0) &&
    168             ((*i) -> isInteger ())        &&
    169             (x_ [indVar] < other.x_ [indVar] - COUENNE_EPS))
    170 
    171           return true;
    172       }
     166           ++i)
     167
     168        if (((*i) -> Multiplicity () > 0) &&
     169            (*i) -> isInteger ()) {
     170
     171          int indVar = (*i) -> Index ();
     172       
     173          if (x_ [indVar] < other.x_ [indVar] - COUENNE_EPS)
     174            return true;
     175        }
    173176
    174177      return false;
  • trunk/Couenne/src/heuristics/CouenneFPscipSolve.cpp

    r1011 r1058  
    159159      if (problem_ -> Var (j) -> isInteger () &&
    160160          problem_ -> Var (j) -> Multiplicity () > 0 &&
    161           problem_ -> Ub (j) - problem_ -> Lb (j) > .5) {
     161          problem_ -> Ub  (j) - problem_ -> Lb (j) > .5) {
    162162
    163163        // if (fabs (x [j] - floor (x [j] + .5)) >= SCIPfeastol (scip)) {
     
    167167        assert (fabs (lbs [j] - problem_ -> Lb (j)) < SCIPfeastol (scip));
    168168        assert (fabs (ubs [j] - problem_ -> Ub (j)) < SCIPfeastol (scip));
    169         assert (fabs (x [j] - floor (x [j] + .5))   < 1e3 * SCIPfeastol (scip));
     169        assert (fabs (x [j] - floor (x [j] + .5))   < SCIPfeastol (scip) * 1.e3);
    170170
    171171        assert (nEntries <= 2*nvars - 2);
     
    252252    currentmilpmethod = milpMethod_; // use a fixed method to solve the MILP
    253253
    254      
    255254  // MILP solving loop. If the MILP terminates without a solution, it might get resolved with a more expensive atrategy
    256255  do {
  • trunk/Couenne/src/heuristics/CouenneFeasPump.cpp

    r1057 r1058  
    103103  // and set it as initial (obviously NLP feasible) solution
    104104
    105   nlp_ -> setInitSol (problem_ -> domain () -> x ());
     105  nlp_ -> setInitSol (sol);
    106106
    107107  ////////////////////////////////////////////////////////////////
     
    232232    // l-1 distance from. If nSol==NULL, the MILP is created using the
    233233    // original milp's LP solution.
     234
     235    bool bad_IP_sol = false;
    234236           
    235237    double z = solveMILP (nSol, iSol, niter, &nsuciter);
     
    258260        }
    259261      }
     262
     263      if (!try_again) { // try moving around current solution
     264
     265        bad_IP_sol = true;
     266
     267        // SCIP could not find a MILP solution and we're somewhat
     268        // locked. Round current solution and feed it to the NLP. This
     269        // is better than just bailing out.
     270
     271        int n = problem_ -> nVars ();
     272
     273        if (!iSol)
     274          iSol = new double [n];
     275
     276        for (int i=0; i<n; i++)
     277          iSol [i] = (problem_ -> Var (i) -> isInteger ()) ?
     278            COUENNE_round (nSol [i]) :
     279            nSol [i];
     280      }
    260281 
    261       if (!try_again) { // nothing to do, bail out
    262        
    263         problem_ -> Jnlst () -> Printf (J_WARNING, J_NLPHEURISTIC, "FP: could not find from pool either, bailing out\n");
    264         break;
    265       }
     282      // if (!try_again) { // nothing to do, bail out   
     283      //        problem_ -> Jnlst () -> Printf (J_WARNING, J_NLPHEURISTIC, "FP: could not find from pool either, bailing out\n");
     284      //        break;
     285      // }
    266286    }
    267287
     
    277297    CouenneFPsolution checkedSol (problem_, iSol, false); // false is for not allocating space for this
    278298
    279     if (tabuPool_. find (checkedSol) == tabuPool_ . end ()) 
     299    if (tabuPool_. find (checkedSol) == tabuPool_ . end ())
    280300
    281301      tabuPool_. insert (CouenneFPsolution (problem_, iSol)); // only insertion to tabu pool: we check its feasibility now
     
    452472        }
    453473
     474        // ONLY do the following if we didn't get a good IP solution
     475        // earlier (i.e. if we had to round)
     476
    454477        // find non-tabu solution in the solution pool
    455         while (!pool_ -> Set (). empty ()) {
    456 
    457           // EXTRACT the closest (to nSol) IP solution from the pool
    458           pool_ -> findClosestAndReplace (iSol, nSol, problem_ -> nVars ());
    459 
    460           CouenneFPsolution newSol (problem_, iSol);
    461 
    462           // we found a solution that is not in the tabu list
    463           if (tabuPool_ . find (newSol) == tabuPool_ . end ()) {
    464             try_again = true;
    465             break;
    466           }
    467         }
     478        if (bad_IP_sol)
     479          while (!pool_ -> Set (). empty ()) {
     480
     481            // EXTRACT the closest (to nSol) IP solution from the pool
     482            pool_ -> findClosestAndReplace (iSol, nSol, problem_ -> nVars ());
     483
     484            CouenneFPsolution newSol (problem_, iSol);
     485
     486            // we found a solution that is not in the tabu list
     487            if (tabuPool_ . find (newSol) == tabuPool_ . end ()) {
     488              try_again = true;
     489              break;
     490            }
     491          }
    468492
    469493      } while (try_again);
     
    536560
    537561        // Update lb/ub on milp and nlp here
    538         const CouNumber 
     562        const CouNumber
    539563          *plb = problem_ -> Lb (),
    540564          *pub = problem_ -> Ub (),
  • trunk/Couenne/src/heuristics/CouenneFeasPump.hpp

    r1025 r1058  
    155155    {return nlp_;}
    156156
    157     /// return number of calls (can be changeD)
     157    /// return number of calls (can be changed)
    158158    int &nCalls ()
    159159    {return nCalls_;}
     160
     161    /// MILP phase of the FP
     162    int milpPhase (double *nSol, double *iSol);
     163
     164    /// NLP phase of the FP
     165    int nlpPhase (double *iSol, double *nSol);
    160166
    161167#ifdef COIN_HAS_SCIP
  • trunk/Couenne/src/heuristics/CouenneFeasPumpConstructors.cpp

    r1032 r1058  
    521521  roptions -> AddBoundedIntegerOption
    522522    ("feas_pump_nseprounds",
    523      "Number of rounds that separate convexification cuts. Must be at least 1",
     523     "Number of rounds of convexification cuts. Must be at least 1",
    524524     1, 1e5, 4,
    525525     "");
     
    555555    ("feas_pump_poolcomp",
    556556     "Priority field to compare solutions in FP pool",
    557      0, 2, 0,
    558        "0: total number of infeasible objects (integer and nonlinear), 1: maximum infeasibility (integer or nonlinear), 2: objective value.");
    559 }
     557     0, 4, 4,
     558       "\
     5590: total number of infeasible objects (integer and nonlinear); \
     5601: maximum infeasibility (integer or nonlinear); \
     5612: objective value; \
     5623: compare value of all variables; \
     5634: compare value of all integers.");
     564}
Note: See TracChangeset for help on using the changeset viewer.