Ipopt  3.12.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpIpoptApplication.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2010 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpIpoptApplication.hpp 2690 2017-06-12 10:28:36Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8 
9 #ifndef __IPIPOPTAPPLICATION_HPP__
10 #define __IPIPOPTAPPLICATION_HPP__
11 
12 #ifndef IPOPT_EXPORT
13 #ifdef _MSC_VER
14 #ifdef IPOPT_DLL
15 #define IPOPT_EXPORT(type) __declspec(dllexport) type __cdecl
16 #else
17 #define IPOPT_EXPORT(type) type __cdecl
18 #endif
19 #else
20 #define IPOPT_EXPORT(type) type
21 #endif
22 #endif
23 
24 #include <iostream>
25 
26 #include "IpJournalist.hpp"
27 #include "IpTNLP.hpp"
28 #include "IpNLP.hpp"
29 /* Return codes for the Optimize call for an application */
30 #include "IpReturnCodes.hpp"
31 
32 namespace Ipopt
33 {
34  DECLARE_STD_EXCEPTION(IPOPT_APPLICATION_ERROR);
35 
36  /* forward declarations */
37  class IpoptAlgorithm;
38  class IpoptNLP;
39  class IpoptData;
40  class IpoptCalculatedQuantities;
41  class AlgorithmBuilder;
42  class RegisteredOptions;
43  class OptionsList;
44  class SolveStatistics;
45 
48  {
49  public:
50  IpoptApplication(bool create_console_out = true,
51  bool create_empty = false);
52 
56  SmartPtr<OptionsList> options,
57  SmartPtr<Journalist> jnlst);
58 
59  virtual ~IpoptApplication();
60 
65 
75  virtual ApplicationReturnStatus Initialize(std::istream& is, bool allow_clobber = false);
87  virtual ApplicationReturnStatus Initialize(std::string params_file, bool allow_clobber = false);
99  virtual ApplicationReturnStatus Initialize(const char* params_file, bool allow_clobber = false)
100  {
101  return Initialize(std::string(params_file), allow_clobber);
102  }
112  virtual ApplicationReturnStatus Initialize(bool allow_clobber = false);
113 
118 
121 
124 
131 
139 
142  virtual bool OpenOutputFile(std::string file_name, EJournalLevel print_level);
143 
148  {
149  return jnlst_;
150  }
151 
155  {
156  return reg_options_;
157  }
158 
161  {
162  return options_;
163  }
164 
167  {
168  return ConstPtr(options_);
169  }
170 
174 
177 
180 
183 
187 
192  void PrintCopyrightMessage();
193 
203  bool RethrowNonIpoptException(bool dorethrow)
204  {
205  bool oldval = rethrow_nonipoptexception_;
206  rethrow_nonipoptexception_ = dorethrow;
207  return oldval;
208  }
209 
212  static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
214 
216  static void
218 
219  private:
229  // IpoptApplication();
230 
233 
235  void operator=(const IpoptApplication&);
237 
241 
246 
250 
253 
256 
259 
263 
267 
271 
276 
281 
285 
294  };
295 
296 } // namespace Ipopt
297 
298 extern "C" IPOPT_EXPORT(class Ipopt::IpoptApplication *) IpoptApplicationFactory();
299 
300 #endif
SmartPtr< IpoptNLP > ip_nlp_
IpoptNLP Object for the NLP.
virtual SmartPtr< RegisteredOptions > RegOptions()
Get a pointer to RegisteredOptions object to add new options.
char Int print_level
static void RegisterOptions(SmartPtr< RegisteredOptions > roptions)
bool rethrow_nonipoptexception_
Decide whether non-ipopt non-bad_alloc exceptions should be rethrown.
SmartPtr< IpoptAlgorithm > AlgorithmObject()
Get the Algorithm Object.
virtual SmartPtr< Journalist > Jnlst()
Get the Journalist for printing output.
static void RegisterAllIpoptOptions(const SmartPtr< RegisteredOptions > &roptions)
Method to registering all Ipopt options.
virtual bool OpenOutputFile(std::string file_name, EJournalLevel print_level)
Method for opening an output file with given print_level.
EJournalLevel
Print Level Enum.
SmartPtr< OptionsList > options_
OptionsList used for the application.
virtual SmartPtr< IpoptNLP > IpoptNLPObject()
Get the IpoptNLP Object.
virtual ApplicationReturnStatus OptimizeNLP(const SmartPtr< NLP > &nlp)
Solve a problem that inherits from NLP.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
ReferencedObject class.
SmartPtr< RegisteredOptions > reg_options_
RegisteredOptions.
SmartPtr< Journalist > jnlst_
Journalist for reporting output.
bool RethrowNonIpoptException(bool dorethrow)
Method to set whether non-ipopt non-bad_alloc exceptions are rethrown by Ipopt.
virtual ApplicationReturnStatus ReOptimizeTNLP(const SmartPtr< TNLP > &tnlp)
Solve a problem (that inherits from TNLP) for a repeated time.
virtual SmartPtr< SolveStatistics > Statistics()
Get the object with the statistics about the most recent optimization run.
virtual SmartPtr< IpoptCalculatedQuantities > IpoptCQObject()
Get the IpoptCQ Object.
bool inexact_algorithm_
Flag indicating if we are to use the inexact linear solver option.
virtual SmartPtr< OptionsList > Options()
Get the options list for setting options.
bool read_params_dat_
Decide whether or not the ipopt.opt file should be read.
SmartPtr< SolveStatistics > statistics_
Object for storing statistics about the most recent optimization run.
SmartPtr< IpoptCalculatedQuantities > ip_cq_
IpoptCalculatedQuantities Object for the NLP.
ApplicationReturnStatus call_optimize()
Method for the actual optimize call of the Ipopt algorithm.
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:572
SmartPtr< IpoptAlgorithm > alg_
Object with the algorithm sceleton.
DECLARE_STD_EXCEPTION(SUFFIX_EMPTY)
void operator=(const IpoptApplication &)
Overloaded Equals Operator.
SmartPtr< IpoptData > IpoptDataObject()
Get the IpoptData Object.
virtual ApplicationReturnStatus OptimizeTNLP(const SmartPtr< TNLP > &tnlp)
Solve a problem that inherits from TNLP.
virtual ApplicationReturnStatus Initialize(const char *params_file, bool allow_clobber=false)
Initialization method.
ApplicationReturnStatus
Return codes for the Optimize call for an application.
virtual ApplicationReturnStatus ReOptimizeNLP(const SmartPtr< NLP > &nlp)
Solve a problem (that inherits from NLP) for a repeated time.
char * file_name
This is the main application class for making calls to Ipopt.
SmartPtr< IpoptData > ip_data_
IpoptData Object for the NLP.
SmartPtr< NLP > nlp_adapter_
Pointer to the TNLPAdapter used to convert the TNLP to an NLP.
IpoptApplication(bool create_console_out=true, bool create_empty=false)
bool replace_bounds_
Flag indicating if all bounds should be replaced by inequality constraints.
virtual ApplicationReturnStatus Initialize(std::istream &is, bool allow_clobber=false)
Initialization method.
void PrintCopyrightMessage()
Method for printing Ipopt copyright message now instead of just before the optimization.
virtual SmartPtr< const OptionsList > Options() const
Get the options list for setting options (const version)
virtual SmartPtr< IpoptApplication > clone()
Method for creating a new IpoptApplication that uses the same journalist and registered options...
#define IPOPT_EXPORT(type)