yaocptool.methods.base package¶
Submodules¶
yaocptool.methods.base.discretizationschemebase module¶
-
class
DiscretizationSchemeBase(solution_method)[source]¶ Bases:
object-
__init__(solution_method)[source]¶ Base class for discretization methods. A discretization class transforms and OCP into a NLP
-
create_initial_guess(p=None, theta=None)[source]¶ Create an initial guess for the optimal control problem using problem.x_0, problem.y_guess, problem.u_guess, and a given p and theta (for p_opt and theta_opt) if they are given. If y_guess or u_guess are None the initial guess uses a vector of zeros of appropriate size. If no p or theta is given, an vector of zeros o appropriate size is used.
Parameters: - p – Optimization parameters
- theta – Optimization theta
Returns:
-
create_initial_guess_with_simulation(u=None, p=None, theta=None)[source]¶ Create an initial guess for the optimal control problem using by simulating with a given control u, and a given p and theta (for p_opt and theta_opt) if they are given. If no u is given the value of problem.u_guess is used, or problem.u_past, then a vector of zeros of appropriate size is used. If no p or theta is given, an vector of zeros o appropriate size is used.
Parameters: - u – Control initial guess
- p – Optimization parameters
- theta – Optimization theta
Returns:
-
degree¶
-
degree_control¶
-
delta_t¶
-
discretize(x_0=None, p=None, theta=None, last_u=None)[source]¶ Discretize the OCP, returning a Optimization Problem
Parameters: - x_0 – initial condition
- p – parameters
- theta – theta parameters
- last_u – last applied control
Returns:
-
finite_elements¶
-
get_system_at_given_times(x, y, u, time_dict=None, p=None, theta=None, functions=None, start_at_t_0=False)[source]¶
-
model¶ Return type: SystemModel
-
problem¶ Return type: OptimalControlProblem
-
set_data_to_optimization_result_from_raw_data(optimization_result, raw_solution_dict)[source]¶ Set the raw data received from the solver and put it in the Optimization Result object :type optimization_result: yaocptool.methods.optimizationresult.OptimizationResult :type raw_solution_dict: dict
-
time_breakpoints¶
-
time_interpolation_controls¶
-
yaocptool.methods.base.optimizationresult module¶
yaocptool.methods.base.solutionmethodinterface module¶
Created on
@author: Marco Aurelio Schmitz de Aguiar
yaocptool.methods.base.solutionmethodsbase module¶
-
class
SolutionMethodsBase(problem, **kwargs)[source]¶ Bases:
yaocptool.methods.base.solutionmethodinterface.SolutionMethodInterface-
__init__(problem, **kwargs)[source]¶ Parameters: - problem (OptimalControlProblem) –
- integrator_type (str) – str
- solution_method (str) – str
- degree (int) – discretization polynomial degree
- degree_control (int) –
- discretization_scheme (str) – (‘multiple-shooting’ | ‘collocation’)
- initial_guess_heuristic (str) – ‘simulation’ or ‘problem_info’
- last_control_as_parameter (bool) – Default: False, if set to True, the last control will be an parameter for the NLP generated from the OCP. This is useful for MPCs, where the initial condition changes every iteration.
-
call_solver(initial_guess=None, p=None, theta=None, x_0=None, last_u=None, initial_guess_dict=None)[source]¶
-
create_control_approximation()[source]¶ Parametrize the control variable, accordingly to the ‘degree_control’ attribute. If degree_control == 1, then a piecewise constant control will be used (most common). If degree_control > 1, then a piecewise polynomial approximation will be used with order ‘degree_control’.
Returns:
-
create_variable_polynomial_approximation(size, degree, name='var_appr', tau=None, point_at_t0=False)[source]¶
-
delta_t¶
-
model¶
-
prepare()[source]¶ Perform pre solve check, check for sizes and types. If it fails raise an Exception
-
solve(initial_guess=None, p=None, theta=None, x_0=None, last_u=None, initial_guess_dict=None)[source]¶ Parameters: - initial_guess – Initial guess
- p – Parameters values
- theta – Theta values
- x_0 – Initial condition value
- last_u – Last control value
- initial_guess_dict – Initial guess as dict
Return type:
-
time_breakpoints¶
-