Changeset 90


Ignore:
Timestamp:
Oct 25, 2006 12:54:34 PM (12 years ago)
Author:
pbonami
Message:

Bug fixes in interface for filter

Location:
branches/devel/Bonmin
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Bonmin/inc/config_bonmin.h.in

    r1 r90  
    2727/* Define to 1 if the FortMP package is used */
    2828#undef COIN_HAS_FMP
     29
     30/* Define to 1 if the filterSqp package is used */
     31#undef COIN_HAS_FSQP
    2932
    3033/* Define to 1 if the Glpk package is used */
  • branches/devel/Bonmin/src/Apps/BonMin.cpp

    r86 r90  
    1818
    1919#include "CoinTime.hpp"
    20 
     20#include "BonminConfig.h"
    2121#include "BonAmplInterface.hpp"
    2222#include "BonIpoptSolver.hpp"
    2323#include "BonCbc.hpp"
     24
     25#ifdef COIN_HAS_FSQP
     26#include "BonFilterSolver.hpp"
     27#endif
    2428
    2529using namespace Bonmin;
     
    119123  using namespace Ipopt;
    120124 
    121   AmplInterface * nlpSolver;
     125  AmplInterface * nlp_and_solver;
     126
     127  //We need to build dummy solver objects to get the options, determine which is the solver to use and register all the options
     128  Ipopt::SmartPtr<IpoptSolver> dummy_ipopt = new IpoptSolver;
     129  OsiTMINLPInterface forOption(GetRawPtr(dummy_ipopt));
     130
     131
     132  int solverUsed = 0; // 0 is Ipopt, 1 is Filter
     133  forOption.solver()->Options()->GetEnumValue("nlp_solver", solverUsed,"bonmin.");
     134
    122135  char * pbName = NULL;
    123136  if(argc > 1)
     
    128141  else //will just output usage
    129142  {
    130     Ipopt::SmartPtr<TNLPSolver> ipoptSolver = new IpoptSolver;
    131     nlpSolver = new AmplInterface(argv, ipoptSolver);
    132     delete nlpSolver;
     143    Ipopt::SmartPtr<IpoptSolver> ipoptSolver = new IpoptSolver;
     144    nlp_and_solver = new AmplInterface(argv, GetRawPtr(ipoptSolver));
     145    delete nlp_and_solver;
    133146    return 0;
    134147  }
    135148  double time1 = CoinCpuTime();
    136149  try {
    137   Ipopt::SmartPtr<TNLPSolver> filterSolver = new IpoptSolver;
    138   nlpSolver = new AmplInterface(argv, filterSolver);
     150  Ipopt::SmartPtr<TNLPSolver> solver;
     151  if(solverUsed == 0)
     152    solver = new IpoptSolver;
     153  else if(solverUsed == 1)
     154#ifdef COIN_HAS_FSQP
     155    solver = new FilterSolver;
     156#else
     157    {
     158      std::cerr<<"filterSQP is not propoerly configured for using into Bonmin"<<std::endl
     159               <<"be sure to run the configure script with options:"<<std::endl
     160               <<"--with-filtersqp_lib=\"<path_to_filter_library>\""<<std::endl
     161               <<"--with-filtersqp_incdir=\"\""<<std::endl;
     162               throw -1;
     163      }
     164#endif
     165  else
     166    {
     167      std::cerr<<"Trying to use unknown solver."<<std::endl;
     168    }
     169   nlp_and_solver = new AmplInterface(argv, solver);
    139170    BonminCbcParam par;
    140171    Bab bb;
    141     par(nlpSolver);
    142     bb(nlpSolver, par);//do branch and bound
     172    par(nlp_and_solver);
     173    bb(nlp_and_solver, par);//do branch and bound
    143174
    144175    std::cout.precision(10);
     
    169200             <<bb.numNodes()<<"\t"
    170201             <<bb.iterationCount()<<"\t"
    171              <<nlpSolver->totalNlpSolveTime()<<"\t"
    172              <<nlpSolver->nCallOptimizeTNLP()<<"\t"
     202             <<nlp_and_solver->totalNlpSolveTime()<<"\t"
     203             <<nlp_and_solver->nCallOptimizeTNLP()<<"\t"
    173204             <<std::endl;
    174     nlpSolver->writeAmplSolFile(message,bb.bestSolution(),NULL);
     205    nlp_and_solver->writeAmplSolFile(message,bb.bestSolution(),NULL);
    175206
    176207  }
     
    181212    //Now depending on what algorithm has been called (B-BB or other) the failed problem may be at different place.
    182213    //    const OsiSolverInterface &si1 = (algo > 0) ? nlpSolver : *model.solver();
    183     writeNodeFiles(*nlpSolver, *nlpSolver);
     214    writeNodeFiles(*nlp_and_solver, *nlp_and_solver);
    184215  }
    185216  catch(OsiTMINLPInterface::SimpleError &E) {
     
    204235
    205236  delete [] pbName;
    206   delete nlpSolver;
     237  delete nlp_and_solver;
    207238  return 0;
    208239}
  • branches/devel/Bonmin/src/Apps/Makefile.am

    r86 r90  
    2727        ../CbcBonmin/libbonminbb.la \
    2828        ../OaInterface/liboainterface.la \
    29         ../IpoptInterface/libipoptinterface.la
     29        ../Interfaces/libbonmininterfaces.la
    3030
    3131libbonmin_la_LDFLAGS = $(LT_LDFLAGS)
  • branches/devel/Bonmin/src/Apps/Makefile.in

    r86 r90  
    7878libbonmin_la_DEPENDENCIES = ../CbcBonmin/libbonminbb.la \
    7979        ../OaInterface/liboainterface.la \
    80         ../IpoptInterface/libipoptinterface.la
     80        ../Interfaces/libbonmininterfaces.la
    8181am_libbonmin_la_OBJECTS =
    8282nodist_libbonmin_la_OBJECTS = CbcCompareUser.lo CbcBranchUser.lo
     
    350350        ../CbcBonmin/libbonminbb.la \
    351351        ../OaInterface/liboainterface.la \
    352         ../IpoptInterface/libipoptinterface.la
     352        ../Interfaces/libbonmininterfaces.la
    353353
    354354libbonmin_la_LDFLAGS = $(LT_LDFLAGS)
  • branches/devel/Bonmin/src/Interfaces/BonOsiTMINLPInterface.cpp

    r67 r90  
    1717#include <sstream>
    1818
     19#include "Ipopt/BonIpoptSolver.hpp"
     20#include "Filter/BonFilterSolver.hpp"
    1921
    2022using namespace Ipopt;
     
    7678
    7779  roptions->SetRegisteringCategory("bonmin branch-and-bound options");
     80
     81  roptions->AddStringOption2("nlp_solver",
     82      "Choice of the solver for continuous nlp's",
     83      "Ipopt",
     84      "Ipopt", "Interior Point OPTimizer (https://projects.coin-or.org/Ipopt)",
     85      "filterSQP", "Sequential quadratic programming trust region algorithm (http://www-unix.mcs.anl.gov/~leyffer/solvers.html)",
     86       "");
    7887
    7988  roptions->AddStringOption4("algorithm",
     
    305314  register_OA_options(roptions);
    306315  register_milp_sub_solver_options(roptions);
     316  //Register options for all possible solvers (besides the one used
     317  IpoptSolver * ipopt = dynamic_cast<IpoptSolver *> (GetRawPtr(app_));
     318  FilterSolver * filter = dynamic_cast<FilterSolver *> (GetRawPtr(app_));
     319
     320  if(!ipopt)
     321    {
     322      ipopt = new IpoptSolver;
     323      ipopt->RegisterOptions(app_->RegOptions());
     324      delete ipopt;
     325      ipopt = NULL;
     326    }
     327  if(!filter)
     328    {
     329      filter = new FilterSolver;
     330      filter->RegisterOptions(app_->RegOptions());
     331      delete filter;
     332      filter = NULL;
     333    }
     334                                               
    307335}
    308336
     
    311339():CoinMessages((int)OSITMINLPINTERFACE_DUMMY_END)
    312340{
    313   strcpy(source_ ,"IpOp");
     341  strcpy(source_ ,"NLP");
    314342  addMessage(SOLUTION_FOUND, CoinOneMessage
    315343      (1,2,"After %d tries found a solution of %g "
     
    409437{}
    410438
     439/** Constructor with given IpSolver and TMINLP */
     440OsiTMINLPInterface::OsiTMINLPInterface (Ipopt::SmartPtr<Bonmin::TNLPSolver> app):
     441    OsiSolverInterface(),
     442    tminlp_(NULL),
     443    problem_(NULL),
     444    rowsense_(NULL),
     445    rhs_(NULL),
     446    rowrange_(NULL),
     447    reducedCosts_(NULL),
     448    OsiDualObjectiveLimit_(1e200),
     449//    optimization_status_(HasNotBeenOptimized),
     450    varNames_(NULL),
     451    hasVarNamesFile_(true),
     452    nCallOptimizeTNLP_(0),
     453    totalNlpSolveTime_(0),
     454    totalIterations_(0),
     455    maxRandomRadius_(1e08),
     456    pushValue_(1e-02),
     457    numRetryInitial_(-1),
     458    numRetryResolve_(-1),
     459    numRetryUnsolved_(1),
     460    messages_(),
     461    pretendFailIsInfeasible_(false),
     462    hasContinuedAfterNlpFailure_(false),
     463    numIterationSuspect_(-1),
     464    hasBeenOptimized_(false),
     465    obj_(NULL),
     466    feasibilityProblem_(NULL),
     467    jRow_(NULL),
     468    jCol_(NULL),
     469    jValues_(NULL),
     470    nnz_jac(0),
     471    constTypes_(NULL),
     472//    constTypesNum_(NULL),
     473    nLinear_(0),
     474    nNonLinear_(0),
     475    tiny_(1e-08),
     476    veryTiny_(1e-17),
     477    infty_(1e100)
     478{
     479  app_ = app->createNew();
     480
     481  Ipopt::SmartPtr<Ipopt::RegisteredOptions> roptions = app_->RegOptions();
     482  register_ALL_options(roptions);
     483  app_->Initialize("bonmin.opt");
     484  extractInterfaceParams();
     485
     486}
    411487
    412488/** Constructor with given IpSolver and TMINLP */
  • branches/devel/Bonmin/src/Interfaces/BonOsiTMINLPInterface.hpp

    r67 r90  
    118118  /// Default Constructor
    119119  OsiTMINLPInterface();
    120   /** Constructor with given (user) TMINLP.
     120   /** Constructor with given (user) TMINLP.
    121121    \warning In this constructor option file is not read, use readOptionFile to read one.
    122122  */
    123123  OsiTMINLPInterface (Ipopt::SmartPtr<Bonmin::TMINLP> tminlp,
    124124                      Ipopt::SmartPtr<Bonmin::TNLPSolver> app);
     125
     126 /** Constructor with specified application and empty problem just usefull to get the options and nothing else */
     127  OsiTMINLPInterface (Ipopt::SmartPtr<Bonmin::TNLPSolver> app);
    125128
    126129  /** Facilitator to allocate a tminlp and an application. */
  • branches/devel/Bonmin/src/Interfaces/BonTMINLP2TNLP.cpp

    r83 r90  
    272272      Index m, Number* g_l, Number* g_u)
    273273  {
    274     IpBlasDcopy(n, x_l_, 1, x_l, 1);
    275     IpBlasDcopy(n, x_u_, 1, x_u, 1);
     274    DBG_ASSERT(n==n_);
     275    DBG_ASSERT(m==m_);
     276    IpBlasDcopy(n_, x_l_, 1, x_l, 1);
     277    IpBlasDcopy(n_, x_u_, 1, x_u, 1);
    276278    IpBlasDcopy(m_, g_l_, 1, g_l, 1);
    277279    IpBlasDcopy(m_, g_u_, 1, g_u, 1);
  • branches/devel/Bonmin/src/Interfaces/BonTMINLP2TNLP.hpp

    r86 r90  
    226226        Index m, Number* g_l, Number* g_u);
    227227
     228    /** Returns the constraint linearity.
     229     * array should be alocated with length at least n. (default implementation
     230     *  just return false and does not fill the array).*/
     231    virtual bool get_constraints_linearity(Index m, LinearityType* const_types)
     232    {
     233      return tminlp_->get_constraints_linearity(m, const_types);
     234    }
    228235    /** Method called by Ipopt to get the starting point. The bools
    229236     *  init_x and init_lambda are both inputs and outputs. As inputs,
  • branches/devel/Bonmin/src/Interfaces/BonTNLPSolver.hpp

    r83 r90  
    126126   virtual Ipopt::SmartPtr<Ipopt::OptionsList> Options() = 0;
    127127
     128   /// Register this solver options into passed roptions
     129   virtual void RegisterOptions(Ipopt::SmartPtr<Ipopt::RegisteredOptions> roptions) = 0;
     130
    128131   /// Get the CpuTime of the last optimization.
    129132   virtual double CPUTime() = 0;
  • branches/devel/Bonmin/src/Interfaces/Filter/BonFilterSolver.cpp

    r86 r90  
    3232static real * g;
    3333//Permutation to apply to jacobian in order to get it row ordered
    34 static int * permutation = NULL;
     34static int * permutationJac = NULL;
     35static int * permutationHess = NULL;
    3536//static int * cache = NULL;
    3637
     
    9596  for(int i = 0 ; i < nnz ; i++)
    9697    {
    97       int indice = permutation[i];
     98      int indice = permutationJac[i];
    9899      if(indice > nnz)
    99100        {
    100101          std::cout<<"Error in gradient computation, i: "<<i
    101                    <<" in row order "<<permutation[i]<<std::endl;
     102                   <<" in row order "<<permutationJac[i]<<std::endl;
    102103         }
    103104      *a++ = values[indice];
     
    122123  *li_hess = nnz_h + *n + 3;
    123124  end = *n + *m;
    124   for(int i = *n ; i < end ; i++)
     125  //std::cout<<"lambda"<<std::endl;
     126  for(int i = *n ; i < end ; i++){
    125127    g[i] = - lam[i];
    126   tnlpSolved->eval_h(*n, x, 1, obj_factor, *m, g + *n ,1, hStruct[0] - 1, NULL, NULL, ws);
     128   // std::cout<<lam[i]<<"\t";
     129   }
     130  //std::cout<<std::endl;
     131  real * values = new real [nnz_h];
     132  tnlpSolved->eval_h(*n, x, 1, obj_factor, *m, g + *n ,1, hStruct[0] - 1, NULL, NULL, values);
     133   for(int i = 0 ; i < nnz_h ; i++) ws[i] = values[permutationHess[i]];
     134   delete [] values;
    127135}
    128136
     
    183191    long int * start = inds + nnz + offset;
    184192   
    185     for(fint i = 0 ; i < nnz ; i++)
     193    Transposer lt;
     194    lt.rowIndices = iCol;
     195    lt.colIndices = iRow;
     196
     197    std::sort(permutationHess, permutationHess + nnz, lt);
     198
     199   for(fint i = 0 ; i < nnz ; i++)
    186200      {
    187         inds[offset + i] = iRow[i];
    188         DBG_ASSERT(iCol[i] >= col);
    189         if(iCol[i] >= col) {
    190           for(;col <= iCol[i] ; col++)
     201        inds[offset + i] = iRow[permutationHess[i]];
     202        DBG_ASSERT(iCol[permutationHess[i]] >= col);
     203        if(iCol[permutationHess[i]] >= col) {
     204          for(;col <= iCol[permutationHess[i]] ; col++)
    191205            *start++ = i + offset + 1;
    192206        }
     
    200214
    201215void
    202 FilterSolver::registerAllOptions(){
    203   roptions_->SetRegisteringCategory("FilterSQP options");
    204   roptions_->AddLowerBoundedNumberOption("eps", "Tolerance for SQP solver",
     216FilterSolver::RegisterOptions(Ipopt::SmartPtr<Ipopt::RegisteredOptions> roptions){
     217  roptions->SetRegisteringCategory("FilterSQP options");
     218  roptions->AddLowerBoundedNumberOption("eps", "Tolerance for SQP solver",
    205219                                        0., 1, 1e-06, "");
    206   roptions_->AddLowerBoundedNumberOption("infty","A large number (1E20)",0.,1, 1e20, "");
    207   roptions_->AddBoundedIntegerOption("iprint", "Print level (0=silent, 3=verbose)", 0,6,0);
    208   roptions_->AddLowerBoundedIntegerOption("kmax", "Dimension of null-space",
    209                                          0,500, "");
    210   roptions_->AddLowerBoundedIntegerOption("maxf","Maximum filter length",0,100);
    211   roptions_->AddLowerBoundedIntegerOption("maxiter", "Maximum number of iterations",0,1000);
    212   roptions_->AddLowerBoundedIntegerOption("mlp","Maximum level for degeneracy (bqpd)",0, 1000);
    213   roptions_->AddLowerBoundedIntegerOption("mxlws", "FINTEGER workspace increment", 0, 50000);
    214   roptions_->AddLowerBoundedIntegerOption("mxws", "REAL workspace increment",
    215                                         0,20000);
    216   roptions_->AddLowerBoundedNumberOption("rho", "Initial trust region size",0,1,10.);
     220  roptions->AddLowerBoundedNumberOption("infty","A large number (1E20)",0.,1, 1e20, "");
     221  roptions->AddBoundedIntegerOption("iprint", "Print level (0=silent, 3=verbose)", 0,6,0);
     222  roptions->AddLowerBoundedIntegerOption("kmax", "Dimension of null-space",
     223                                 0, 500, "");
     224  roptions->AddLowerBoundedIntegerOption("maxf","Maximum filter length",0,100);
     225  roptions->AddLowerBoundedIntegerOption("maxiter", "Maximum number of iterations",0,1000);
     226  roptions->AddLowerBoundedIntegerOption("mlp","Maximum level for degeneracy (bqpd)",0, 1000);
     227  roptions->AddLowerBoundedIntegerOption("mxlws", "FINTEGER workspace increment", 0, 500000);
     228  roptions->AddLowerBoundedIntegerOption("mxws", "REAL workspace increment",
     229                                        0,2000000);
     230  roptions->AddLowerBoundedNumberOption("rho", "Initial trust region size",0,1,10.);
    217231  //  roption->AddLowerBoundedIntegerOption("timing", "whether to time evaluations (1 = yes)");
    218   roptions_->AddLowerBoundedNumberOption("tt", "Parameter for upper bound on filter",0,1, 125e-2);
    219   roptions_->AddLowerBoundedNumberOption("ubd", "Parameter for upper bound on filter", 0 , 1,1e2);
    220 
    221   /** Options taken from Ipopt code Algorithm/IpWarmStartInitializaer. */
    222   roptions_->AddLowerBoundedNumberOption(
    223                                         "warm_start_bound_push",
    224                                         "same as bound_push for the regular initializer.",
    225                                         0.0, true, 1e-3);
    226   roptions_->AddBoundedNumberOption(
    227                                    "warm_start_bound_frac",
    228                                    "same as bound_frac for the regular initializer.",
    229                                    0.0, true, 0.5, false, 1e-3);
    230 
    231   /** Options taken from Ipopt: Interfaces/IpIpoptApplication.cpp */
    232       roptions_->AddStringOption2(
    233       "print_user_options",
    234       "Print all options set by the user.",
    235       "no",
    236       "no", "don't print options",
    237       "yes", "print options",
    238       "If selected, the algorithm will print the list of all options set by "
    239       "the user including their values and whether they have been used.");
    240 
    241     roptions_->AddStringOption2(
    242       "print_options_documentation",
    243       "Switch to print all algorithmic options.",
    244       "no",
    245       "no", "don't print list",
    246       "yes", "print list",
    247       "If selected, the algorithm will print the list of all available "
    248       "algorithmic options with some documentation before solving the "
    249       "optimization problem.");
    250 
    251 }
     232  roptions->AddLowerBoundedNumberOption("tt", "Parameter for upper bound on filter",0,1, 125e-2);
     233  roptions->AddLowerBoundedNumberOption("ubd", "Parameter for upper bound on filter", 0 , 1,1e2);
     234
     235 }
    252236
    253237
     
    262246    journalist_->AddFileJournal("console", "stdout", Ipopt::J_ITERSUMMARY);
    263247 
    264   registerAllOptions();
     248  RegisterOptions();
    265249
    266250  options_->SetJournalist(journalist_);
     
    345329  g = cached_->g_;
    346330//Permutation to apply to jacobian in order to get it row ordered
    347   permutation = cached_->transposed;
     331  permutationJac = cached_->transposed;
    348332
    349333
     
    371355  // 1.b) then from options
    372356  options->GetIntegerValue("kmax", (Ipopt::Index&) kmax, "filter.");
    373 
     357  kmax = min(kmax,n);
    374358  options->GetIntegerValue("mlp", (Ipopt::Index&) mlp,"filter.");
    375359
     
    383367
    384368  // Setup storage for Filter
    385 
     369  double infty = nlp_eps_inf__.infty;
     370  int nplusm = n + m;
    386371  //Starting point
    387372  x = new real [n];
    388373
    389374  tnlp->get_starting_point(n, 1, x, 0, NULL, NULL, m, 0, NULL);
    390  
     375  //for(int i = 0 ; i < n ; i++) x[i] = 0;
    391376  lam = new real [n+m];
    392377  g = g_ = new real[n+m];
     
    395380  bounds = new real [2*n + 2*m];
    396381 
    397   tnlp->get_bounds_info(n, bounds, &bounds[n+m], m, &bounds[n], &bounds[2*n + m]);
     382  tnlp->get_bounds_info(n, bounds, bounds + nplusm, m, bounds + n, bounds + n + nplusm);
     383
     384  for(int i = 0 ; i < nplusm ; i++){
     385  if(bounds[i] < -infty) bounds[i] = - infty;}
     386
     387  real * ubounds = bounds + nplusm;
     388  for(int i = 0 ; i < nplusm ; i++){
     389  if(ubounds[i] > infty) ubounds[i] = infty;}
     390
    398391  maxa = n + nnz_jac_g;
    399392  fint maxia = n + nnz_jac_g + m + 3;
     
    410403  tnlp->eval_jac_g( (int) n, NULL, 0,(int) m , (int) nnz_jac_g,  RowJac,  ColJac, NULL);
    411404
    412   permutation = transposed = new int [nnz_jac_g];
     405  permutationJac = transposed = new int [nnz_jac_g];
    413406  TMat2RowPMat(n, m, nnz_jac_g,  RowJac, ColJac, transposed,
    414407               la, n);
    415408
    416409
    417   for(int i = 0 ; i < nnz_jac_g ; i++){
    418     std::cout<<RowJac[transposed[i]];}
    419 
    420 
    421410  delete [] RowJac;
    422411  delete [] ColJac;
    423412
    424413  // Now setup hessian
    425  
    426   hStruct_ = new fint[nnz_h + m + 3];
     414  permutationHess = new int[nnz_h];
     415  for(int i = 0 ; i < nnz_h ; i++) permutationHess[i] = i;
     416  hStruct_ = new fint[nnz_h + n + 3];
    427417  int * cache = new int[2*nnz_h + 1];
    428418  hessc_.phl = 1;
    429   tnlp->eval_h((Ipopt::Index&) n, NULL, 0, 1., (Ipopt::Index&) m, NULL, 0, (Ipopt::Index&) nnz_h, cache , cache + nnz_h , NULL);
     419  tnlp->eval_h((Ipopt::Index&) n, NULL, 0, 1., (Ipopt::Index&) m, NULL, 0, (Ipopt::Index&) nnz_h, cache + nnz_h, cache , NULL);
    430420
    431421  TMat2ColPMat(n, m, nnz_h, cache, cache + nnz_h,
     
    439429
    440430  ws = new real[maxWk];
     431  for(int i = 0 ; i < maxWk ; i++) ws[i] = 0;
    441432  lws = new fint[maxiWk];
     433  for(int i = 0 ; i < maxiWk ; i++) lws[i] = 0;
    442434
    443435  // Setup global variables and static variables
     
    468460  nout = 6;
    469461  cstype = new char[m];
     462  Ipopt::TNLP::LinearityType * const_types =
     463        new Ipopt::TNLP::LinearityType[m];
     464  tnlp->get_constraints_linearity(m, const_types);
    470465  for(int i = 0 ; i < m ; i++)
    471      cstype[i] = 'N';
     466  {
     467    if(const_types[i] == Ipopt::TNLP::LINEAR){
     468     cstype[i] = 'L';}
     469    else
     470     cstype[i] = 'N';
     471  }
     472  delete [] const_types;
    472473  c = new double[m];
    473474  tnlp_ = Ipopt::GetRawPtr(tnlp);
  • branches/devel/Bonmin/src/Interfaces/Filter/BonFilterSolver.hpp

    r86 r90  
    120120    return solverName_;}
    121121
     122   /// Register this solver options into passed roptions
     123   void RegisterOptions(){
     124   RegisterOptions(roptions_);}
     125
     126   /// Register this solver options into passed roptions
     127   virtual void RegisterOptions(Ipopt::SmartPtr<Ipopt::RegisteredOptions> roptions);
    122128private:
    123129  /** @name Private function members. */
     
    125131  /** Perform optimization using data structure in cache. */
    126132  TNLPSolver::ReturnStatus callOptimizer();
    127 
    128   void registerAllOptions();
    129  
    130133  /** @} */
    131134  /** Register all the options for filter. */
     
    219222
    220223    cachedInfo(const Ipopt::SmartPtr<Ipopt::TNLP> &tnlp,
    221                Ipopt::SmartPtr<Ipopt::OptionsList>& options)
    222     {
     224               Ipopt::SmartPtr<Ipopt::OptionsList>& options):
     225     n(-1),
     226     m(-1),
     227     nnz_h_(-1),
     228     kmax(-1),
     229     maxa(-1),
     230     maxf(-1),
     231     mlp(-1),
     232     maxWk(-1),
     233     maxiWk(-1),
     234     iprint(-1),
     235     nout(6),
     236     ifail(0),
     237     rho(0),
     238      x(NULL),
     239      c(NULL),
     240     f(1e100),
     241     fmin(-1e100),
     242      bounds(NULL),
     243     s(NULL),
     244      a(NULL),
     245      la(NULL),
     246      ws(NULL),
     247      lws(NULL),
     248      lam(NULL),
     249     g_(NULL),
     250     cstype(NULL),
     251     maxiter(1000),
     252     istat(NULL),
     253     rstat(NULL),
     254     tnlp_(NULL),
     255     hStruct_(NULL),
     256     transposed(NULL),
     257     cpuTime_(0)   {
    223258      initialize(tnlp, options);
    224259    }
  • branches/devel/Bonmin/src/Interfaces/Ipopt/BonIpoptSolver.hpp

    r86 r90  
    110110    return solverName_;}
    111111
     112   /// Register this solver options into passed roptions
     113   virtual void RegisterOptions(Ipopt::SmartPtr<Ipopt::RegisteredOptions> roptions){
     114   app_.RegisterAllIpoptOptions(roptions);
     115  // app_.RegisterOptions(roptions);
     116   }
     117
     118
    112119
    113120  /// Return status of last optimization
  • branches/devel/Bonmin/src/Interfaces/Makefile.am

    r86 r90  
    3737libbonmininterfaces_la_LIBADD = Ipopt/libipoptinterface.la \
    3838                              Ampl/libamplinterface.la
     39
    3940if COIN_HAS_FSQP
    4041libbonmininterfaces_la_LIBADD += Filter/libfilterinterface.la
    4142endif
    4243
    43 libbonmininterfaces_la_DEPENDENCIES = $(libipoptinterface_la_LIBADD)
     44libbonmininterfaces_la_DEPENDENCIES = $(libbonmininterfaces_la_LIBADD)
    4445
    4546# This is for libtool (on Windows)
  • branches/devel/Bonmin/src/Interfaces/Makefile.in

    r86 r90  
    339339libbonmininterfaces_la_LIBADD = Ipopt/libipoptinterface.la \
    340340        Ampl/libamplinterface.la $(am__append_2)
    341 libbonmininterfaces_la_DEPENDENCIES = $(libipoptinterface_la_LIBADD)
     341libbonmininterfaces_la_DEPENDENCIES = $(libbonmininterfaces_la_LIBADD)
    342342
    343343# This is for libtool (on Windows)
  • branches/devel/Bonmin/test/InterfaceTest.cpp

    r67 r90  
    1313#include "BonAmplTMINLP.hpp"
    1414#include "IpIpoptApplication.hpp"
     15
     16#include "BonIpoptSolver.hpp"
     17#include "BonminConfig.h"
     18
     19#ifdef COIN_HAS_FSQP
     20#include "BonFilterSolver.hpp"
     21#endif
     22#include <cmath>
    1523
    1624using namespace Bonmin;
     
    8896   
    8997    assert(si.isProvenOptimal());
    90     assert(si.nCallOptimizeTNLP()==1);
     98//    assert(si.nCallOptimizeTNLP()==1);
    9199    assert(si.getIterationCount()>0);
    92100    // Optimum of the problem is -( 3/2 + sqrt(5)/2)
     
    178186                 
    179187      const double * rowUp = lp.getRowUpper();
    180       assert(eq(rowUp[0], 1./2. + 3./(2 * sqrt(5))));
     188      double sqrt5 = sqrt(5);
     189      if(!eq(rowUp[0], 1./2. + 3./(2 * sqrt5))){
     190        double error = fabs(rowUp[0] - 1./2. - 3./(2 * sqrt5));
     191        std::cout<<"Error in OA for rowUp[0]: "
     192                 <<error<<std::endl;
     193      }
    181194      assert(eq(rowUp[1], 0.));
    182195      assert(eq(rowUp[2], 2.));
     
    204217        {
    205218        assert(inds[k]==mat->getIndices()[j]);
    206         assert(eq(vals[k],mat->getElements()[j]));
     219        if(!eq(vals[k],mat->getElements()[j])){
     220        double error = fabs(vals[k] - mat->getElements()[j]);
     221        std::cout<<"Error in OA for element of constraint matrix "<<k<<": "
     222                 <<error<<std::endl;
     223        if(error > 1e-06) throw -1;
     224      }
    207225          k++;
    208226        }
     
    221239       assert(eq(si.getColSolution()[1],(1./2.)));
    222240}
    223 void interfaceTest()
     241void interfaceTest(Ipopt::SmartPtr<TNLPSolver> solver)
    224242{
    225243  /**********************************************************************************/
    226244  /*   Test constructors                                                                                                              */
    227245  /**********************************************************************************/
    228   std::cout<<"Test OsiTMINLPInterface with Ipopt solver"<<std::endl;
     246  std::cout<<"Test OsiTMINLPInterface with "
     247           <<solver->solverName()<<" solver"<<std::endl;
    229248  // Test usefull constructor
    230249  {
     
    244263       
    245264        //Setup Ipopt should be replaced if solver is changed
    246         using namespace Ipopt;
    247       SmartPtr<Bonmin::IpoptSolver> app = new Bonmin::IpoptSolver();
    248265       const char * args[3] ={"name","mytoy",NULL}; //Ugly, but I don't know how to do differently
    249266       const char ** argv = args;
    250       SmartPtr<TMINLP> ampl_tminlp = new AmplTMINLP(ConstPtr(app->getIpoptApp().Jnlst()), app->Options(), const_cast<char**&>(argv));
    251       OsiTMINLPInterface si(ampl_tminlp, new IpoptSolver);
     267      AmplInterface si(const_cast<char **&> (argv), solver);
    252268    std::cout<<"---------------------------------------------------------------------------------------------------------------------------------------------------------"
    253269    <<std::endl<<"Testing usefull constructor"<<std::endl
     
    275291       
    276292        //Setup Ipopt should be replaced if solver is changed
    277         using namespace Ipopt;
    278       SmartPtr<Ipopt::IpoptApplication> app = new Ipopt::IpoptApplication();
    279293      const char * args[3] ={"name","mytoy",NULL}; //Ugly, but I don't know how to do differently
    280294      const char ** argv = args;
    281       SmartPtr<TMINLP> ampl_tminlp = new AmplTMINLP(ConstPtr(app->Jnlst()),  app->Options(), const_cast<char**&>(argv));
    282       OsiTMINLPInterface si1(ampl_tminlp, new IpoptSolver);
     295      AmplInterface si1(const_cast<char **&> (argv), solver);
    283296     
    284297      OsiTMINLPInterface si(si1);
     
    295308  {
    296309        //Setup Ipopt should be replaced if solver is changed
    297         using namespace Ipopt;
    298310        const char * args[3] ={"name","mytoy",NULL}; //Ugly, but I don't know how to do differently
    299311        const char ** argv = args;
    300       Bonmin::AmplInterface si(const_cast<char**&>(argv));
     312      Bonmin::AmplInterface si(const_cast<char**&>(argv), solver);
    301313      std::cout<<"---------------------------------------------------------------------------------------------------------------------------------------------------------"
    302314               <<std::endl<<"Testing outer approximations related methods"<<std::endl
     
    324336int main()
    325337{
    326     interfaceTest();
    327     return 0;
    328 }
     338  Ipopt::SmartPtr<IpoptSolver> ipopt_solver = new IpoptSolver;
     339  interfaceTest(GetRawPtr(ipopt_solver));
     340
     341#ifdef COIN_HAS_FSQP
     342  Ipopt::SmartPtr<FilterSolver> filter_solver = new FilterSolver;
     343  interfaceTest(GetRawPtr(filter_solver));
     344#endif
     345  return 0;
     346}
Note: See TracChangeset for help on using the changeset viewer.