source: branches/devel/Bonmin/src/Interfaces/Ipopt/BonIpoptSolver.hpp @ 104

Last change on this file since 104 was 90, checked in by pbonami, 13 years ago

Bug fixes in interface for filter

File size: 4.1 KB
Line 
1// (C) Copyright International Business Machines (IBM) 2005
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// Authors :
6// Pierre Bonami, IBM
7//
8// Date : 26/09/2006
9
10#ifndef IpoptSolver_HPP
11#define IpoptSolver_HPP
12#include "BonTNLPSolver.hpp"
13#include "IpIpoptApplication.hpp"
14
15
16namespace Bonmin{
17class IpoptSolver: public TNLPSolver {
18public:
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
39  /// Constructor
40  IpoptSolver():
41    app_(),
42    warmStartStrategy_(1)
43  {}
44
45  ///virtual constructor
46  virtual TNLPSolver * createNew();
47
48
49  /// Virtual destructor
50  virtual ~IpoptSolver();
51
52  /** Initialize the TNLPSolver (read options from params_file)
53  */
54  virtual void Initialize(std::string params_file);
55
56  /** Initialize the TNLPSolver (read options from istream is)
57  */
58  virtual void Initialize(std::istream& is);
59
60  /** @name Solve methods */
61  //@{
62  /// Solves a problem expresses as a TNLP
63  virtual TNLPSolver::ReturnStatus OptimizeTNLP(const Ipopt::SmartPtr<Ipopt::TNLP> & tnlp);
64
65  /// Resolves a problem expresses as a TNLP
66  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
83  //@}
84
85  ///Get a pointer to a journalist
86  virtual Ipopt::SmartPtr<Ipopt::Journalist> Jnlst();
87
88  ///Get a pointer to RegisteredOptions (generally used to add new ones)
89  virtual Ipopt::SmartPtr<Ipopt::RegisteredOptions> RegOptions();
90
91  /// Get the options (for getting their values).
92  virtual Ipopt::SmartPtr<const Ipopt::OptionsList> Options() const;
93
94   /// Get the options (for getting and setting their values).
95   virtual Ipopt::SmartPtr<Ipopt::OptionsList> Options();
96
97   /// Get the CpuTime of the last optimization.
98   virtual double CPUTime();
99
100   /// Get the iteration count of the last optimization.
101   virtual int IterationCount();
102
103  /// turn off all output from the solver
104  virtual void turnOffOutput();
105  /// turn on all output from the solver
106  virtual void turnOnOutput();
107
108  /// Get the solver name
109  virtual std::string & solverName(){
110    return solverName_;}
111
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
119
120  /// Return status of last optimization
121  Ipopt::ApplicationReturnStatus getOptStatus() const
122  {
123    return optimizationStatus_;
124  }
125
126  Ipopt::IpoptApplication& getIpoptApp(){
127    return app_;
128  }
129  private:
130  /** Set default Ipopt parameters for use in a MINLP */
131  void setMinlpDefaults(Ipopt::SmartPtr< Ipopt::OptionsList> Options);
132
133  /** get Bonmin return status from Ipopt one. */
134  TNLPSolver::ReturnStatus solverReturnStatus(Ipopt::ApplicationReturnStatus optimization_status) const;
135  /** Ipopt application */
136  Ipopt::IpoptApplication app_;
137  /** return status of last optimization.*/
138  Ipopt::ApplicationReturnStatus optimizationStatus_;
139    //@}
140
141  /** Warm start strategy :
142  <ol>
143  <li> no warm start,</li>
144  <li> simple warm start (optimal point),</li>
145  <li> more elaborate strategies (interior point...).</li>
146  </ol>
147  */
148  int warmStartStrategy_;
149
150  //name of solver (Ipopt)
151  static std::string  solverName_;
152};
153}
154#endif
155
Note: See TracBrowser for help on using the repository browser.