OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dakota_application.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-13 by Energy Systems Design Laboratory, University of Alberta
6 //
7 // This software is distributed under the MIT License.
8 // For more information, see the README file in /doc/LICENSE
9 //
10 // - Class: dakota_application.h
11 // - Description: Used to read in an array of experimental data with column headers.
12 // For use with parameter estimation or generating polarization curves.
13 // - Developers: Malte Krack, Peter Dobson <pdobson@ualberta.ca>, Marc Secanell <secanell@ualberta.ca>
14 // - $Id: dakota_application.h 2605 2014-08-15 03:36:44Z secanell $
15 //
16 //---------------------------------------------------------------------------
17 
18 #ifndef dakota_application_h
19 #define dakota_application_h
20 
21 #ifdef _WITH_DAKOTA
22 
23 //deal.II:
24 #include <deal.II/base/parameter_handler.h>
25 
29 #include <utils/fcst_utilities.h>
30 
31 //STL libraries:
32 #include<string>
33 #include<fstream>
34 #include<iostream>
35 #include<vector>
36 
37 //Dakota:
38 #include <ParallelLibrary.hpp>
39 #include <ProblemDescDB.hpp>
40 #include <DakotaStrategy.hpp>
41 #include <DakotaModel.hpp>
42 #include <DirectApplicInterface.hpp>
43 
44 
45 namespace SIM
46 {
77  {
78  public:
83  DakotaApplication(boost::shared_ptr<Dakota::ProblemDescDB> global_problem_db,
84  std::string parameter_file);
85 
91  void manage_inputs(ParameterHandler& param);
92 
99  void assign_interface(Dakota::DirectApplicInterface* optimization_interface);
100 
107  void run();
108 
129  inline bool use_NLS()
130  {
131  return NLS_flag;
132  }
133 
137  Dakota::RealVector vars_results();
138 
142  Dakota::RealVector resp_results();
143 
147  void declare_parameters(ParameterHandler& param);
148 
153  void synchronize_variables(unsigned int &n_dvar, unsigned int &n_resp,
154  std::vector<std::string> &name_design_var, std::vector<std::string> &name_responses);
155 
156  private:
160  void initialize(ParameterHandler& param);
180  void write_method(std::stringstream& inputss, std::string& method_id, std::string method_name, std::string model_ptr);
184  void write_responses(std::stringstream& inputss, int id, std::string method_name);
188  void write_variables(std::stringstream& inputss, int id);
189 
194  DeclException2(DesignVariableNotFoundInFCSTDesignVariables,
195  std::string,
196  std::string,
197  << "A " << arg1 << " with name \"" << arg2 << "\" is not stored in available FCST design variables. Please define the variable in DakotaApplication class and in set_parameters in the appropriate class");
198 
227  std::string n_gradient_type;
231  bool hessians;
232 
280  unsigned int n_dvar;
284  unsigned int n_obj;
288  unsigned int n_nl_con;
292  unsigned int n_eq_con;
296  unsigned int n_con;
300  unsigned int n_resp;
304  std::vector<std::string> name_design_var;
308  std::vector<std::string> all_name_design_var;
313  std::vector<std::string> name_responses;
314 
318  std::string input_file;
322  boost::shared_ptr<Dakota::ProblemDescDB> problem_db;
323 
324  //DAKOTA variables
328  std::string dakota_version;
329 
341  std::string dakota_input;
357  std::string optimization_method;
361  bool NLS_flag;
367  bool scaling;
371  std::string NLS_data_file;
375  int max_iter;
399  std::string hybrid_strategy;
407  std::vector<std::string> hybrid_opt_method;
411  std::vector<std::string> method_list;
415  std::vector<std::string> model_ptr;
419  std::vector<double> tol;
423  std::vector<double> eval_max;
427  std::vector<double> iter_max;
428 
429 
435  std::vector<int> part_design_var;
443  double grad_tol;
447  std::string merit_function;
451  double trust_rad;
455  double abs_conv_tol;
459  double x_conv_tol;
468 
485 
486 
490  Dakota::StringArray dakota_name_design_var;
494  Dakota::RealVector ip_design_var;
498  Dakota::RealVector lb_design_var;
502  Dakota::RealVector ub_design_var;
506  Dakota::RealVector scale_design_var;
510  Dakota::StringArray scale_types;
514  Dakota::RealVector step_design_var;
518  Dakota::RealVector lb_nl_constraint;
522  Dakota::RealVector ub_nl_constraint;
526  Dakota::RealVector eq_constraint;
536  Dakota::Strategy selected_strategy;
537 
542 
569  //
570  // /**
571  // * Optimization - OPT++ Search method .
572  // */
573  // std::string search_method;
574  // bool changing_search_method;
575 
576 
577 
578 
610  std::string mutation_type;
614  std::string crossover_type;
618  std::string fitness_type;
619  std::string fitness_type_moga;
623  std::string replacement_type;
628  std::string initialization_type;
632  std::string convergence_type;
638  double num_parents;
639 
640 
641 
642  };
643 }
644 
645 #endif //Dakota
646 
647 #endif
unsigned int n_nl_con
Number of non-linear constraints.
Definition: dakota_application.h:288
double convergence_tol
Optimization convergence tolerance.
Definition: dakota_application.h:383
std::string input_file
Name of the analysis input file.
Definition: dakota_application.h:318
double constraint_tol
Optimization constraint tolerance.
Definition: dakota_application.h:387
Dakota::RealVector vars_results()
Function retrieves and returns the final optimum design variables.
std::vector< double > eval_max
Hybrid Optimization method specific function evaluation maximums.
Definition: dakota_application.h:423
unsigned int n_con
Total number of constraints = n_nl_con + n_eq_con.
Definition: dakota_application.h:296
double num_offspring
JEGA - Number of Offspring and Parent.
Definition: dakota_application.h:637
double x_conv_tol
NL2SOL Parameter convergence tolerance.
Definition: dakota_application.h:459
double threshold_delta
Definition: dakota_application.h:567
void write_variables(std::stringstream &inputss, int id)
Member function to write Dakota input file based on specified variables.
unsigned int n_obj
Number of objective functions.
Definition: dakota_application.h:284
std::string merit_function
OPT++ merit function.
Definition: dakota_application.h:447
int rand_pareto_weights
Number of random weights for generating objective function pareto set.
Definition: dakota_application.h:391
std::string n_gradient_type
Numerical Gradients type for Dakota optimization.
Definition: dakota_application.h:227
std::vector< std::string > model_ptr
Hybrid Optimization model string identifiers.
Definition: dakota_application.h:415
double num_parents
Definition: dakota_application.h:638
Dakota::RealVector step_design_var
Dakota vector of design variable step sizes for numerical gradients.
Definition: dakota_application.h:514
std::vector< int > part_design_var
Parameter Study Partition vector Set number of partitions for multidim_parameter_study NOTE: Evaluate...
Definition: dakota_application.h:435
std::string replacement_type_moga
Definition: dakota_application.h:624
std::vector< double > iter_max
Hybrid Optimization method specific iteration maximums.
Definition: dakota_application.h:427
std::string mutation_type
Optimization - OPT++ Search method .
Definition: dakota_application.h:610
std::string optimization_method
Optimization Method - OPT++, NL2SOL, multidim_parameter_study, etc.
Definition: dakota_application.h:357
bool use_dakota_input_file
Flag to use an input file from Dakota Specify interface, method, and strategy options, number of variables, number of responses/constrants.
Definition: dakota_application.h:337
std::vector< std::string > hybrid_opt_method
Hybrid Optimization method names.
Definition: dakota_application.h:407
std::vector< std::string > method_list
Hybrid Optimization method string identifiers.
Definition: dakota_application.h:411
int max_iter
Maximum number of optimization iterations.
Definition: dakota_application.h:375
void assign_interface(Dakota::DirectApplicInterface *optimization_interface)
Assign the direct interface to the simulation code which is of type Dakota::DirectApplicInterface.
double false_conv_tol
NL2SOL Parameter false convergence tolerance.
Definition: dakota_application.h:463
unsigned int n_eq_con
Number of equality constraints.
Definition: dakota_application.h:292
double volume_boxsize_limit
NCSU parameter.
Definition: dakota_application.h:484
void write_method(std::stringstream &inputss, std::string &method_id, std::string method_name, std::string model_ptr)
Member function to write Dakota input file based on method selection.
void synchronize_variables(unsigned int &n_dvar, unsigned int &n_resp, std::vector< std::string > &name_design_var, std::vector< std::string > &name_responses)
This function is used to remotely axcess the number and name of design_variables, number and name of ...
void declare_parameters(ParameterHandler &param)
Declare all parameters that are needed for optimization.
unsigned int n_resp
Number of responses = n_obj + n_con.
Definition: dakota_application.h:300
std::vector< std::string > all_name_design_var
Member that stores the name of all possible design variables that have been defined in FCST...
Definition: dakota_application.h:308
void run()
This function will first lock the problem_db preventing anychanges to the data.
int rand_start_points
Number of random weights for generating objective function pareto set.
Definition: dakota_application.h:395
Dakota::RealVector eq_constraint
Dakota vector of equality constraints.
Definition: dakota_application.h:526
DakotaApplication(boost::shared_ptr< Dakota::ProblemDescDB > global_problem_db, std::string parameter_file)
Constructor for an object of this class.
Dakota::RealVector resp_results()
Function retrieves and returns the optimum response values.
std::string crossover_type
JEGA - crossover_type.
Definition: dakota_application.h:614
Dakota::RealVector lb_nl_constraint
Dakota vector of nonlinear constraint lower bounds.
Definition: dakota_application.h:518
bool NLS_flag
Nonlinear Least-Squares Parameter Estimation Flag.
Definition: dakota_application.h:361
double contraction_factor
Definition: dakota_application.h:568
double abs_conv_tol
NL2SOL absolute convergence tolerance.
Definition: dakota_application.h:455
boost::shared_ptr< Dakota::ProblemDescDB > problem_db
Pointer to the problem description data base.
Definition: dakota_application.h:322
bool n_gradients
Numerical Gradients option for Dakota optimization.
Definition: dakota_application.h:210
Dakota::StringArray scale_types
Dakota vector of design variable scale methods.
Definition: dakota_application.h:510
std::string dakota_version
Dakota version used.
Definition: dakota_application.h:328
void manage_inputs(ParameterHandler &param)
Declares &amp; Initializes all parameters, creates Dakota input file.
void write_multi_start_dakota_input_file()
Write Dakota input file for multi-start optimization strategy.
void write_single_method_dakota_input_file()
Write Dakota input file for single optimization strategy.
double centering_param
Centering parameter for the opt++ strategy.
Definition: dakota_application.h:541
std::string dakota_input
Name of the Dakota input file.
Definition: dakota_application.h:341
double final_solutions
NCSU parameter.
Definition: dakota_application.h:476
int m_data_points
NL2SOL Parameter storing the number of terms.
Definition: dakota_application.h:467
double trust_rad
NL2SOL initial trust radius.
Definition: dakota_application.h:451
double solution_target
NCSU parameter.
Definition: dakota_application.h:472
std::vector< std::string > name_responses
Member that stores the name of the responses, i.e.
Definition: dakota_application.h:313
Dakota::StringArray dakota_name_design_var
Dakota array of design variable names.
Definition: dakota_application.h:490
double step_to_boundary
OPT++ steplength.
Definition: dakota_application.h:439
Dakota::RealVector ub_nl_constraint
Dakota vector of nonlinear constraint upper bounds.
Definition: dakota_application.h:522
void write_responses(std::stringstream &inputss, int id, std::string method_name)
Member function to write Dakota input file based on specified response variables. ...
double min_boxsize_limit
NCSU parameter.
Definition: dakota_application.h:480
void write_pareto_dakota_input_file()
Write Dakota input file for pareto optimization strategy.
Dakota::Strategy selected_strategy
DAKOTA strategy.
Definition: dakota_application.h:536
bool a_gradients
Analytical Gradients option for Dakota optimization.
Definition: dakota_application.h:202
Dakota::RealVector lb_design_var
Dakota vector of design variable lower bounds.
Definition: dakota_application.h:498
std::string convergence_type_moga
Definition: dakota_application.h:633
This class is used to interface with DAKOTA as an algorithm library.
Definition: dakota_application.h:76
int n_hybrid_methods
Number of Hybrid Optimization methods.
Definition: dakota_application.h:403
std::string replacement_type
JEGA - replacement_type.
Definition: dakota_application.h:623
Dakota::RealVector ip_design_var
Dakota vector of design variable initial points.
Definition: dakota_application.h:494
bool use_NLS()
Get boolean NLS flag.
Definition: dakota_application.h:129
double initial_delta
Optimization SCOLIB (COLINY) - COBYLA (Constrained Optimization By Linear Appoximations) [coliny_coby...
Definition: dakota_application.h:566
unsigned int n_dvar
Number of design variables.
Definition: dakota_application.h:280
std::string convergence_type
JEGA - convergence_type.
Definition: dakota_application.h:632
double grad_tol
OPT++ gradient tolerance.
Definition: dakota_application.h:443
std::vector< std::string > name_design_var
Member that stores the name of the design variables.
Definition: dakota_application.h:304
std::string fitness_type
JEGA - fitness_type.
Definition: dakota_application.h:618
Dakota::RealVector scale_design_var
Dakota vector of design variable scales.
Definition: dakota_application.h:506
std::string NLS_data_file
Experimental data file for NLS parameter estimation - Operating Conditions &amp; output.
Definition: dakota_application.h:371
int max_f_eval
Maximum number of optimization function evaluations.
Definition: dakota_application.h:379
Dakota::RealVector ub_design_var
Dakota vector of design variable upper bounds.
Definition: dakota_application.h:502
void initialize(ParameterHandler &param)
Read in parameters for the parameter handler in order to initialize data.These parameters are read in...
std::string initialization_type
JEGA - initialization_type.
Definition: dakota_application.h:628
DeclException2(DesignVariableNotFoundInFCSTDesignVariables, std::string, std::string,<< "A "<< arg1<< " with name \""<< arg2<< "\" is not stored in available FCST design variables. Please define the variable in DakotaApplication class and in set_parameters in the appropriate class")
Exception thrown when a user defined design variables is not found among available FCST design variab...
bool scaling
Used to activate scaling.
Definition: dakota_application.h:367
std::string optimization_strategy
Optimization Strategy - Single, Pareto, Multi start point, Hybrid.
Definition: dakota_application.h:349
void write_hybrid_dakota_input_file()
Write Dakota input file for hybrid optimization strategy.
std::string fitness_type_moga
Definition: dakota_application.h:619
std::vector< double > tol
Hybrid Optimization method specific tolerances.
Definition: dakota_application.h:419
std::string hybrid_strategy
Hybrid Optimization strategy - sequential, etc.
Definition: dakota_application.h:399
bool hessians
Analytical Hessian Option for Dakota optimization.
Definition: dakota_application.h:231