/home/coin/SVN-release/OS-1.1.1/Bonmin/src/Interfaces/Ipopt/BonIpoptSolver.hpp

Go to the documentation of this file.
00001 // (C) Copyright International Business Machines (IBM) 2005, 2007
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Authors :
00006 // Pierre Bonami, IBM
00007 //
00008 // Date : 26/09/2006
00009 
00010 #ifndef IpoptSolver_HPP
00011 #define IpoptSolver_HPP
00012 #include "BonTNLPSolver.hpp"
00013 #include "IpIpoptApplication.hpp"
00014 
00015 
00016 namespace Bonmin
00017 {
00018   class IpoptSolver: public TNLPSolver
00019   {
00020   public:
00021   class UnsolvedIpoptError: public TNLPSolver::UnsolvedError
00022     {
00023     public:
00024       UnsolvedIpoptError(int errorNum,
00025           Ipopt::SmartPtr<TMINLP2TNLP> problem,
00026           std::string name):
00027           TNLPSolver::UnsolvedError(errorNum, problem, name)
00028       {}
00029       virtual const std::string& errorName() const;
00030 
00031       virtual const std::string& solverName() const;
00032       virtual ~UnsolvedIpoptError()
00033       {}
00034     private:
00035       static std::string errorNames [17];
00036       static std::string solverName_;
00037     };
00038 
00039     virtual UnsolvedError * newUnsolvedError(int num,
00040         Ipopt::SmartPtr<TMINLP2TNLP> problem,
00041         std::string name)
00042     {
00043       return new UnsolvedIpoptError(num, problem, name);
00044     }
00045 
00046 
00047 
00049     IpoptSolver(bool createEmpty = false);
00050 
00052     IpoptSolver(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions,
00053         Ipopt::SmartPtr<Ipopt::OptionsList> options,
00054         Ipopt::SmartPtr<Ipopt::Journalist> journalist);
00055 
00056 
00058     virtual Ipopt::SmartPtr<TNLPSolver> clone();
00059 
00061     virtual ~IpoptSolver();
00062 
00065     virtual bool Initialize(std::string params_file);
00066 
00069     virtual bool Initialize(std::istream& is);
00070 
00073 
00074     virtual TNLPSolver::ReturnStatus OptimizeTNLP(const Ipopt::SmartPtr<Ipopt::TNLP> & tnlp);
00075 
00077     virtual TNLPSolver::ReturnStatus ReOptimizeTNLP(const Ipopt::SmartPtr<Ipopt::TNLP> & tnlp);
00078 
00080     virtual bool setWarmStart(const CoinWarmStart * warm,
00081         Ipopt::SmartPtr<TMINLP2TNLP> tnlp);
00082 
00084    virtual CoinWarmStart * getUsedWarmStart(Ipopt::SmartPtr<TMINLP2TNLP> tnlp) const;
00085 
00086 
00088     virtual CoinWarmStart * getWarmStart(Ipopt::SmartPtr<Bonmin::TMINLP2TNLP> tnlp) const;
00089 
00090     virtual CoinWarmStart * getEmptyWarmStart() const;
00091 
00093     virtual bool warmStartIsValid(const CoinWarmStart * ws) const;
00094 
00096     virtual void enableWarmStart();
00097 
00099     virtual void disableWarmStart();
00100 
00102 
00104     virtual double CPUTime();
00105 
00107     virtual int IterationCount();
00108 
00110     virtual void turnOffOutput();
00112     virtual void turnOnOutput();
00113 
00115     virtual std::string & solverName()
00116     {
00117       return solverName_;
00118     }
00119 
00121     static void RegisterOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions)
00122     {
00123       Ipopt::IpoptApplication::RegisterAllIpoptOptions(GetRawPtr(roptions));
00124     }
00125 
00126 
00127 
00129     Ipopt::ApplicationReturnStatus getOptStatus() const
00130     {
00131       return optimizationStatus_;
00132     }
00133 
00134     Ipopt::IpoptApplication& getIpoptApp()
00135     {
00136       return *app_;
00137     }
00138 
00139     virtual int errorCode() const
00140     {
00141       return (int) optimizationStatus_;
00142     }
00143   private:
00145     void setMinlpDefaults(Ipopt::SmartPtr< Ipopt::OptionsList> Options);
00146 
00148     TNLPSolver::ReturnStatus solverReturnStatus(Ipopt::ApplicationReturnStatus optimization_status) const;
00149 
00151     Ipopt::SmartPtr<Ipopt::IpoptApplication> app_;
00153     Ipopt::ApplicationReturnStatus optimizationStatus_;
00155 
00156 
00158     bool problemHadZeroDimension_;
00159 
00167     int warmStartStrategy_;
00168 
00170     bool enable_warm_start_;
00171 
00174     bool optimized_before_;
00175     //name of solver (Ipopt)
00176     static std::string  solverName_;
00177   };
00178 }
00179 #endif
00180 

Generated on Tue Sep 30 03:01:24 2008 by  doxygen 1.4.7