Changeset 81


Ignore:
Timestamp:
Oct 23, 2006 12:01:16 PM (12 years ago)
Author:
pbonami
Message:

Fixes for filter. Now passes the unitTest

Location:
branches/devel/Bonmin/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Bonmin/src/Apps/BonMin.cpp

    r67 r81  
    2020
    2121#include "BonAmplInterface.hpp"
     22#include "BonFilterSolver.hpp"
    2223#include "BonCbc.hpp"
    2324
     
    127128  else //will just output usage
    128129  {
    129     nlpSolver = new AmplInterface(argv);
     130    Ipopt::SmartPtr<TNLPSolver> ipoptSolver = new IpoptSolver;
     131    nlpSolver = new AmplInterface(argv, ipoptSolver);
    130132    delete nlpSolver;
    131133    return 0;
     
    133135  double time1 = CoinCpuTime();
    134136  try {
    135   nlpSolver = new AmplInterface(argv);
     137  Ipopt::SmartPtr<TNLPSolver> filterSolver = new FilterSolver;
     138  nlpSolver = new AmplInterface(argv, filterSolver);
    136139    BonminCbcParam par;
    137140    Bab bb;
  • branches/devel/Bonmin/src/Apps/nodeSolver.cpp

    r67 r81  
    2020
    2121#include "BonAmplInterface.hpp"
    22 
     22#include "BonIpoptSolver.hpp"
    2323#include "BonBoundsReader.hpp"
    2424#include "BonStartPointReader.hpp"
     
    3636
    3737  using namespace Ipopt;
     38  using namespace Bonmin;
    3839
    3940  // Read in model using argv[1]
     
    5657
    5758
    58   Bonmin::AmplInterface nlpSolver(myArgv);
     59  Bonmin::AmplInterface nlpSolver(myArgv, new IpoptSolver);
    5960
    6061  Ipopt::SmartPtr<Ipopt::OptionsList> Options =
  • branches/devel/Bonmin/src/BonminAmplInterface/BonAmplInterface.cpp

    r67 r81  
    6666
    6767    // set the default options... expect_infeasible, etc...
    68     IpoptSolver * ipopt = dynamic_cast<IpoptSolver *> (GetRawPtr(app_));
    6968    if (!IsValid(tminlp_)) {
    70       amplTminlp_ = new AmplTMINLP(ConstPtr(ipopt->getIpoptApp().Jnlst()), app_->Options(), filename,
     69      amplTminlp_ = new AmplTMINLP(Ipopt::ConstPtr(app_->Jnlst()), app_->Options(), filename,
    7170          NULL, appName() , nl_file_content);
    7271      tminlp_ = GetRawPtr(amplTminlp_);
     
    7675      if (amplTMINLP) {
    7776        AmplTMINLP * newAmpl = amplTMINLP->createEmpty();
    78         newAmpl->Initialize(ConstPtr(ipopt->getIpoptApp().Jnlst()), app_->Options(), filename,
     77        newAmpl->Initialize(ConstPtr(app_->Jnlst()), app_->Options(), filename,
    7978            NULL, appName() , nl_file_content);
    8079        amplTminlp_ = newAmpl;
     
    8281      }
    8382      else {
    84         amplTminlp_ = new AmplTMINLP(ConstPtr(ipopt->getIpoptApp().Jnlst()), app_->Options(), filename,
     83        amplTminlp_ = new AmplTMINLP(ConstPtr(app_->Jnlst()), app_->Options(), filename,
    8584            NULL, appName() , nl_file_content);
    8685        tminlp_ = GetRawPtr(amplTminlp_);
     
    9998      categories.push_back("bonmin options : B-Hyb specific options");
    10099//    roptions->OutputLatexOptionDocumentation2(*app_->Jnlst(),categories);
    101       roptions->OutputOptionDocumentation(*(ipopt->getIpoptApp().Jnlst()),categories);
     100      roptions->OutputOptionDocumentation(*(Ipopt::ConstPtr(app_->Jnlst())),categories);
    102101    }
    103102
  • branches/devel/Bonmin/src/BonminAmplInterface/BonAmplInterface.hpp

    r70 r81  
    1414    AmplInterface();
    1515    /** Constructor with inputed ampl command line (reads model from nl file)*/
    16     AmplInterface(char **& amplArgs, Ipopt::SmartPtr<TNLPSolver> app = new IpoptSolver);
     16    AmplInterface(char **& amplArgs, Ipopt::SmartPtr<TNLPSolver> app);
    1717    /** Copy constructor */
    1818    AmplInterface(const AmplInterface &other);
  • branches/devel/Bonmin/src/IpoptInterface/BonFilterSolver.cpp

    r67 r81  
    22#include <fstream>
    33
    4 
    5 
     4#include "CoinTime.hpp"
     5#include<algorithm>
    66typedef Bonmin::FilterSolver::fint fint;
    77typedef Bonmin::FilterSolver::real real;
     
    1010
    1111typedef long ftnlen;
    12 
     12extern "C" {
    1313void filtersqp_(
    1414        fint *n, fint *m, fint *kmax, fint *maxa,
     
    2121        real *rstat, ftnlen cstype_len);
    2222
     23 void fopen_ (fint*, char*, ftnlen);
     24}
    2325
    2426//Static variables
     
    2729
    2830static fint * hStruct = NULL;
     31
     32static real * g;
     33//Permutation to apply to jacobian in order to get it row ordered
     34static int * permutation = NULL;
    2935//static int * cache = NULL;
    3036
     
    8389  tnlpSolved->eval_grad_f(*n, x, 1, a);
    8490  /// ATTENTION: Filter expect the jacobian to be ordered by row
    85   tnlpSolved->eval_jac_g(*n, x, 1, *m, la[0] - *n, NULL, NULL, &a[*n]);
     91  int nnz = la[0] - *n - 1;
     92  double * values = new double [nnz];
     93  tnlpSolved->eval_jac_g(*n, x, 1, *m, nnz, NULL, NULL, values);
     94  a+= *n;
     95  for(int i = 0 ; i < nnz ; i++)
     96    {
     97      int indice = permutation[i];
     98      if(indice > nnz)
     99        {
     100          std::cout<<"Error in gradient computation, i: "<<i
     101                   <<" in row order "<<permutation[i]<<std::endl;
     102         }
     103      *a++ = values[indice];
     104    }
     105  delete [] values;
    86106}
    87107
     
    92112             fint *l_hess, fint *li_hess, fint *errflag)
    93113{
    94   real obj_factor = (*phase == 1)? 1. : 0.;
    95   fint * begin = hStruct;
    96   fint * end = begin + 2 * begin[0];
    97   *lws++ = *begin++;
    98 
    99   for( ; begin != end ; lws += 2, begin += 2)
     114  real obj_factor = (*phase == 1)? 0. : 1.;
     115  fint  end = nnz_h + (*n)  + 2;
     116
     117  for(int i = 0 ; i < end ; i++)
    100118    {
    101       lws[0] = begin[0];
    102       lws[1] = begin[1];
     119      lws[i] = hStruct[i];
    103120    }
    104   tnlpSolved->eval_h(*n, x, 1, obj_factor, *m, &lam[*n],1, hStruct[0], NULL, NULL, ws);
     121  *l_hess = nnz_h;
     122  *li_hess = nnz_h + *n + 3;
     123  end = *n + *m;
     124  for(int i = *n ; i < end ; i++)
     125    g[i] = - lam[i];
     126  tnlpSolved->eval_h(*n, x, 1, obj_factor, *m, g + *n ,1, hStruct[0] - 1, NULL, NULL, ws);
    105127}
    106128
     
    108130
    109131namespace Bonmin{
     132
     133
     134  struct Transposer{
     135    int *rowIndices;
     136    int * colIndices;
     137    bool operator()(int i, int j){
     138      return rowIndices[i]<rowIndices[j] ||
     139        (rowIndices[i]==rowIndices[j] && colIndices[i] < colIndices[j]);}
     140  };
     141
     142
     143  // Convert a sparse matrix from triplet format to row ordered packed matrix
     144  void TMat2RowPMat(int n, int m, int nnz, int * iRow, int* iCol, int * permutation2,
     145                    long int * lws, int offset)
     146  {
     147    for(int i = 0 ; i < nnz ; i++)
     148      permutation2[i] = i;
     149
     150
     151    Transposer lt;
     152    lt.rowIndices = iRow;
     153    lt.colIndices = iCol;
     154
     155    std::sort(permutation2, &permutation2[nnz], lt);
     156
     157    fint row = 1;
     158    lws[0] = nnz + offset + 1;
     159    long int * inds = lws + 1;
     160    long int * start = inds + nnz + offset + 1;
     161   
     162    for(fint i = 0 ; i < nnz ; i++)
     163      {
     164        inds[offset + i] = iCol[permutation2[i]];
     165        DBG_ASSERT(RowJac[permutation2[i]] >= row);
     166        if(iRow[permutation2[i]] >= row) {
     167          for(;row <= iRow[permutation2[i]] ; row++)
     168            *start++ = i + offset + 1;
     169        }
     170      }
     171    for(;row <= m+1 ; row++)
     172      *start++ = nnz + offset +1;
     173
     174  }
     175
     176  // Convert a sparse matrix from triplet format to row ordered packed matrix
     177  void TMat2ColPMat(int n, int m, int nnz, int * iRow, int* iCol,
     178                    long int * lws, int offset)
     179  {
     180    fint col = 1;
     181    lws[0] = nnz + offset + 1;
     182    long int * inds = lws + 1;
     183    long int * start = inds + nnz + offset;
     184   
     185    for(fint i = 0 ; i < nnz ; i++)
     186      {
     187        inds[offset + i] = iRow[i];
     188        DBG_ASSERT(iCol[i] >= col);
     189        if(iCol[i] >= col) {
     190          for(;col <= iCol[i] ; col++)
     191            *start++ = i + offset + 1;
     192        }
     193      }
     194    for(;col <= n+1 ; col++)
     195      *start++ = nnz + offset +1;
     196
     197  }
     198
     199  std::string FilterSolver::solverName_ = "filter SQP";
    110200
    111201void
     
    115205                                        0., 1, 1e-06, "");
    116206  roptions_->AddLowerBoundedNumberOption("infty","A large number (1E20)",0.,1, 1e20, "");
    117   roptions_->AddBoundedIntegerOption("iprint", "Print level (0=silent, 3=verbose)", 0,3,0);
     207  roptions_->AddBoundedIntegerOption("iprint", "Print level (0=silent, 3=verbose)", 0,6,0);
    118208  roptions_->AddLowerBoundedIntegerOption("kmax", "Dimension of null-space",
    119209                                         0,500, "");
     
    121211  roptions_->AddLowerBoundedIntegerOption("maxiter", "Maximum number of iterations",0,1000);
    122212  roptions_->AddLowerBoundedIntegerOption("mlp","Maximum level for degeneracy (bqpd)",0, 1000);
    123   roptions_->AddLowerBoundedIntegerOption("mxlws", "FINTEGER workspace increment", 0, 500000);
     213  roptions_->AddLowerBoundedIntegerOption("mxlws", "FINTEGER workspace increment", 0, 50000);
    124214  roptions_->AddLowerBoundedIntegerOption("mxws", "REAL workspace increment",
    125                                         0,200000);
     215                                        0,20000);
    126216  roptions_->AddLowerBoundedNumberOption("rho", "Initial trust region size",0,1,10.);
    127217  //  roption->AddLowerBoundedIntegerOption("timing", "whether to time evaluations (1 = yes)");
    128218  roptions_->AddLowerBoundedNumberOption("tt", "Parameter for upper bound on filter",0,1, 125e-2);
    129219  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
    130251}
    131252
     
    210331  assert(tnlp == cached_->tnlp_);
    211332  cached_->ifail = -1;
     333  //rescan bounds which may have changed
     334  assert(cached_->bounds);
     335  int n = cached_->n;
     336  int m = cached_->m;
     337  tnlp->get_bounds_info(n, cached_->bounds, &cached_->bounds[n+m],
     338                        m, &cached_->bounds[n], &cached_->bounds[2*n + m]);
     339
     340  tnlpSolved = static_cast<Ipopt::TNLP *>(Ipopt::GetRawPtr(tnlp));
     341  nnz_h = cached_->nnz_h_;
     342
     343  hStruct = cached_->hStruct_;
     344
     345  g = cached_->g_;
     346//Permutation to apply to jacobian in order to get it row ordered
     347  permutation = cached_->transposed;
     348
     349
    212350  return callOptimizer();
    213351}
     352
    214353
    215354
     
    224363  Ipopt::TNLP::IndexStyleEnum index_style;
    225364  tnlp->get_nlp_info((Ipopt::Index&) n,(Ipopt::Index&) m,
    226                      (Ipopt::Index&) nnz_jac_g, (Ipopt::Index&) nnz_h,
     365                     (Ipopt::Index&) nnz_jac_g, (Ipopt::Index&) nnz_h_,
    227366                     index_style);
    228367
    229 
     368  nnz_h = nnz_h_;
    230369 
    231370
     
    251390 
    252391  lam = new real [n+m];
    253  
     392  g = g_ = new real[n+m];
     393  for(int i = 0 ; i < n+m ; i++) lam[i] = g_[i] = 0.;
    254394  //bounds
    255395  bounds = new real [2*n + 2*m];
     
    260400  a = new real[maxa];
    261401  la = new fint [maxia];
    262   fint * start = & la[nnz_jac_g + 1];
     402
    263403  int * RowJac = new int [nnz_jac_g]; 
    264404  int * ColJac = new int [nnz_jac_g];
    265405 
    266   la[0] = nnz_jac_g + n + 1;
    267 
    268   *start++ = 1;
     406  la[nnz_jac_g + n + 1] = 1;
    269407
    270408  for(fint i = 1; i <= n ; i++)
     
    272410  tnlp->eval_jac_g( (int) n, NULL, 0,(int) m , (int) nnz_jac_g,  RowJac,  ColJac, NULL);
    273411
    274   fint row = -1;
    275   for(fint i = 0 ; i < nnz_jac_g ; i++)
    276     {
    277       la[1+n+i] = ColJac[i];
    278       DBG_ASSERT(RowJac[i] >= row);
    279       if(RowJac[i] > row) {
    280         for(row++; row <= RowJac[i] ; row++)
    281           *start++ = i + n + 1;
    282       }
    283     }
    284   for(row++; row <= m ; row++)
    285     *start++ = nnz_jac_g + n +1;
     412  permutation = transposed = new int [nnz_jac_g];
     413  TMat2RowPMat(n, m, nnz_jac_g,  RowJac, ColJac, transposed,
     414               la, n);
     415
     416
     417  for(int i = 0 ; i < nnz_jac_g ; i++){
     418    std::cout<<RowJac[transposed[i]];}
     419
    286420
    287421  delete [] RowJac;
    288422  delete [] ColJac;
    289423
    290   // Now setup hession
    291  
    292   hStruct_ = new fint[2 * nnz_h + 1];
    293   int * cache = new int[2*nnz_h];
    294   hStruct_[0] = nnz_h + 1;
     424  // Now setup hessian
     425 
     426  hStruct_ = new fint[nnz_h + m + 3];
     427  int * cache = new int[2*nnz_h + 1];
    295428  hessc_.phl = 1;
    296429  tnlp->eval_h((Ipopt::Index&) n, NULL, 0, 1., (Ipopt::Index&) m, NULL, 0, (Ipopt::Index&) nnz_h, cache , cache + nnz_h , NULL);
    297430
    298   int end = 2 * nnz_h;
    299   for(int i = 1 ; i <= end ; i++)
    300     {
    301       hStruct_[i] = cache[i];
    302     }
     431  TMat2ColPMat(n, m, nnz_h, cache, cache + nnz_h,
     432               hStruct_, 0);
    303433
    304434  delete [] cache;
     
    325455
    326456
     457  // Set up scaling
     458  scalec_.scale_mode = 0;
     459  s = new real [n+m];
     460 
    327461  istat = new fint[14];
    328462  rstat = new real[7];
    329463
    330464  fmin = -1e100;
    331   options->GetIntegerValue("iprint",(Ipopt::Index &) iprint, "filter.");
     465  Ipopt::Index bufy;
     466  options->GetIntegerValue("iprint",bufy, "filter.");
     467  iprint = bufy;
     468  nout = 6;
    332469  cstype = new char[m];
    333470  for(int i = 0 ; i < m ; i++)
     
    378515    break;
    379516  }
     517  int end = cached_->n + cached_->m;
     518  for(int i = cached_->n ; i < end ; i++)
     519    cached_->g_[i] = - cached_->lam[i];
    380520
    381521  cached_->tnlp_->finalize_solution(status, cached_->n,
    382522                          cached_->x, cached_->lam, cached_->lam,
    383                           cached_->m, cached_->c, cached_->lam + cached_->n,
     523                          cached_->m, cached_->c, cached_->g_ + cached_->n,
    384524                          cached_->f);
    385525  return optimizationStatus;
     
    390530FilterSolver::cachedInfo::optimize()
    391531{
     532  cpuTime_ = - CoinCpuTime();
    392533  fint cstype_len = 1;
    393534  filtersqp_(&n, &m, &kmax, & maxa, &maxf, &mlp, &maxWk,
     
    395536             c, &f, &fmin, bounds,
    396537             bounds + n + m,
    397              NULL, a, la,
     538             s, a, la,
    398539             ws, lws, lam, cstype,
    399540             NULL, NULL,
    400541             &maxiter, istat, rstat,
    401542             cstype_len);
    402 }
     543   cpuTime_ += CoinCpuTime();
     544}
     545
     546std::string
     547FilterSolver::UnsolvedFilterError::errorNames_[1] =
     548{"Internal error in Filter SQP."};
     549
     550std::string
     551FilterSolver::UnsolvedFilterError::solverName_ =
     552          "filterSqp";
     553
     554const std::string&
     555FilterSolver::UnsolvedFilterError::errorName() const
     556{ return errorNames_[0];}
     557
     558const std::string&
     559FilterSolver::UnsolvedFilterError::solverName() const
     560{ return solverName_;}
     561
    403562
    404563
  • branches/devel/Bonmin/src/IpoptInterface/BonFilterSolver.hpp

    r72 r81  
    1313#include "BonTNLPSolver.hpp"
    1414
     15#include "CoinWarmStartBasis.hpp"
    1516namespace Bonmin{
    1617class FilterSolver : public TNLPSolver{
    1718public:
     19  class UnsolvedFilterError: public TNLPSolver::UnsolvedError
     20{
     21 public:
     22  UnsolvedFilterError(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 ~UnsolvedFilterError(){}
     29  private:
     30  static std::string errorNames_[1];
     31  static std::string solverName_;
     32};
     33
     34  virtual UnsolvedError * newUnsolvedError(int num){
     35    return new UnsolvedFilterError(num);}
     36
     37
     38
    1839    typedef long fint;
    1940    typedef double real;
     
    4061   /// Resolves a problem expresses as a TNLP
    4162   virtual ReturnStatus ReOptimizeTNLP(const Ipopt::SmartPtr<Ipopt::TNLP> & tnlp);
     63
     64  /// Set the warm start in the solver
     65  virtual bool setWarmStart(const CoinWarmStart * warm,
     66                            Ipopt::SmartPtr<TMINLP2TNLP> tnlp){
     67   return 1;}
     68
     69  /// Get the warm start form the solver
     70  virtual CoinWarmStart * getWarmStart(Ipopt::SmartPtr<TMINLP2TNLP> tnlp) const{
     71   return new CoinWarmStartBasis;}
     72
     73  virtual CoinWarmStart * getEmptyWarmStart() const {
     74  return new CoinWarmStartBasis;}
     75
    4276
    4377  virtual void enableWarmStart()
     
    4781   //@}
    4882
    49    ///Get a pointer to RegisteredOptions (generally used to add new ones)
    50    virtual Ipopt::SmartPtr<Ipopt::RegisteredOptions> RegOptions();
    51 
    52    /// Get the options (for getting theur values).
    53    virtual Ipopt::SmartPtr<const Ipopt::OptionsList> Options() const;
    54 
    55    /// Get the options (for getting and setting their values).
    56    virtual Ipopt::SmartPtr<Ipopt::OptionsList> Options();
     83  /// Virtual constructor
     84  virtual TNLPSolver * createNew(){
     85    return new FilterSolver;}
     86
     87  ///Get a pointer to a journalist
     88  virtual Ipopt::SmartPtr<Ipopt::Journalist> Jnlst(){
     89    return journalist_;}
     90
     91  ///Get a pointer to RegisteredOptions (generally used to add new ones)
     92  virtual Ipopt::SmartPtr<Ipopt::RegisteredOptions> RegOptions(){
     93    return roptions_;}
     94 
     95  /// Get the options (for getting theur values).
     96  virtual Ipopt::SmartPtr<const Ipopt::OptionsList> Options() const{
     97    return ConstPtr(options_);}
     98 
     99  /// Get the options (for getting and setting their values).
     100  virtual Ipopt::SmartPtr<Ipopt::OptionsList> Options(){
     101    return options_;}
    57102
    58103   /// Get the CpuTime of the last optimization.
    59    virtual double CPUTime();
     104   virtual double CPUTime(){
     105   return (Ipopt::IsValid(cached_)) ? cached_->cpuTime_: 0.;}
    60106
    61107   /// Get the iteration count of the last optimization.
    62    virtual int IterationCount();
     108   virtual int IterationCount(){
     109   return (Ipopt::IsValid(cached_)) ? cached_->istat[1]:0;}
    63110
    64111  /// turn off all output from the solver
     
    68115  virtual void turnOnOutput()
    69116  {if(Ipopt::IsValid(cached_)) cached_->iprint = 3;}
     117
     118  /// Get the solver name
     119  virtual std::string & solverName(){
     120    return solverName_;}
     121
    70122private:
    71123  /** @name Private function members. */
     
    88140  /** Registered Options */
    89141  Ipopt::SmartPtr<Ipopt::RegisteredOptions> roptions_;
    90 
     142 
    91143
    92144
     
    95147    fint n;
    96148    fint m;
     149    fint nnz_h_;
    97150    fint kmax;
    98151    fint maxa;
     
    110163    real fmin;
    111164    real * bounds;
     165    real * s;
    112166    real * a;
    113167    fint * la;
     
    115169    fint * lws;
    116170    real * lam;
     171    real * g_;
    117172    char * cstype;
    118173    fint maxiter;
     
    121176    Ipopt::TNLP * tnlp_;
    122177    fint * hStruct_;
     178    int * transposed;
     179    /** Elapsed CPU time in last optimization. */
     180    double cpuTime_;
    123181
    124182
     
    127185     n(-1),
    128186     m(-1),
     187     nnz_h_(-1),
    129188     kmax(-1),
    130189     maxa(-1),
     
    134193     maxiWk(-1),
    135194     iprint(-1),
    136      nout(-1),
     195     nout(6),
    137196     ifail(-100),
    138197     rho(0),
     
    142201     fmin(-1e100),
    143202      bounds(NULL),
     203     s(NULL),
    144204      a(NULL),
    145205      la(NULL),
     
    147207      lws(NULL),
    148208      lam(NULL),
     209     g_(NULL),
    149210     cstype(NULL),
    150211     maxiter(1000),
     
    152213     rstat(NULL),
    153214     tnlp_(NULL),
    154      hStruct_(NULL)
     215     hStruct_(NULL),
     216     transposed(NULL),
     217     cpuTime_(0)
    155218    {}
    156219
     
    173236      delete []c;
    174237      delete [] bounds;
     238      delete [] s;
    175239      delete [] a;
    176240      delete [] la;
     
    178242      delete [] lws;
    179243      delete [] lam;
     244      delete [] g_;
    180245      delete [] cstype;     
    181246      delete [] istat;
    182247      delete [] rstat;
     248      delete [] transposed;
    183249      delete [] hStruct_;
    184250      tnlp_ = NULL;
    185251    }
    186252  };
     253
     254  /** Cached information on last problem optimized for reoptimization. */
    187255  Ipopt::SmartPtr<cachedInfo> cached_;
     256
     257  //name of solver (Filter)
     258  static std::string  solverName_; 
    188259};
    189260
  • branches/devel/Bonmin/src/IpoptInterface/BonIpoptSolver.cpp

    r67 r81  
    1717
    1818namespace Bonmin{
     19
     20  std::string IpoptSolver::solverName_ = "Ipopt";
     21
     22
    1923  IpoptSolver::~IpoptSolver(){}
    2024
     
    8084      return solverReturnStatus(optimizationStatus_);
    8185  }
     86
     87  Ipopt::SmartPtr<Ipopt::Journalist>
     88  IpoptSolver::Jnlst()
     89  {return app_.Jnlst();}
    8290
    8391  Ipopt::SmartPtr<Ipopt::RegisteredOptions>
  • branches/devel/Bonmin/src/IpoptInterface/BonIpoptSolver.hpp

    r67 r81  
    8383  //@}
    8484
     85  ///Get a pointer to a journalist
     86  virtual Ipopt::SmartPtr<Ipopt::Journalist> Jnlst();
     87
    8588  ///Get a pointer to RegisteredOptions (generally used to add new ones)
    8689  virtual Ipopt::SmartPtr<Ipopt::RegisteredOptions> RegOptions();
     
    102105  /// turn on all output from the solver
    103106  virtual void turnOnOutput();
     107
     108  /// Get the solver name
     109  virtual std::string & solverName(){
     110    return solverName_;}
     111
    104112
    105113  /// Return status of last optimization
     
    132140  */
    133141  int warmStartStrategy_;
     142
     143  //name of solver (Ipopt)
     144  static std::string  solverName_;
    134145};
    135146}
  • branches/devel/Bonmin/src/IpoptInterface/BonTMINLP.hpp

    r64 r81  
    165165        Index& nnz_h_lag, TNLP::IndexStyleEnum& index_style)=0;
    166166
     167    /** overload this method to return scaling parameters. This is
     168     *  only called if the options are set to retrieve user scaling.
     169     *  There, use_x_scaling (or use_g_scaling) should get set to true
     170     *  only if the variables (or constraints) are to be scaled.  This
     171     *  method should return true only if the scaling parameters could
     172     *  be provided.
     173     */
     174    virtual bool get_scaling_parameters(Number& obj_scaling,
     175                                        bool& use_x_scaling, Index n,
     176                                        Number* x_scaling,
     177                                        bool& use_g_scaling, Index m,
     178                                        Number* g_scaling)
     179    {
     180      return false;
     181    }
     182
     183
    167184    /** overload this method to set the variable type. The var_types
    168185     *  array will be allocated with length n. */
  • branches/devel/Bonmin/src/IpoptInterface/BonTMINLP2TNLP.cpp

    r65 r81  
    567567  }
    568568
     569  bool
     570  TMINLP2TNLP::get_scaling_parameters(Number& obj_scaling,
     571                                        bool& use_x_scaling, Index n,
     572                                        Number* x_scaling,
     573                                        bool& use_g_scaling, Index m,
     574                                        Number* g_scaling)
     575  {
     576    return tminlp_->get_scaling_parameters(obj_scaling, use_x_scaling, n,
     577                                  x_scaling,
     578                                  use_g_scaling, m, g_scaling);
     579  }
     580                                 
     581
     582
     583
    569584}
    570585// namespace Ipopt
  • branches/devel/Bonmin/src/IpoptInterface/BonTMINLP2TNLP.hpp

    r55 r81  
    237237        Index m, bool init_lambda,
    238238        Number* lambda);
     239
     240    /** Method that returns scaling parameters.
     241     */
     242    virtual bool get_scaling_parameters(Number& obj_scaling,
     243                                        bool& use_x_scaling, Index n,
     244                                        Number* x_scaling,
     245                                        bool& use_g_scaling, Index m,
     246                                        Number* g_scaling);
     247
    239248
    240249    /** Methat that returns an Ipopt IteratesVector that has the
  • branches/devel/Bonmin/src/IpoptInterface/BonTNLPSolver.hpp

    r67 r81  
    114114   //@}
    115115
     116  ///Get a pointer to a journalist
     117  virtual Ipopt::SmartPtr<Ipopt::Journalist> Jnlst() = 0;
     118
    116119   ///Get a pointer to RegisteredOptions (generally used to add new ones)
    117120   virtual Ipopt::SmartPtr<Ipopt::RegisteredOptions> RegOptions() = 0;
     
    134137  /// turn on all output from the solver
    135138  virtual void turnOnOutput() = 0;
    136 
     139  /// Get the solver name
     140  virtual std::string & solverName() = 0;
    137141protected:
    138142  bool zeroDimension(const Ipopt::SmartPtr<Ipopt::TNLP> &tnlp,
Note: See TracChangeset for help on using the changeset viewer.