Changeset 67


Ignore:
Timestamp:
Oct 16, 2006 11:05:15 PM (13 years ago)
Author:
pbonami
Message:

Update for including the interface for filter.
Everything compiles but not tested yet.
To compile filter interface has to specify --with-filtersqp-lib and with-filtersqp-incdir to point to correct location.

Location:
branches/devel/Bonmin
Files:
3 added
2 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Bonmin/examples/CppExample/Makefile.in

    r1 r67  
    6060        `cat $(COINLIBDIR)/osi_addlibs.txt` \
    6161        `cat $(COINLIBDIR)/clp_addlibs.txt` \
    62         `cat $(COINLIBDIR)/coinutils_addlibs.txt` \
    63         @ASLLIB@
     62        `cat $(COINLIBDIR)/coinutils_addlibs.txt`
    6463
    6564# Necessary Include dirs
    6665INCL = -I`$(CYGPATH_W) $(COININCDIR)` \
    6766        -I`$(CYGPATH_W) $(COININCDIR)/ipopt` \
    68         -I`$(CYGPATH_W) $(SRCDIR)/BonminAmplInterface/` \
    6967        $(ADDINCFLAGS)
    7068
  • branches/devel/Bonmin/examples/CppExample/MyBonmin.cpp

    r58 r67  
    1818#include "CoinTime.hpp"
    1919
    20 #include "BonIpoptInterface.hpp"
     20#include "BonOsiTMINLPInterface.hpp"
     21#include "BonIpoptSolver.hpp"
    2122#include "MyTMINLP.hpp"
    2223#include "BonCbc.hpp"
     
    2728{
    2829  using namespace Ipopt;
     30  using namespace Bonmin;
    2931  SmartPtr<TMINLP> tminlp = new MyTMINLP;
    30   IpoptInterface nlpSolver(tminlp);
     32  OsiTMINLPInterface nlpSolver(tminlp, new IpoptSolver);
    3133 
    3234  //Option can be set here directly either to bonmin or ipopt
     
    7274
    7375  }
    74   catch(IpoptInterface::UnsolvedError *E) {
     76  catch(TNLPSolver::UnsolvedError *E) {
    7577    //There has been a failure to solve a problem with Ipopt.
    7678    std::cerr<<"Ipopt has failed to solve a problem"<<std::endl;
    7779  }
    78   catch(IpoptInterface::SimpleError &E) {
     80  catch(OsiTMINLPInterface::SimpleError &E) {
    7981    std::cerr<<E.className()<<"::"<<E.methodName()
    8082             <<std::endl
  • branches/devel/Bonmin/src/Apps/BonMin.cpp

    r57 r67  
    3131
    3232*/
    33 void writeNodeFiles(const OsiSolverInterface& si1,const IpoptInterface& si2)
     33void writeNodeFiles(const OsiSolverInterface& si1,const OsiTMINLPInterface& si2)
    3434{
    3535  const int numcols = si1.getNumCols();
     
    8888
    8989
    90     const IpoptInterface * ipopt = dynamic_cast<const IpoptInterface *>(&si1);
    91     assert(ipopt);
    92 
    93     const double * primals = ipopt->problem()->x_init();
    94     const double * duals = ipopt->problem()->duals_init();
     90    const OsiTMINLPInterface* nlpSolver = dynamic_cast<const OsiTMINLPInterface *>(&si1);
     91    assert(nlpSolver);
     92
     93    const double * primals = nlpSolver->problem()->x_init();
     94    const double * duals = nlpSolver->problem()->duals_init();
    9595
    9696    if(!primals)//No starting point no output
     
    172172
    173173  }
    174   catch(IpoptInterface::UnsolvedError *E) {
     174  catch(TNLPSolver::UnsolvedError *E) {
    175175     E->printError(std::cerr);
    176176    //There has been a failure to solve a problem with Ipopt.
     
    180180    writeNodeFiles(*nlpSolver, *nlpSolver);
    181181  }
    182   catch(IpoptInterface::SimpleError &E) {
     182  catch(OsiTMINLPInterface::SimpleError &E) {
    183183    std::cerr<<E.className()<<"::"<<E.methodName()
    184184             <<std::endl
  • branches/devel/Bonmin/src/Apps/nodeSolver.cpp

    r57 r67  
    7676      }
    7777     
    78       nlpSolver.turnOnIpoptOutput();
     78      nlpSolver.solver()->turnOnOutput();
    7979      nlpSolver.initialSolve();
    8080     
  • branches/devel/Bonmin/src/BonminAmplInterface/BonAmplInterface.cpp

    r62 r67  
    77{
    88  /** Default constructor */
    9   AmplInterface::AmplInterface(): IpoptInterface(), amplTminlp_(NULL)
     9  AmplInterface::AmplInterface(): OsiTMINLPInterface(), amplTminlp_(NULL)
    1010  {}
    1111
    1212  /** Constructor with inputed ampl command line (reads model from nl file)*/
    13   AmplInterface::AmplInterface(char **& amplArgs)
     13  AmplInterface::AmplInterface(char **& amplArgs, SmartPtr<TNLPSolver> app)
    1414      :
    15       IpoptInterface(),
     15      OsiTMINLPInterface(),
    1616      amplTminlp_(NULL)
    1717  {
    18     readAmplNlFile(amplArgs, NULL, NULL);
     18    readAmplNlFile(amplArgs, NULL, NULL, app);
    1919  }
    2020
    2121  /** Copy constructor */
    2222  AmplInterface::AmplInterface(const AmplInterface &other):
    23       IpoptInterface(other), amplTminlp_(NULL)
     23      OsiTMINLPInterface(other), amplTminlp_(NULL)
    2424  {
    2525    amplTminlp_ = dynamic_cast<Bonmin::AmplTMINLP *> (GetRawPtr(tminlp_));
     
    4242  AmplInterface::readAmplNlFile(char**& filename,
    4343      std::string* ipopt_file_content,
    44       std::string* nl_file_content)
     44      std::string* nl_file_content,
     45      Ipopt::SmartPtr<TNLPSolver> app)
    4546  {
    4647
    4748
    4849
    49     app_ = new IpoptSolver;
     50    app_ = app->createNew();
    5051
    5152    SmartPtr<RegisteredOptions> roptions = app_->RegOptions();
  • branches/devel/Bonmin/src/BonminAmplInterface/BonAmplInterface.hpp

    r62 r67  
    11#ifndef BonminAmplInterface_H
    22#define BonminAmplInterface_H
    3 #include "BonIpoptInterface.hpp"
     3#include "BonOsiTMINLPInterface.hpp"
    44#include "BonAmplTMINLP.hpp"
     5#include "BonIpoptSolver.hpp"
    56
    67namespace Bonmin
    78{
    89  /** Class for providing an Osi interface to Ipopt with an ampl nl file as input. */
    9   class AmplInterface: public IpoptInterface
     10  class AmplInterface: public OsiTMINLPInterface
    1011  {
    1112  public:
     
    1314    AmplInterface();
    1415    /** Constructor with inputed ampl command line (reads model from nl file)*/
    15     AmplInterface(char **& amplArgs);
     16    AmplInterface(char **& amplArgs, Ipopt::SmartPtr<TNLPSolver> app = new IpoptSolver);
    1617    /** Copy constructor */
    1718    AmplInterface(const AmplInterface &other);
     
    2728    virtual void readAmplNlFile(char**& filename,
    2829        std::string* ipopt_file_content =NULL,
    29         std::string* nl_file_content = NULL);
     30        std::string* nl_file_content = NULL,
     31        Ipopt::SmartPtr<TNLPSolver> app = IpoptSolver() );
    3032    /** write ampl solution file */
    3133    void writeAmplSolFile(std::string message,const double * primalSol = NULL,const double * dualSol = NULL);
  • branches/devel/Bonmin/src/CbcBonmin/BonCbc.cpp

    r62 r67  
    267267      bool hasPseudo = (upPsCosts!=NULL);
    268268      model.findIntegers(true,hasPseudo);
    269       CbcObject ** simpleIntegerObjects = model.objects();
     269      OsiObject ** simpleIntegerObjects = model.objects();
    270270      int numberObjects = model.numberObjects();
    271271      for (int i = 0 ; i < numberObjects ; i++)
    272272      {
    273         int iCol = simpleIntegerObjects[i]->columnNumber();
     273        CbcObject * object = dynamic_cast<CbcObject *>
     274          (simpleIntegerObjects[i]);
     275        int iCol = object->columnNumber();
    274276        if (priorities)
    275           simpleIntegerObjects[i]->setPriority(priorities[iCol]);
     277          object->setPriority(priorities[iCol]);
    276278        if (directions)
    277           simpleIntegerObjects[i]->setPreferredWay(directions[iCol]);
     279          object->setPreferredWay(directions[iCol]);
    278280        if (upPsCosts) {
    279281          CbcSimpleIntegerPseudoCost * pscObject =
    280             dynamic_cast<CbcSimpleIntegerPseudoCost*> (simpleIntegerObjects[i]);
     282            dynamic_cast<CbcSimpleIntegerPseudoCost*> (object);
    281283          pscObject->setUpPseudoCost(upPsCosts[iCol]);
    282284          pscObject->setDownPseudoCost(downPsCosts[iCol]);
  • branches/devel/Bonmin/src/CbcBonmin/BonCbc.hpp

    r62 r67  
    6969    /** virtual callback function to eventually modify objects for integer variable
    7070        (replace with user set). This is called after CbcModel::findIntegers */
    71     virtual void replaceIntegers(CbcObject ** objects, int numberObjects)
     71    virtual void replaceIntegers(OsiObject ** objects, int numberObjects)
    7272    {};
    7373  private:
  • branches/devel/Bonmin/src/CbcBonmin/BonCbcNode.cpp

    r62 r67  
    2323#include "BonOsiTMINLPInterface.hpp"
    2424#include "BonIpoptWarmStart.hpp"
    25 #include "BonIpoptInterface.hpp"
     25#include "BonOsiTMINLPInterface.hpp"
    2626
    2727using namespace std;
     
    8989      sequenceOfUnsolvedSize_(0)
    9090  {
    91     IpoptInterface * ipopt = dynamic_cast<IpoptInterface *>(model->solver());
    92     assert (ipopt);
    93     Ipopt::ApplicationReturnStatus optimization_status
    94     = ipopt->getOptStatus();
    9591    BonCbcPartialNodeInfo * nlpParent = dynamic_cast<BonCbcPartialNodeInfo *> (parent);
    9692    int numberInfeasible = 0;
     
    112108      }
    113109    }
    114     if ((optimization_status==Ipopt::Unrecoverable_Exception)||
    115         (optimization_status==Ipopt::NonIpopt_Exception_Thrown)||
    116         (optimization_status==Ipopt::Insufficient_Memory)||
    117         (optimization_status==Ipopt::Restoration_Failed)||
    118         (optimization_status==Ipopt::Internal_Error)||
    119         (optimization_status==Ipopt::Maximum_Iterations_Exceeded))
     110    if (model->solver()->isAbandoned() ||
     111        model->solver()->isIterationLimitReached())
    120112      sequenceOfUnsolvedSize_ = numberUnsolved + 1;
    121113
    122     if (optimization_status==Ipopt::Infeasible_Problem_Detected)
     114    if (model->solver()->isProvenPrimalInfeasible())
    123115      sequenceOfInfeasiblesSize_ = numberInfeasible + 1;
    124116  }
  • branches/devel/Bonmin/src/IpoptInterface/BonIpoptInteriorWarmStarter.cpp

    r55 r67  
    1212#include "IpIpoptData.hpp"
    1313#include "IpIpoptCalculatedQuantities.hpp"
    14 
     14namespace Bonmin {
    1515IpoptInteriorWarmStarter::
    1616IpoptInteriorWarmStarter(Index n,
     
    213213  return true;
    214214}
     215}
     216
  • branches/devel/Bonmin/src/IpoptInterface/BonIpoptInteriorWarmStarter.hpp

    r55 r67  
    1515
    1616using namespace Ipopt;
    17 
     17namespace Ipopt {
    1818class IpoptInteriorWarmStarter : public ReferencedObject
    1919{
     
    100100  //@}
    101101};
    102 
     102}
    103103#endif
  • branches/devel/Bonmin/src/IpoptInterface/BonIpoptSolver.cpp

    r64 r67  
    1313#include "CoinError.hpp"
    1414
     15#include "BonIpoptInteriorWarmStarter.hpp"
     16#include "BonIpoptWarmStart.hpp"
     17
    1518namespace Bonmin{
    1619  IpoptSolver::~IpoptSolver(){}
     
    2629  {
    2730    app_.Initialize(params_file);
     31    app_.Options()->GetEnumValue("warm_start",warmStartStrategy_,"bonmin.");
    2832    setMinlpDefaults(app_.Options());
    2933  }
     
    3337  {
    3438    app_.Initialize(is);
     39    app_.Options()->GetEnumValue("warm_start",warmStartStrategy_,"bonmin.");
    3540    setMinlpDefaults(app_.Options());
    3641  }
     
    5156          optimizationStatus_ = Ipopt::Infeasible_Problem_Detected;
    5257      }
     58
     59
     60
    5361    return solverReturnStatus(optimizationStatus_);
    5462  }
     
    7078          optimizationStatus_ = Ipopt::Infeasible_Problem_Detected;
    7179      }
    72     return solverReturnStatus(optimizationStatus_);
     80      return solverReturnStatus(optimizationStatus_);
    7381  }
    7482
     
    174182    }
    175183  }
     184
     185/// Get warmstarting information
     186CoinWarmStart*
     187IpoptSolver::getWarmStart(Ipopt::SmartPtr<TMINLP2TNLP> tnlp) const
     188{
     189  if(warmStartStrategy_) {
     190    if(warmStartStrategy_==2) {
     191        Ipopt::SmartPtr<IpoptInteriorWarmStarter> warm_starter =
     192        Ipopt::SmartPtr<IpoptInteriorWarmStarter>(tnlp->GetWarmStarter());
     193        return new IpoptWarmStart(tnlp, warm_starter);
     194    }
     195    else  return new IpoptWarmStart(tnlp, NULL);
     196  }
     197  else
     198     return new IpoptWarmStart(tnlp->num_variables(), tnlp->num_constraints());
    176199}
     200
     201
     202bool
     203IpoptSolver::setWarmStart(const CoinWarmStart* warmstart,
     204                          Ipopt::SmartPtr<TMINLP2TNLP> tnlp)
     205{
     206  if(!warmstart || !warmStartStrategy_)
     207    return 0;
     208  const IpoptWarmStart * ws = dynamic_cast<const IpoptWarmStart*> (warmstart);
     209  if(ws->empty())//reset initial point and leave
     210  {
     211    disableWarmStart();
     212    return 1;
     213  }
     214  enableWarmStart();
     215  int numcols = tnlp->num_variables();
     216  int numrows = tnlp->num_constraints();
     217  const double * colLow = tnlp->x_l();
     218  const double * colUp = tnlp->x_u();
     219  for(int i = 0; i < numcols ; i++) {
     220    CoinWarmStartBasis::Status status = ws->getStructStatus(i);
     221    if(status == CoinWarmStartBasis::atLowerBound) {
     222      tnlp->setxInit(i,colLow[i]);
     223      tnlp->setDualInit(i + numcols + numrows,0.);
     224    }
     225    else if(status == CoinWarmStartBasis::atUpperBound) {
     226      tnlp->setxInit(i,colUp[i]);
     227      tnlp->setDualInit(i + numrows,0.);
     228    }
     229    else {
     230      tnlp->setDualInit(i + numrows,0.);
     231      tnlp->setDualInit(i + numcols + numrows, 0.);
     232    }
     233  }
     234  for(int i = 0; i < numrows ; i++) {
     235    CoinWarmStartBasis::Status status = ws->getArtifStatus(i);
     236    if(status == CoinWarmStartBasis::atLowerBound) {
     237      tnlp->setDualInit(i,0.);
     238    }
     239  }
     240  int nElem = ws->values()->getNumElements();
     241  const int * inds = ws->values()->getIndices();
     242  const double * elems = ws->values()->getElements();
     243
     244  for(int i = 0 ; i < nElem ; i++) {
     245    tnlp->setxInit(inds[i],elems[i]);
     246  }
     247
     248  if(IsValid(ws->warm_starter()))
     249    tnlp->SetWarmStarter(ws->warm_starter());
     250  return 1;
     251}
     252
     253
     254CoinWarmStart *
     255IpoptSolver::getEmptyWarmStart() const
     256{return new IpoptWarmStart(1);}
     257
     258  void
     259  IpoptSolver::enableWarmStart()
     260  {
     261    Options()->SetStringValue("warm_start_init_point", "yes");
     262  }
     263
     264  void
     265  IpoptSolver::disableWarmStart()
     266  {
     267    Options()->SetStringValue("warm_start_init_point", "no");
     268  }
     269
     270
     271  void
     272  IpoptSolver::turnOffOutput(){
     273  }
     274
     275
     276  void
     277  IpoptSolver::turnOnOutput(){
     278  }
     279
     280
     281/*******************************************************************************/
     282// Class for throwing errors reported from Ipopt
     283/******************************************************************************/
     284
     285std::string
     286IpoptSolver::UnsolvedIpoptError::errorNames[17] ={"Solve succeeded",
     287    "Solved to acceptable level",
     288    "Infeasible problem detected",
     289    "Search direction becomes too small",
     290    "Diverging iterates",
     291    "User requested stop",
     292    "Maximum iterations exceeded",
     293    "Restoration failed",
     294    "Error in step computation",
     295    "Not enough degrees of freedom",
     296    "Invalid problem definition",
     297    "Invalid option",
     298    "Invalid number detected",
     299    "Unrecoverable exception",
     300    "NonIpopt exception thrown",
     301    "Insufficient memory",
     302    "Internal error"};
     303
     304const std::string &
     305IpoptSolver::UnsolvedIpoptError::errorName() const
     306{
     307  if(errorNum() >=0)
     308    return errorNames[errorNum()];
     309  if(errorNum() == -1) return errorNames[6];
     310  else if(errorNum() == -2) return errorNames[7];
     311  else if(errorNum() == -3) return errorNames[8];
     312  else if(errorNum() == -10) return errorNames[9];
     313  else if(errorNum() == -11) return errorNames[10];
     314  else if(errorNum() == -12) return errorNames[11];
     315  else if(errorNum() == -13) return errorNames[12];
     316  else if(errorNum() == -100) return errorNames[13];
     317  else if(errorNum() == -101) return errorNames[14];
     318  else if(errorNum() == -102) return errorNames[15];
     319  else if(errorNum() == -199) return errorNames[16];
     320  throw CoinError("UnsolvedError", "UnsolvedError::errorName()","Unrecognized optimization status in ipopt.");
     321}
     322
     323std::string IpoptSolver::UnsolvedIpoptError::solverName_ = "Ipopt";
     324
     325const std::string &
     326IpoptSolver::UnsolvedIpoptError::solverName() const
     327{
     328   return solverName_;
     329}
     330
     331
     332
     333
     334}//end namespace Bonmin
  • branches/devel/Bonmin/src/IpoptInterface/BonIpoptSolver.hpp

    r58 r67  
    1313#include "IpIpoptApplication.hpp"
    1414
     15
    1516namespace Bonmin{
    1617class IpoptSolver: public TNLPSolver {
    1718public:
     19class UnsolvedIpoptError: public TNLPSolver::UnsolvedError
     20{
     21 public:
     22  UnsolvedIpoptError(int errorNum = 10000):
     23  TNLPSolver::UnsolvedError(errorNum)
     24  {}
     25  virtual const std::string& errorName() const;
     26 
     27  virtual const std::string& solverName() const;
     28  virtual ~UnsolvedIpoptError(){}
     29  private:
     30  static std::string errorNames [17];
     31  static std::string solverName_;
     32};
     33
     34  virtual UnsolvedError * newUnsolvedError(int num){
     35    return new UnsolvedIpoptError(num);}
     36
     37
     38
    1839  /// Constructor
    19   IpoptSolver():app_(){}
     40  IpoptSolver():
     41    app_(),
     42    warmStartStrategy_(1)
     43  {}
    2044
    2145  ///virtual constructor
     
    4165  /// Resolves a problem expresses as a TNLP
    4266  virtual TNLPSolver::ReturnStatus ReOptimizeTNLP(const Ipopt::SmartPtr<Ipopt::TNLP> & tnlp);
     67
     68  /// Set the warm start in the solver
     69  virtual bool setWarmStart(const CoinWarmStart * warm,
     70                           Ipopt::SmartPtr<TMINLP2TNLP> tnlp);
     71
     72  /// Get the warm start form the solver
     73  virtual CoinWarmStart * getWarmStart(Ipopt::SmartPtr<Bonmin::TMINLP2TNLP> tnlp) const;
     74
     75  virtual CoinWarmStart * getEmptyWarmStart() const;
     76
     77  /// Enable the warm start options in the solver
     78  virtual void enableWarmStart();
     79
     80  /// Disable the warm start options in the solver
     81  virtual void disableWarmStart();
     82
    4383  //@}
    4484
     
    5797   /// Get the iteration count of the last optimization.
    5898   virtual int IterationCount();
     99
     100  /// turn off all output from the solver
     101  virtual void turnOffOutput();
     102  /// turn on all output from the solver
     103  virtual void turnOnOutput();
    59104
    60105  /// Return status of last optimization
     
    77122  /** return status of last optimization.*/
    78123  Ipopt::ApplicationReturnStatus optimizationStatus_;
    79  
     124    //@}
     125
     126  /** Warm start strategy :
     127  <ol>
     128  <li> no warm start,</li>
     129  <li> simple warm start (optimal point),</li>
     130  <li> more elaborate strategies (interior point...).</li>
     131  </ol>
     132  */
     133  int warmStartStrategy_;
    80134};
    81135}
  • branches/devel/Bonmin/src/IpoptInterface/BonIpoptWarmStart.cpp

    r58 r67  
    1515
    1616
    17 #include "BonIpoptInterface.hpp"
     17#include "BonTMINLP2TNLP.hpp"
    1818#include "BonIpoptInteriorWarmStarter.hpp"
    1919
     
    3232}
    3333/// Usefull constructor
    34 IpoptWarmStart::IpoptWarmStart(const IpoptInterface &ipopt,
     34IpoptWarmStart::IpoptWarmStart(const Ipopt::SmartPtr<TMINLP2TNLP> tnlp,
    3535    SmartPtr<IpoptInteriorWarmStarter> warm_starter):
    3636    values_(),
     
    4040{
    4141
    42   int numcols = ipopt.getNumCols();
    43   int numrows = ipopt.getNumRows();
     42  int numcols = tnlp->num_variables();
     43  int numrows = tnlp->num_constraints();
    4444  setSize(numcols,numrows);
    4545  values_.reserve(numcols+numrows);
     
    4747  // it when we are happy with the new warmstarter (AW)
    4848  double epsilon = 1e-05;//ipopt.getPushFact();
    49   const double * primals = ipopt.problem()->x_sol();
    50   const double * duals = ipopt.problem()->duals_sol();
    51   const double * colLo = ipopt.getColLower();
    52   const double * colUp = ipopt.getColUpper();
     49  const double * primals = tnlp->x_sol();
     50  const double * duals = tnlp->duals_sol();
     51  const double * colLo = tnlp->x_l();
     52  const double * colUp = tnlp->x_u();
    5353  for(int i = 0 ; i < numcols ; i++) {
    5454    if(primals[i] - colLo[i] < epsilon) {
  • branches/devel/Bonmin/src/IpoptInterface/BonIpoptWarmStart.hpp

    r58 r67  
    1818
    1919namespace Bonmin {
    20 class IpoptInterface;
     20class TMINLP2TNLP;
    2121
    2222/** \brief Class for storing warm start informations for Ipopt.<br>
     
    3232  IpoptWarmStart(bool empty = 1, int numvars = 0, int numcont = 0);
    3333  /// Usefull constructor, stores the current optimum of ipopt
    34   IpoptWarmStart(const IpoptInterface &ipopt,
     34  IpoptWarmStart(const Ipopt::SmartPtr<TMINLP2TNLP> tnlp,
    3535      SmartPtr<IpoptInteriorWarmStarter> warm_starter);
    3636  /// Copy constructor
  • branches/devel/Bonmin/src/IpoptInterface/BonOsiTMINLPInterface.cpp

    r64 r67  
    575575}
    576576
     577OsiSolverInterface *
     578OsiTMINLPInterface::clone(bool copyData ) const
     579{
     580  if(copyData)
     581    return new OsiTMINLPInterface(*this);
     582  else return new OsiTMINLPInterface;
     583}
    577584
    578585/// Assignment operator
     
    839846  //std::cerr<<"Resolving the problem for robustness"<<std::endl;
    840847  //First remove warm start point and resolve
    841   unsetWarmStartOptions();
     848  app_->disableWarmStart();
    842849  messageHandler()->message(WARNING_RESOLVING,
    843850      messages_)
     
    12411248}
    12421249
     1250  /*! \brief Get an empty warm start object
     1251
     1252  This routine returns an empty CoinWarmStartBasis object. Its purpose is
     1253  to provide a way to give a client a warm start basis object of the
     1254  appropriate type, which can resized and modified as desired.
     1255  */
     1256CoinWarmStart *
     1257OsiTMINLPInterface::getEmptyWarmStart () const
     1258{return app_->getEmptyWarmStart();}
     1259
     1260  /** Get warmstarting information */
     1261CoinWarmStart*
     1262OsiTMINLPInterface::getWarmStart() const
     1263{return app_->getWarmStart(problem_);}
     1264  /** Set warmstarting information. Return true/false depending on whether
     1265      the warmstart information was accepted or not. */
     1266bool
     1267OsiTMINLPInterface::setWarmStart(const CoinWarmStart* warmstart)
     1268{
     1269  hasBeenOptimized_ = false;
     1270  return app_->setWarmStart(warmstart, problem_);
     1271}
    12431272
    12441273/** Set the index-th variable to be a continuous variable */
     
    14441473  }
    14451474  //std::cout<<std::endl;
    1446   unsetWarmStartOptions();
     1475  app_->disableWarmStart();
    14471476  setColSolution(sol);
    14481477  delete [] sol;
    14491478}
    14501479
    1451 
    1452 void
    1453 OsiTMINLPInterface::UnsolvedError::printError(std::ostream &os)
    1454 {
    1455   os<<solverName()<<" exited with error code "<<errorNum_<<" "<<errorName()<<std::endl;
    1456 }
    14571480
    14581481
     
    19481971
    19491972
    1950   setWarmStartOptions();
     1973  app_->enableWarmStart();
    19511974  setColSolution(problem()->x_sol());
    19521975  setRowPrice(problem()->duals_sol());
     
    21402163  }
    21412164
    2142   setWarmStartOptions();
     2165  app_->enableWarmStart();
    21432166
    21442167  solveAndCheckErrors(1,1,"resolve");
  • branches/devel/Bonmin/src/IpoptInterface/BonOsiTMINLPInterface.hpp

    r64 r67  
    7070  ;
    7171
    72   //#############################################################################
    73 
    74   /** We will throw this error when a problem is not solved.
    75       Eventually store the error code from Ipopt*/
    76   class UnsolvedError
    77   {
    78   public:
    79     /** Constructor */
    80     UnsolvedError(int errorNum):errorNum_(errorNum)
    81     {}
    82     /** Print error message.*/
    83     void printError(std::ostream & os);
    84     /** Get the string corresponding to error.*/
    85     virtual const std::string& errorName() const = 0;
    86     /** Return the name of the solver. */
    87     virtual const std::string& solverName() const = 0;
    88     /** Return error number. */
    89     int errorNum() const{
    90     return errorNum_;}
    91     /** destructor. */
    92     virtual ~UnsolvedError(){}
    93   private:
    94     int errorNum_;
    95   }
    96   ;
    97 
    98   virtual UnsolvedError * newUnsolvedError(int num) = 0;
     72  // Error when problem is not solved
     73  TNLPSolver::UnsolvedError * newUnsolvedError(int num){
     74    return app_->newUnsolvedError(num);
     75  }
    9976  //#############################################################################
    10077
     
    155132  OsiTMINLPInterface (const OsiTMINLPInterface &);
    156133
     134  /** Virtual copy constructor */
     135  OsiSolverInterface * clone(bool copyData = true) const;
     136
    157137  /// Assignment operator
    158138  OsiTMINLPInterface & operator=(const OsiTMINLPInterface& rhs);
     
    514494  appropriate type, which can resized and modified as desired.
    515495  */
    516   virtual CoinWarmStart *getEmptyWarmStart () const = 0;
     496  virtual CoinWarmStart *getEmptyWarmStart () const;
    517497
    518498  /** Get warmstarting information */
    519   virtual CoinWarmStart* getWarmStart() const = 0;
     499  virtual CoinWarmStart* getWarmStart() const;
    520500
    521501  /** Set warmstarting information. Return true/false depending on whether
    522502      the warmstart information was accepted or not. */
    523   virtual bool setWarmStart(const CoinWarmStart* warmstart) = 0;
    524 
    525   virtual void setWarmStartOptions() = 0;
    526   virtual void unsetWarmStartOptions() = 0;
     503  virtual bool setWarmStart(const CoinWarmStart* warmstart);
     504
    527505
    528506
     
    785763    return GetRawPtr(tminlp_);
    786764  }
    787  
     765   const Bonmin::TNLPSolver * solver() const
     766  {
     767    return GetRawPtr(app_);
     768  }
     769 
     770  Bonmin::TNLPSolver * solver()
     771  {
     772    return GetRawPtr(app_);
     773  }
    788774  /** Methods to build outer approximations */
    789775  //@{
  • branches/devel/Bonmin/src/IpoptInterface/BonStartPointReader.cpp

    r55 r67  
    3737  {
    3838    readFile();
    39     solver->setWarmStartOptions();
     39    solver->solver()->enableWarmStart();
    4040    if(primals_)
    4141      solver->setColSolution(primals_);
  • branches/devel/Bonmin/src/IpoptInterface/BonTNLPSolver.cpp

    r58 r67  
    8181    return 1;
    8282  }
     83
     84void
     85TNLPSolver::UnsolvedError::printError(std::ostream &os)
     86{
     87  os<<solverName()<<" exited with error code "<<errorNum_<<" "<<errorName()<<std::endl;
    8388}
     89
     90
     91}//end namespace Bonmin
     92
  • branches/devel/Bonmin/src/IpoptInterface/BonTNLPSolver.hpp

    r58 r67  
    1212#define TNLPSolver_H
    1313#include "IpTNLP.hpp"
     14#include "BonTMINLP2TNLP.hpp"
    1415
    1516//Some declarations
    1617#include "IpOptionsList.hpp"
    1718#include "IpRegOptions.hpp"
     19#include "CoinWarmStart.hpp"
    1820
    1921namespace Bonmin  {
     
    3739    unbounded /** Problem is unbounded.*/
    3840  };
     41
     42
     43
     44//#############################################################################
     45
     46  /** We will throw this error when a problem is not solved.
     47      Eventually store the error code from solver*/
     48  class UnsolvedError
     49  {
     50  public:
     51    /** Constructor */
     52    UnsolvedError(int errorNum):errorNum_(errorNum)
     53    {}
     54    /** Print error message.*/
     55    void printError(std::ostream & os);
     56    /** Get the string corresponding to error.*/
     57    virtual const std::string& errorName() const = 0;
     58    /** Return the name of the solver. */
     59    virtual const std::string& solverName() const = 0;
     60    /** Return error number. */
     61    int errorNum() const{
     62    return errorNum_;}
     63    /** destructor. */
     64    virtual ~UnsolvedError(){}
     65  private:
     66    int errorNum_;
     67  }
     68  ;
     69
     70  virtual UnsolvedError * newUnsolvedError(int num) = 0;
     71 
     72
     73
    3974  /// Constructor
    4075   TNLPSolver();
     
    6297   /// Resolves a problem expresses as a TNLP
    6398   virtual ReturnStatus ReOptimizeTNLP(const Ipopt::SmartPtr<Ipopt::TNLP> & tnlp) = 0;
     99
     100  /// Set the warm start in the solver
     101  virtual bool setWarmStart(const CoinWarmStart * warm,
     102                            Ipopt::SmartPtr<TMINLP2TNLP> tnlp) = 0;
     103
     104  /// Get the warm start form the solver
     105  virtual CoinWarmStart * getWarmStart(Ipopt::SmartPtr<TMINLP2TNLP> tnlp) const = 0;
     106
     107  virtual CoinWarmStart * getEmptyWarmStart() const = 0;
     108
     109  /// Enable the warm start options in the solver
     110  virtual void enableWarmStart() = 0;
     111
     112  /// Disable the warm start options in the solver
     113  virtual void disableWarmStart() = 0;
    64114   //@}
    65115
     
    79129   virtual int IterationCount() = 0;
    80130
     131
     132  /// turn off all output from the solver
     133  virtual void turnOffOutput() = 0 ;
     134  /// turn on all output from the solver
     135  virtual void turnOnOutput() = 0;
     136
    81137protected:
    82138  bool zeroDimension(const Ipopt::SmartPtr<Ipopt::TNLP> &tnlp,
  • branches/devel/Bonmin/src/IpoptInterface/Makefile.am

    r65 r67  
    2121        BonCurvatureEstimator.cpp BonCurvatureEstimator.hpp \
    2222        BonStartPointReader.cpp BonStartPointReader.hpp \
    23         BonIpoptInterface.cpp BonIpoptInterface.hpp \
    2423        BonOsiTMINLPInterface.cpp BonOsiTMINLPInterface.hpp \
    2524        BonIpoptInteriorWarmStarter.cpp BonIpoptInteriorWarmStarter.hpp \
     
    6564
    6665include_HEADERS = \
    67         BonIpoptInterface.hpp \
    6866        BonOsiTMINLPInterface.hpp \
    6967        BonIpoptInteriorWarmStarter.hpp \
     
    9997# Here repeat all source files, with "bak" appended
    10098ASTYLE_FILES = \
    101         BonBoundsReader.cpp BonBoundsReader.hpp \
    102         BonColReader.cpp BonColReader.hpp \
    103         BonStartPointReader.cpp BonStartPointReader.hpp \
    104         BonIpoptInterface.cpp BonIpoptInterface.hpp \
    105         BonOsiTMINLPInterface.cpp BonOsiTMINLPInterface.hpp \
    106         BonIpoptInteriorWarmStarter.cpp BonIpoptInteriorWarmStarter.hpp \
    107         BonIpoptWarmStart.cpp BonIpoptWarmStart.hpp \
    108         BonTMINLP2TNLP.cpp BonTMINLP2TNLP.hpp \
    109         BonTMINLP.cpp BonTMINLP.hpp \
    110         BonIpoptSolver.hpp BonIpoptSolver.cpp \
    111         BonTNLPSolver.hpp BonTNLPSolver.cpp \
    112         BonTNLP2FPNLP.cpp BonTNLP2FPNLP.hpp
     99        BonBoundsReaderbak.cpp BonBoundsReaderbak.hpp \
     100        BonColReaderbak.cpp BonColReaderbak.hpp \
     101        BonStartPointReaderbak.cpp BonStartPointReader.hpp \
     102        BonOsiTMINLPInterfacebak.cpp BonOsiTMINLPInterface.hpp \
     103        BonIpoptInteriorWarmStarterbak.cpp BonIpoptInteriorWarmStarter.hpp \
     104        BonIpoptWarmStartbak.cpp BonIpoptWarmStart.hpp \
     105        BonTMINLP2TNLPbak.cpp BonTMINLP2TNLP.hpp \
     106        BonTMINLPbak.cpp BonTMINLP.hpp \
     107        BonIpoptSolverbak.hpp BonIpoptSolver.cpp \
     108        BonTNLPSolverbak.hpp BonTNLPSolver.cpp \
     109        BonTNLP2FPNLPbak.cpp BonTNLP2FPNLP.hpp
    113110
    114111
  • branches/devel/Bonmin/src/IpoptInterface/Makefile.in

    r65 r67  
    6464        BonCurvatureEstimator.cpp BonCurvatureEstimator.hpp \
    6565        BonStartPointReader.cpp BonStartPointReader.hpp \
    66         BonIpoptInterface.cpp BonIpoptInterface.hpp \
    6766        BonOsiTMINLPInterface.cpp BonOsiTMINLPInterface.hpp \
    6867        BonIpoptInteriorWarmStarter.cpp \
     
    7675am_libipoptinterface_la_OBJECTS = BonBoundsReader.lo BonColReader.lo \
    7776        BonCurvatureEstimator.lo BonStartPointReader.lo \
    78         BonIpoptInterface.lo BonOsiTMINLPInterface.lo \
    79         BonIpoptInteriorWarmStarter.lo BonIpoptWarmStart.lo \
    80         BonTMINLP2TNLP.lo BonTMINLP.lo BonIpoptSolver.lo \
    81         BonTNLPSolver.lo BonTNLP2FPNLP.lo $(am__objects_1)
     77        BonOsiTMINLPInterface.lo BonIpoptInteriorWarmStarter.lo \
     78        BonIpoptWarmStart.lo BonTMINLP2TNLP.lo BonTMINLP.lo \
     79        BonIpoptSolver.lo BonTNLPSolver.lo BonTNLP2FPNLP.lo \
     80        $(am__objects_1)
    8281libipoptinterface_la_OBJECTS = $(am_libipoptinterface_la_OBJECTS)
    8382depcomp = $(SHELL) $(top_srcdir)/../depcomp
     
    334333        BonColReader.cpp BonColReader.hpp BonCurvatureEstimator.cpp \
    335334        BonCurvatureEstimator.hpp BonStartPointReader.cpp \
    336         BonStartPointReader.hpp BonIpoptInterface.cpp \
    337         BonIpoptInterface.hpp BonOsiTMINLPInterface.cpp \
     335        BonStartPointReader.hpp BonOsiTMINLPInterface.cpp \
    338336        BonOsiTMINLPInterface.hpp BonIpoptInteriorWarmStarter.cpp \
    339337        BonIpoptInteriorWarmStarter.hpp BonIpoptWarmStart.cpp \
     
    372370########################################################################
    373371include_HEADERS = \
    374         BonIpoptInterface.hpp \
    375372        BonOsiTMINLPInterface.hpp \
    376373        BonIpoptInteriorWarmStarter.hpp \
     
    396393# Here repeat all source files, with "bak" appended
    397394ASTYLE_FILES = \
    398         BonBoundsReader.cpp BonBoundsReader.hpp \
    399         BonColReader.cpp BonColReader.hpp \
    400         BonStartPointReader.cpp BonStartPointReader.hpp \
    401         BonIpoptInterface.cpp BonIpoptInterface.hpp \
    402         BonOsiTMINLPInterface.cpp BonOsiTMINLPInterface.hpp \
    403         BonIpoptInteriorWarmStarter.cpp BonIpoptInteriorWarmStarter.hpp \
    404         BonIpoptWarmStart.cpp BonIpoptWarmStart.hpp \
    405         BonTMINLP2TNLP.cpp BonTMINLP2TNLP.hpp \
    406         BonTMINLP.cpp BonTMINLP.hpp \
    407         BonIpoptSolver.hpp BonIpoptSolver.cpp \
    408         BonTNLPSolver.hpp BonTNLPSolver.cpp \
    409         BonTNLP2FPNLP.cpp BonTNLP2FPNLP.hpp
     395        BonBoundsReaderbak.cpp BonBoundsReaderbak.hpp \
     396        BonColReaderbak.cpp BonColReaderbak.hpp \
     397        BonStartPointReaderbak.cpp BonStartPointReader.hpp \
     398        BonOsiTMINLPInterfacebak.cpp BonOsiTMINLPInterface.hpp \
     399        BonIpoptInteriorWarmStarterbak.cpp BonIpoptInteriorWarmStarter.hpp \
     400        BonIpoptWarmStartbak.cpp BonIpoptWarmStart.hpp \
     401        BonTMINLP2TNLPbak.cpp BonTMINLP2TNLP.hpp \
     402        BonTMINLPbak.cpp BonTMINLP.hpp \
     403        BonIpoptSolverbak.hpp BonIpoptSolver.cpp \
     404        BonTNLPSolverbak.hpp BonTNLPSolver.cpp \
     405        BonTNLP2FPNLPbak.cpp BonTNLP2FPNLP.hpp
    410406
    411407CLEANFILES = $(ASTYLE_FILES)
     
    466462@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BonCurvatureEstimator.Plo@am__quote@
    467463@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BonFilterSolver.Plo@am__quote@
    468 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BonIpoptInterface.Plo@am__quote@
    469464@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BonIpoptInteriorWarmStarter.Plo@am__quote@
    470465@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BonIpoptSolver.Plo@am__quote@
  • branches/devel/Bonmin/src/OaInterface/BonOACutGenerator2.cpp

    r62 r67  
    344344    bool deleteSi = false;
    345345    if (si_ == NULL) {
    346       si_ = si.clone();
     346      si_ = si.clone(1);
    347347      deleteSi = true;
    348348    }
  • branches/devel/Bonmin/test/InterfaceTest.cpp

    r58 r67  
    1818    If Solver passes all the test then it should have everything needed to be integrated into bonmin. */
    1919
    20 void testGetMethods(IpoptInterface &si)
     20void testGetMethods(OsiTMINLPInterface &si)
    2121{
    2222    CoinRelFltEq eq;// to test equality of doubles   
     
    8181      std::cout<<"Test passed"<<std::endl;                 
    8282}
    83 void testOptimAndSolutionQuery(IpoptInterface &si)
     83void testOptimAndSolutionQuery(OsiTMINLPInterface & si)
    8484{
    8585    CoinRelFltEq eq(1e-07);// to test equality of doubles   
     
    124124
    125125///Test set methods
    126 void testSetMethods(IpoptInterface &si)
     126void testSetMethods(OsiTMINLPInterface &si)
    127127{
    128128    CoinRelFltEq eq(1e-07);// to test equality of doubles   
     
    226226  /*   Test constructors                                                                                                              */
    227227  /**********************************************************************************/
    228   std::cout<<"Test IpoptInterface"<<std::endl;
     228  std::cout<<"Test OsiTMINLPInterface with Ipopt solver"<<std::endl;
    229229  // Test usefull constructor
    230230  {
     
    249249       const char ** argv = args;
    250250      SmartPtr<TMINLP> ampl_tminlp = new AmplTMINLP(ConstPtr(app->getIpoptApp().Jnlst()), app->Options(), const_cast<char**&>(argv));
    251       IpoptInterface si(ampl_tminlp);
     251      OsiTMINLPInterface si(ampl_tminlp, new IpoptSolver);
    252252    std::cout<<"---------------------------------------------------------------------------------------------------------------------------------------------------------"
    253253    <<std::endl<<"Testing usefull constructor"<<std::endl
     
    280280      const char ** argv = args;
    281281      SmartPtr<TMINLP> ampl_tminlp = new AmplTMINLP(ConstPtr(app->Jnlst()),  app->Options(), const_cast<char**&>(argv));
    282       IpoptInterface si1(ampl_tminlp);
    283      
    284       IpoptInterface si(si1);
     282      OsiTMINLPInterface si1(ampl_tminlp, new IpoptSolver);
     283     
     284      OsiTMINLPInterface si(si1);
    285285    std::cout<<"---------------------------------------------------------------------------------------------------------------------------------------------------------"
    286286    <<std::endl<<"Testing copy constructor"<<std::endl
Note: See TracChangeset for help on using the changeset viewer.