Changeset 526


Ignore:
Timestamp:
Apr 30, 2007 2:01:34 PM (12 years ago)
Author:
pbonami
Message:

Transmit time limit to Ipopt

Location:
stable/0.1/Bonmin/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable/0.1/Bonmin/src/CbcBonmin/CbcBonmin.cpp

    r470 r526  
    6969}
    7070
    71 
     71double GlobalTimeEnd;
    7272/** Constructor.*/
    7373BonminBB::BonminBB():
     
    9696  OsiSolverInterface * si;
    9797
     98  GlobalTimeEnd = CoinCpuTime() + par.maxTime;
    9899
    99100  nlpSolver.messageHandler()->setLogLevel(par.nlpLogLevel);
     
    401402  CbcBranchUserDecision branch;
    402403  model.setBranchingMethod(&branch);
    403 
     404  TMINLP::SolverReturn status;
     405
     406  if(CoinCpuTime() > GlobalTimeEnd){
     407    model.findIntegers(true);
     408    status = TMINLP::LIMIT_EXCEEDED;
     409    mipStatus_ = NoSolutionKnown;
     410  }
     411  else {
    404412  //Get the time and start.
    405413  model.initialSolve();
    406 
    407414  continuousRelaxation_ =model.solver()->getObjValue();
    408415  if(par.algo == 0)//Set warm start point for Ipopt
     
    465472    CoinCopyN(model.bestSolution(), nlpSolver.getNumCols(), bestSolution_);
    466473  }
    467   TMINLP::SolverReturn status;
    468474  if(model.status()==0) {
    469475    if(bestSolution_){
     
    485491  else if (model.status()==2){
    486492    status = TMINLP::MINLP_ERROR;
     493  }
    487494  }
    488495
  • stable/0.1/Bonmin/src/IpoptInterface/TMINLP2TNLP.cpp

    r24 r526  
    1717#include <fstream>
    1818#include <sstream>
     19
     20#include "CoinTime.hpp"
     21
     22extern double GlobalTimeEnd;
     23
    1924namespace Ipopt
    2025{
     
    442447      IpoptCalculatedQuantities* ip_cq)
    443448  {
    444     // If we don't have this swtiched on, we assume that also the
    445     // "warm_start" option for bonmin is set not to refer to the
    446     // interior warm start object
    447     if (!warm_start_entire_iterate_) {
    448       return true;
    449     }
    450 
    451     if (need_new_warm_starter_) {
    452       // Create a new object for later warm start information
    453       curr_warm_starter_ = new IpoptInteriorWarmStarter(n_, x_l_, x_u_,
    454           nlp_lower_bound_inf_,
    455           nlp_upper_bound_inf_,
    456           warm_start_entire_iterate_);
    457       need_new_warm_starter_ = false;
    458     }
    459 
    460     return curr_warm_starter_->UpdateStoredIterates(mode, *ip_data, *ip_cq);
    461   }
    462 
     449    if(CoinCpuTime() > GlobalTimeEnd) return false;
     450    else {
     451      // If we don't have this swtiched on, we assume that also the
     452      // "warm_start" option for bonmin is set not to refer to the
     453      // interior warm start object
     454      if (!warm_start_entire_iterate_) {
     455        return true;
     456      }
     457 
     458      if (need_new_warm_starter_) {
     459        // Create a new object for later warm start information
     460        curr_warm_starter_ = new IpoptInteriorWarmStarter(n_, x_l_, x_u_,
     461            nlp_lower_bound_inf_,
     462            nlp_upper_bound_inf_,
     463            warm_start_entire_iterate_);
     464        need_new_warm_starter_ = false;
     465      }
     466
     467      return curr_warm_starter_->UpdateStoredIterates(mode, *ip_data, *ip_cq);
     468    }
     469  }
    463470
    464471  /** Procedure to ouptut relevant informations to reproduce a sub-problem.
Note: See TracChangeset for help on using the changeset viewer.