Ipopt Documentation  
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6 
7 #ifndef __IPIPOPTAPPLICATION_HPP__
8 #define __IPIPOPTAPPLICATION_HPP__
9 
10 #ifndef IPOPT_EXPORT
11 #ifdef _MSC_VER
12 #define IPOPT_EXPORT(type) type __cdecl
13 #else
14 #define IPOPT_EXPORT(type) type
15 #endif
16 #endif
17 
18 #include <iostream>
19 
20 #include "IpJournalist.hpp"
21 #include "IpTNLP.hpp"
22 #include "IpNLP.hpp"
23 /* Return codes for the Optimize call for an application */
24 #include "IpReturnCodes.hpp"
25 
26 namespace Ipopt
27 {
28 DECLARE_STD_EXCEPTION(IPOPT_APPLICATION_ERROR);
29 
30 /* forward declarations */
31 class IpoptAlgorithm;
32 class IpoptNLP;
33 class IpoptData;
34 class IpoptCalculatedQuantities;
35 class AlgorithmBuilder;
36 class RegisteredOptions;
37 class OptionsList;
38 class SolveStatistics;
39 
42 {
43 public:
45  bool create_console_out = true,
46  bool create_empty = false
47  );
48 
53  SmartPtr<RegisteredOptions> reg_options,
54  SmartPtr<OptionsList> options,
56  );
57 
58  virtual ~IpoptApplication();
59 
63  virtual SmartPtr<IpoptApplication> clone();
64 
78  virtual ApplicationReturnStatus Initialize(
79  std::istream& is,
80  bool allow_clobber = false
81  );
82 
100  virtual ApplicationReturnStatus Initialize(
101  std::string params_file,
102  bool allow_clobber = false
103  );
104 
123  const char* params_file,
124  bool allow_clobber = false
125  )
126  {
127  return Initialize(std::string(params_file), allow_clobber);
128  }
129 
144  virtual ApplicationReturnStatus Initialize(
145  bool allow_clobber = false
146  );
147 
149 
151  virtual ApplicationReturnStatus OptimizeTNLP(
152  const SmartPtr<TNLP>& tnlp
153  );
154 
156  virtual ApplicationReturnStatus OptimizeNLP(
157  const SmartPtr<NLP>& nlp
158  );
159 
161  virtual ApplicationReturnStatus OptimizeNLP(
162  const SmartPtr<NLP>& nlp,
163  SmartPtr<AlgorithmBuilder>& alg_builder
164  );
165 
173  virtual ApplicationReturnStatus ReOptimizeTNLP(
174  const SmartPtr<TNLP>& tnlp
175  );
176 
184  virtual ApplicationReturnStatus ReOptimizeNLP(
185  const SmartPtr<NLP>& nlp
186  );
188 
193  virtual bool OpenOutputFile(
194  std::string file_name,
195  EJournalLevel print_level
196  );
197 
199 
202  {
203  return jnlst_;
204  }
205 
208  {
209  return reg_options_;
210  }
211 
214  {
215  return options_;
216  }
217 
220  {
221  return ConstPtr(options_);
222  }
223 
227  virtual SmartPtr<SolveStatistics> Statistics();
228 
230  virtual SmartPtr<IpoptNLP> IpoptNLPObject();
231 
233  SmartPtr<IpoptData> IpoptDataObject();
234 
236  virtual SmartPtr<IpoptCalculatedQuantities> IpoptCQObject();
237 
239  SmartPtr<IpoptAlgorithm> AlgorithmObject();
241 
248  void PrintCopyrightMessage();
249 
261  bool dorethrow
262  )
263  {
264  bool oldval = rethrow_nonipoptexception_;
265  rethrow_nonipoptexception_ = dorethrow;
266  return oldval;
267  }
268 
269  static void RegisterOptions(
271  );
272 
274  static void
275  RegisterAllIpoptOptions(
276  const SmartPtr<RegisteredOptions>& roptions
277  );
278 
279 private:
287 
290  const IpoptApplication&
291  );
292 
294  void operator=(
295  const IpoptApplication&
296  );
298 
303  ApplicationReturnStatus call_optimize();
304 
306 
309 
313 
316 
319 
322 
327 
331 
337 
343 
349 
355 
357 
360 
368 };
369 
370 } // namespace Ipopt
371 
372 extern "C" IPOPTLIB_EXPORT IPOPT_EXPORT(class Ipopt::IpoptApplication*) IpoptApplicationFactory();
373 
374 #endif
SmartPtr< IpoptNLP > ip_nlp_
IpoptNLP Object for the NLP.
IPOPTLIB_EXPORT class Ipopt::IpoptApplication * IpoptApplicationFactory()
virtual SmartPtr< RegisteredOptions > RegOptions()
Get a pointer to RegisteredOptions object to add new options.
bool rethrow_nonipoptexception_
Decide whether non-ipopt non-bad_alloc exceptions should be rethrown.
DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER)
virtual SmartPtr< Journalist > Jnlst()
Get the Journalist for printing output.
EJournalLevel
Print Level Enum.
SmartPtr< OptionsList > options_
OptionsList used for the application.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:171
Storing the reference count of all the smart pointers that currently reference it.
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.
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.
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:665
#define IPOPTLIB_EXPORT
SmartPtr< IpoptAlgorithm > alg_
Object with the algorithm skeleton.
virtual ApplicationReturnStatus Initialize(const char *params_file, bool allow_clobber=false)
Initialization method.
ApplicationReturnStatus
Return codes for the Optimize call for an application.
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.
bool replace_bounds_
Flag indicating if all bounds should be replaced by inequality constraints.
virtual SmartPtr< const OptionsList > Options() const
Get the options list for setting options (const version)