User-interface to automatically generate simulation algorithms for fast optimal control. More...
#include <sim_export.hpp>
Public Member Functions | |
returnValue | exportAcadoHeader (const std::string &_dirName, const std::string &_fileName, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const |
virtual returnValue | exportAndRun (const std::string &dirName, const std::string &initStates, const std::string &controls, const std::string &results=std::string("results.txt"), const std::string &ref=std::string("ref.txt")) |
virtual returnValue | exportCode (const std::string &dirName, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) |
SIMexport & | operator= (const SIMexport &arg) |
virtual returnValue | printDetails (bool details) |
virtual returnValue | setReference (const std::string &reference, const std::vector< std::string > &outputReference=*(new std::vector< std::string >())) |
virtual returnValue | setTimingSteps (uint _timingSteps) |
SIMexport (const uint simIntervals=1, const double totalTime=1.0) | |
SIMexport (const SIMexport &arg) | |
virtual | ~SIMexport () |
Protected Member Functions | |
returnValue | checkConsistency () const |
returnValue | clear () |
returnValue | collectDataDeclarations (ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const |
returnValue | collectFunctionDeclarations (ExportStatementBlock &declarations) const |
returnValue | copy (const SIMexport &arg) |
returnValue | executeTest (const std::string &_dirName) |
returnValue | exportEvaluation (const std::string &_dirName, const std::string &_fileName) const |
returnValue | exportMakefile (const std::string &_dirName, const std::string &_fileName, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const |
returnValue | exportTest (const std::string &_dirName, const std::string &_fileName, const std::string &_resultsFile, const std::vector< std::string > &_outputFiles, const bool &TIMING=false, const uint jumpReference=1) const |
virtual returnValue | setTimingCalls (uint _timingCalls) |
returnValue | setup () |
Protected Attributes | |
std::string | _controls |
std::string | _initStates |
std::vector< std::string > | _outputFiles |
std::string | _ref |
std::vector< std::string > | _refOutputFiles |
std::string | _results |
IntegratorExport * | integrator |
bool | PRINT_DETAILS |
bool | referenceProvided |
double | T |
uint | timingCalls |
uint | timingSteps |
Static Protected Attributes | |
static const uint | factorRef = 10 |
User-interface to automatically generate simulation algorithms for fast optimal control.
The class SIMexport is a user-interface to automatically generate tailored simulation algorithms for fast optimal control. It takes an optimal control problem (OCP) formulation and generates code based on given user options, e.g specifying the integrator and the number of integration steps. In addition to the export of such a simulation algorithm, the performance of this integrator will be evaluated on accuracy of the results and the time complexity.
Definition at line 60 of file sim_export.hpp.
BEGIN_NAMESPACE_ACADO SIMexport::SIMexport | ( | const uint | simIntervals = 1 , |
const double | totalTime = 1.0 |
||
) |
Default constructor.
[in] | simIntervals | The number of simulation intervals. |
[in] | totalTime | The total simulation time. |
Definition at line 55 of file sim_export.cpp.
SIMexport::SIMexport | ( | const SIMexport & | arg | ) |
Copy constructor (deep copy).
[in] | arg | Right-hand side object. |
Definition at line 75 of file sim_export.cpp.
SIMexport::~SIMexport | ( | ) | [virtual] |
Destructor.
Definition at line 82 of file sim_export.cpp.
returnValue SIMexport::checkConsistency | ( | ) | const [protected] |
Checks whether OCP formulation is compatible with code export capabilities.
Definition at line 300 of file sim_export.cpp.
returnValue SIMexport::clear | ( | ) | [protected] |
Frees internal dynamic memory to yield an empty function.
Definition at line 236 of file sim_export.cpp.
returnValue SIMexport::collectDataDeclarations | ( | ExportStatementBlock & | declarations, |
ExportStruct | dataStruct = ACADO_ANY |
||
) | const [protected, virtual] |
Collects all data declarations of the auto-generated sub-modules to given list of declarations.
[in] | declarations | List of declarations. |
Implements ExportModule.
Definition at line 320 of file sim_export.cpp.
returnValue SIMexport::collectFunctionDeclarations | ( | ExportStatementBlock & | declarations | ) | const [protected, virtual] |
Collects all function (forward) declarations of the auto-generated sub-modules to given list of declarations.
[in] | declarations | List of declarations. |
Implements ExportModule.
Definition at line 331 of file sim_export.cpp.
returnValue SIMexport::copy | ( | const SIMexport & | arg | ) | [protected] |
Copies all class members from given object.
[in] | arg | Right-hand side object. |
Definition at line 218 of file sim_export.cpp.
returnValue SIMexport::executeTest | ( | const std::string & | _dirName | ) | [protected] |
Compiles the exported source files and runs the corresponding test.
[in] | _dirName | Name of directory in which the files are exported. |
Definition at line 888 of file sim_export.cpp.
returnValue SIMexport::exportAcadoHeader | ( | const std::string & | _dirName, |
const std::string & | _fileName, | ||
const std::string & | _realString = "real_t" , |
||
const std::string & | _intString = "int" , |
||
int | _precision = 16 |
||
) | const [virtual] |
Exports main header file for using the exported algorithm.
[in] | _dirName | Name of directory to be used to export file. |
[in] | _fileName | Name of file to be exported. |
[in] | _realString | std::string to be used to declare real variables. |
[in] | _intString | std::string to be used to declare integer variables. |
[in] | _precision | Number of digits to be used for exporting real values. |
Implements ExportModule.
Definition at line 772 of file sim_export.cpp.
returnValue SIMexport::exportAndRun | ( | const std::string & | dirName, |
const std::string & | initStates, | ||
const std::string & | controls, | ||
const std::string & | results = std::string( "results.txt" ) , |
||
const std::string & | ref = std::string( "ref.txt" ) |
||
) | [virtual] |
Exports all files of the auto-generated code into the given directory and runs the test to evaluate the performance of the exported integrator.
[in] | dirName | Name of directory to be used to export files. |
[in] | initStates | Name of the file containing the initial values of all the states. |
[in] | controls | Name of the file containing the control values over the OCP grid. |
[in] | results | Name of the file in which the integration results will be written. |
[in] | ref | Name of the file in which the reference will be written, to which the results of the integrator will be compared. |
Definition at line 718 of file sim_export.cpp.
returnValue SIMexport::exportCode | ( | const std::string & | dirName, |
const std::string & | _realString = "real_t" , |
||
const std::string & | _intString = "int" , |
||
int | _precision = 16 |
||
) | [virtual] |
Exports all files of the auto-generated code into the given directory.
[in] | dirName | Name of directory to be used to export files. |
[in] | _realString | std::string to be used to declare real variables. |
[in] | _intString | std::string to be used to declare integer variables. |
[in] | _precision | Number of digits to be used for exporting real values. |
Implements ExportModule.
Definition at line 103 of file sim_export.cpp.
returnValue SIMexport::exportEvaluation | ( | const std::string & | _dirName, |
const std::string & | _fileName | ||
) | const [protected] |
Exports the file evaluating the performance of the exported integrator, based on its results from the test and the corresponding reference results.
[in] | _dirName | Name of directory to be used to export file. |
[in] | _fileName | Name of file to be exported. |
Definition at line 548 of file sim_export.cpp.
returnValue SIMexport::exportMakefile | ( | const std::string & | _dirName, |
const std::string & | _fileName, | ||
const std::string & | _realString = "real_t" , |
||
const std::string & | _intString = "int" , |
||
int | _precision = 16 |
||
) | const [protected] |
Exports GNU Makefile for compiling the exported MPC algorithm.
[in] | _dirName | Name of directory to be used to export file. |
[in] | _fileName | Name of file to be exported. |
[in] | _realString | std::string to be used to declare real variables. |
[in] | _intString | std::string to be used to declare integer variables. |
[in] | _precision | Number of digits to be used for exporting real values. |
Definition at line 845 of file sim_export.cpp.
returnValue SIMexport::exportTest | ( | const std::string & | _dirName, |
const std::string & | _fileName, | ||
const std::string & | _resultsFile, | ||
const std::vector< std::string > & | _outputFiles, | ||
const bool & | TIMING = false , |
||
const uint | jumpReference = 1 |
||
) | const [protected] |
Exports test file with template main function for using the exported simulation algorithm.
[in] | _dirName | Name of directory to be used to export file. |
[in] | _fileName | Name of file to be exported. |
[in] | _resultsFile | Name of the file in which the integration results will be written. |
[in] | _outputFiles | Names of the files in which the output results will be written. |
[in] | TIMING | A boolean that is true when timing results are desired. |
[in] | jumpReference | The reference factor if the reference output results are computed. |
Definition at line 341 of file sim_export.cpp.
Assignment operator (deep copy).
[in] | arg | Right-hand side object. |
Definition at line 88 of file sim_export.cpp.
returnValue SIMexport::printDetails | ( | bool | details | ) | [virtual] |
This function sets a boolean if the exported simulation code should print all the details about the results or not.
[in] | details | true if the exported simulation code should print all the details, otherwise false |
Definition at line 881 of file sim_export.cpp.
returnValue SIMexport::setReference | ( | const std::string & | reference, |
const std::vector< std::string > & | outputReference = *(new std::vector<std::string>()) |
||
) | [virtual] |
This function should be used if the user wants to provide the file containing the reference solution, to which the results of the integrator are compared.
[in] | reference | Name of the file containing the reference. |
[in] | outputReference | The names of the files containing the reference for the output results if any. |
Definition at line 861 of file sim_export.cpp.
returnValue SIMexport::setTimingCalls | ( | uint | _timingCalls | ) | [protected, virtual] |
This function sets the number of calls performed for the timing results.
[in] | _timingCalls | The new number of calls performed for the timing results. |
Definition at line 899 of file sim_export.cpp.
returnValue SIMexport::setTimingSteps | ( | uint | _timingSteps | ) | [virtual] |
This function sets the number of integration steps performed for the timing results.
[in] | _timingSteps | The new number of integration steps performed for the timing results. |
Definition at line 874 of file sim_export.cpp.
returnValue SIMexport::setup | ( | ) | [protected] |
Sets-up code export and initializes underlying export modules.
Definition at line 246 of file sim_export.cpp.
std::string SIMexport::_controls [protected] |
Name of the file containing the control values over the OCP grid.
Definition at line 333 of file sim_export.hpp.
std::string SIMexport::_initStates [protected] |
Name of the file containing the initial values of all the states.
Definition at line 332 of file sim_export.hpp.
std::vector<std::string> SIMexport::_outputFiles [protected] |
Names of the files in which the outputs will be written for the integrator.
Definition at line 338 of file sim_export.hpp.
std::string SIMexport::_ref [protected] |
Name of the file in which the reference will be written, to which the results of the integrator will be compared.
Definition at line 335 of file sim_export.hpp.
std::vector<std::string> SIMexport::_refOutputFiles [protected] |
Names of the files in which the outputs will be written for the reference.
Definition at line 337 of file sim_export.hpp.
std::string SIMexport::_results [protected] |
Name of the file in which the integration results will be written.
Definition at line 334 of file sim_export.hpp.
const uint SIMexport::factorRef = 10 [static, protected] |
The used factor in the number of integration steps to get the reference.
Definition at line 329 of file sim_export.hpp.
IntegratorExport* SIMexport::integrator [protected] |
Module for exporting a tailored integrator.
Definition at line 324 of file sim_export.hpp.
bool SIMexport::PRINT_DETAILS [protected] |
True if the user wants all the details about the results being printed.
Definition at line 327 of file sim_export.hpp.
bool SIMexport::referenceProvided [protected] |
True if the user provided a file with the reference solution.
Definition at line 326 of file sim_export.hpp.
double SIMexport::T [protected] |
The total simulation time.
Definition at line 323 of file sim_export.hpp.
uint SIMexport::timingCalls [protected] |
The number of calls to the exported function for the timing results.
Definition at line 321 of file sim_export.hpp.
uint SIMexport::timingSteps [protected] |
The number of integration steps performed for the timing results.
Definition at line 330 of file sim_export.hpp.