/home/coin/SVN-release/OS-2.1.1/Bonmin/src/Interfaces/Filter/BonBqpdSolver.hpp

Go to the documentation of this file.
00001 // (C) Copyright International Business Machines Corporation, 2007
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Authors :
00006 // Andreas Waechter, International Business Machines Corporation
00007 //                    based on BonFilterSolver.cpp
00008 //
00009 // Date : 07/09/2007
00010 
00011 #ifndef BonBqpdSolver_H
00012 #define BonBqpdSolver_H
00013 
00014 #include "BonTNLPSolver.hpp"
00015 #include "BonBranchingTQP.hpp"
00016 
00017 namespace Bonmin
00018 {
00019   class BqpdSolver : public TNLPSolver
00020   {
00021   public:
00022     friend class FilterSolver;
00023 
00024   class UnsolvedBqpdError: public TNLPSolver::UnsolvedError
00025     {
00026     public:
00027       UnsolvedBqpdError(int errorNum,
00028           Ipopt::SmartPtr<TMINLP2TNLP> model,
00029           const std::string &name):
00030           TNLPSolver::UnsolvedError(errorNum, model, name)
00031       {}
00032       virtual const std::string& errorName() const;
00033 
00034       virtual const std::string& solverName() const;
00035       virtual ~UnsolvedBqpdError()
00036       {}
00037 
00038     private:
00039       static std::string errorNames_[1];
00040       static std::string solverName_;
00041     };
00042 
00044     typedef ipfint fint;
00046     typedef double real;
00047 
00048     virtual UnsolvedError*
00049     newUnsolvedError(int num,
00050         Ipopt::SmartPtr<TMINLP2TNLP> problem,
00051         std::string name)
00052     {
00053       return new UnsolvedBqpdError(num, problem, name);
00054     }
00055 
00057     BqpdSolver(bool createEmpty = false);
00058 
00060     BqpdSolver(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions,
00061         Ipopt::SmartPtr<Ipopt::OptionsList> options,
00062         Ipopt::SmartPtr<Ipopt::Journalist> journalist,
00063         const std::string & prefix
00064               );
00065 
00067     virtual ~BqpdSolver();
00068 
00071     virtual bool Initialize(std::string params_file);
00072 
00075     virtual bool Initialize(std::istream& is);
00076 
00079 
00080     virtual ReturnStatus OptimizeTNLP(const Ipopt::SmartPtr<Ipopt::TNLP> & tnlp);
00081 
00083     virtual ReturnStatus ReOptimizeTNLP(const Ipopt::SmartPtr<Ipopt::TNLP> & tnlp);
00084 
00086     virtual bool setWarmStart(const CoinWarmStart * warm,
00087         Ipopt::SmartPtr<TMINLP2TNLP> tnlp);
00088 
00092     virtual bool markHotStart(){return cached_->markHotStart();}
00093 
00095     virtual CoinWarmStart * getUsedWarmStart(Ipopt::SmartPtr<TMINLP2TNLP> tnlp) const{
00096       throw CoinError(__PRETTY_FUNCTION__,"","Not implemented");
00097     }
00098 
00100     virtual CoinWarmStart * getWarmStart(Ipopt::SmartPtr<TMINLP2TNLP> tnlp) const;
00101 
00102     virtual CoinWarmStart * getEmptyWarmStart() const;
00103 
00105     virtual bool warmStartIsValid(const CoinWarmStart * ws) const;
00106 
00107     virtual void enableWarmStart()
00108     {//No options to be set
00109     }
00110     virtual void disableWarmStart()
00111     {//No options to be set
00112     }
00114 
00116     virtual SmartPtr<TNLPSolver> clone();
00117 
00119     virtual double CPUTime()
00120     {
00121       return (Ipopt::IsValid(cached_)) ? cached_->cpuTime_: 0.;
00122     }
00123 
00125     virtual int IterationCount()
00126     {
00127       return 0;
00128     }
00129 
00130 
00131     // turn off all output from the solver
00132     virtual void setOutputToDefault()
00133     {
00134       if (Ipopt::IsValid(cached_)) cached_->iprint = default_log_level_;
00135     }
00137     virtual void forceSolverOutput(int log_level)
00138     {
00139       if (Ipopt::IsValid(cached_)) cached_->iprint = log_level;
00140     }
00141     
00143     virtual std::string & solverName()
00144     {
00145       return solverName_;
00146     }
00147 
00149     void registerOptions()
00150     {
00151       registerOptions(roptions_);
00152     }
00153 
00155     virtual int errorCode() const
00156     {
00157       return -1;
00158     }
00160     static void registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
00161   private:
00165     TNLPSolver::ReturnStatus callOptimizer();
00171     double fillin_factor_;
00172     int kmax_ipt_;
00173     int mlp_ipt_;
00175 
00177   struct cachedInfo : public Ipopt::ReferencedObject
00178     {
00179       fint n;
00180       fint m;
00181       fint k;
00182       fint kmax;
00183       real* a;
00184       fint* la;
00185       real* x;
00186       real* bl;
00187       real* bu;
00188       real f;
00189       real* g;
00190       real* r;
00191       real* w;
00192       real* e;
00193       fint* ls;
00194       real* alp;
00195       fint* lp;
00196       fint mlp;
00197       fint peq;
00198       real* ws;
00199       fint* lws;
00200       fint m0de;
00201       fint ifail;
00202       fint info[1];
00203       fint iprint;
00204       fint nout;
00205 
00207       fint kk,ll,mxws,mxlws;
00208 
00210       bool haveHotStart_;
00214 
00215       fint irh1,na,na1,nb,nb1,ka1,kb1,kc1,irg1,lu1,lv,lv1,ll1;
00217       real eps,tol,emin;
00219       real vstep;
00221       real sgnf;
00222       fint nrep,npiv,nres;
00224       fint nup,nfreq;
00226       real alpha;
00228       fint ns,ns1,nt,nt1,nu,nu1,nx,nx1,np,np1,nprof,lc;
00229       fint lc1,li,li1,lm,lm1,lp_,lp1,lq,lq1,lr,lr1,ls_,ls1,lt,lt1;
00231       fint m1,m2,mp,mq,lastr,irow;
00233       fint mxm1;
00235       real c;
00237       fint kHot;
00238       real* xHot;
00239       real fHot;
00240       real* gHot;
00241       real* rHot;
00242       real* wHot;
00243       real* eHot;
00244       fint* lsHot;
00245       real* alpHot;
00246       fint* lpHot;
00247       fint peqHot;
00248       real* wsHot;
00249       fint* lwsHot;
00250       fint infoHot[1];
00251       fint kkkHot;
00252       fint lllHot;
00253 
00254       Ipopt::SmartPtr<BranchingTQP> tqp_;
00256       double cpuTime_;
00259       bool use_warm_start_in_cache_;
00260       bool bad_warm_start_info_;
00261 
00263       int amax_;
00264 
00268       double* fillin_factor_;
00270 
00272       cachedInfo()
00273           :
00274           a(NULL),
00275           la(NULL),
00276           x(NULL),
00277           bl(NULL),
00278           bu(NULL),
00279           g(NULL),
00280           r(NULL),
00281           w(NULL),
00282           e(NULL),
00283           ls(NULL),
00284           alp(NULL),
00285           lp(NULL),
00286           ws(NULL),
00287           lws(NULL),
00288           haveHotStart_(false),
00289           xHot(NULL),
00290           gHot(NULL),
00291           rHot(NULL),
00292           wHot(NULL),
00293           eHot(NULL),
00294           lsHot(NULL),
00295           alpHot(NULL),
00296           lpHot(NULL),
00297           wsHot(NULL),
00298           lwsHot(NULL),
00299           cpuTime_(0),
00300           use_warm_start_in_cache_(false),
00301           bad_warm_start_info_(false)
00302       {}
00303 
00304       cachedInfo(const Ipopt::SmartPtr<BranchingTQP> &tqp,
00305                  Ipopt::SmartPtr<Ipopt::OptionsList>& options,
00306                  int kmax_ipt, int mlp_ipt, double* fillin_factor):
00307           a(NULL),
00308           la(NULL),
00309           x(NULL),
00310           bl(NULL),
00311           bu(NULL),
00312           g(NULL),
00313           r(NULL),
00314           w(NULL),
00315           e(NULL),
00316           ls(NULL),
00317           alp(NULL),
00318           lp(NULL),
00319           ws(NULL),
00320           lws(NULL),
00321           haveHotStart_(false),
00322           xHot(NULL),
00323           gHot(NULL),
00324           rHot(NULL),
00325           wHot(NULL),
00326           eHot(NULL),
00327           lsHot(NULL),
00328           alpHot(NULL),
00329           lpHot(NULL),
00330           wsHot(NULL),
00331           lwsHot(NULL),
00332           tqp_(tqp),
00333           cpuTime_(0),
00334           use_warm_start_in_cache_(false),
00335           bad_warm_start_info_(false)
00336       {
00337         initialize(tqp, options, kmax_ipt, mlp_ipt, fillin_factor);
00338       }
00339 
00341       void initialize(const Ipopt::SmartPtr<BranchingTQP> &tqp,
00342                       Ipopt::SmartPtr<Ipopt::OptionsList>& options,
00343                       int kmax_ipt, int mlp_ipt, double* fillin_factor);
00344 
00346       void optimize();
00347 
00349       bool markHotStart();
00350 
00352       void unmarkHotStart();
00353 
00355       void copyFromHotStart();
00356 
00358       ~cachedInfo();
00359     };
00360 
00362     Ipopt::SmartPtr<cachedInfo> cached_;
00363 
00364     //name of solver (Bqpd)
00365     static std::string  solverName_;
00366 
00368      int default_log_level_;
00369 
00370 
00371   };
00372 
00373 }// end namespace Bonmin
00374 #endif

Generated on Mon May 3 03:05:17 2010 by  doxygen 1.4.7