pockit.lobatto
Submodule for Legendre-Gauss-Lobatto pseudospectral methods.
The Lobatto phase is suitable for problems with continuous state and control variables.
Base class for one phase of an optimal control problem.
Initialize a phase with given state, control, and static variables.
States and controls can be given as the number of variables or the list of variable names. If names are given, they are used as the names of the variables. Otherwise, the names are generated automatically as \( x_0, x_1, \dots, x_{n - 1} \).
Static variables should be identical to those defined in the system level.
The identifier should be unique for each phase in a given system to avoid possible name conflict.
It is recommended to use the System.new_phase() method of the System
object to create phases instead of manually using this method.
If simplify is True, every symbolic expression will be simplified (by sympy.simplify()) before
being compiled. This will slow down the speed of compilation.
If fastmath is True, the fastmath flag will be passed to the Numba JIT compiler,
see Numba
and LLVM documentation for details.
Arguments:
- state: Number of state variables or list of state variable names.
- control: Number of control variables or list of control variable names.
- symbol_static_parameter: list of static parameters,
should be identical to those in the
Systemobject. - identifier: Unique identifier of the phase.
- simplify: Whether to use SymPy to simplify
sympy.Exprobjects before compilation. - fastmath: Whether to use Numba
fastmathmode.
Lobatto nodes cannot approximate discontinuous functions precisely.
Use radau nodes instead.
Raises:
- NotImplementedError: Always
Check the continuous error. Same as check_continuous().
Arguments:
- variable: Variable to be checked.
- static_parameter: Static parameter to be checked. Set to
Noneif the phase has no static parameters. - absolute_tolerance_continuous: Absolute tolerance for continuous error.
- relative_tolerance_continuous: Relative tolerance for continuous error.
- tolerance_discontinuous: In each subinterval, after scaling to \( [0, 1] \), the bang-bang control functions
should either be less than
tolerance_discontinuousor greater than1 - tolerance_discontinuoussimultaneously. - tolerance_mesh: Skip the check if the mesh width is smaller than this value.
Returns:
Trueif the error is within the tolerance,Falseotherwise.
Lobatto nodes cannot approximate discontinuous functions precisely.
Use radau nodes instead.
Raises:
- NotImplementedError: Always
Adjust the mesh and the number of interpolation points to match the
continuous error tolerance. Same as refine_continuous().
Arguments:
- variable: Variable of the previous iteration.
- static_parameter: Static parameter of the previous iteration.
Set to
Noneif the phase has no static parameters. - absolute_tolerance_continuous: Absolute tolerance for continuous error.
- relative_tolerance_continuous: Relative tolerance for continuous error.
- tolerance_discontinuous: In each subinterval, after scaling to \( [0, 1] \), the bang-bang control functions
should either be less than
tolerance_discontinuousor greater than1 - tolerance_discontinuoussimultaneously. - num_point_min: Minimum number of interpolation points.
- num_point_max: Maximum number of interpolation points.
- mesh_length_min: Minimum mesh length.
- mesh_length_max: Maximum mesh length.
Inherited Members
- pockit.base.phasebase.PhaseBase
- set_dynamics
- set_integral
- set_phase_constraint
- set_boundary_condition
- set_discretization
- check_continuous
- refine_continuous
- n_x
- x
- n_u
- u
- n
- n_s
- s
- t
- F_d
- n_d
- F_I
- n_I
- I
- F_c
- n_c
- v_lb
- v_ub
- c_lb
- c_ub
- s_b
- bc_0
- bc_f
- F_b
- n_b
- t_0
- t_f
- N
- ok
- index_state
- index_control
- index_mstage
- l_v
- r_v
- t_m
- l_m
- r_m
- L_m
- w_m
- f_v2m
- T_v
- T_v_coo
- I_m
- I_m_coo
- l_d
- r_d
- t_m_aug
- l_m_aug
- r_m_aug
- L_m_aug
- w_aug
- P
- V_xu_aug
- T_x_aug
- I_m_aug
- t_x
- t_u
- l_x
- r_x
- l_u
- r_u
- L_x
- L_xu
- L
Base class for a complete optimal control problem.
Initialize a system with given static parameters.
If static_parameter is an integer, the names are generated automatically as \( s_0, s_1, \dots, s_{n-1} \).
If simplify is True, every symbolic expression will be simplified (by sympy.simplify()) before
being compiled. This will slow down the speed of compilation.
If fastmath is True, the fastmath flag will be passed to the Numba JIT compiler,
see Numba
and LLVM documentation for details.
Arguments:
- static_parameter: Number of static parameters or list of static parameter names.
- simplify: Whether to use SymPy to simplify
sympy.Exprobjects before compilation. - fastmath: Whether to use Numba
fastmathmode.
Lobatto nodes cannot approximate discontinuous functions precisely.
Use radau nodes instead.
Raises:
- NotImplementedError: Always
Check the continuous error. Same as check_continuous().
Arguments:
- value: The variable to be checked. If the system has only one phase and no static variables,
valuecan be a singleVariableobject. Otherwise,valueshould be a list ofVariableobjects, one for eachPhase, followed by an array of static-parameter values. - absolute_tolerance_continuous: Absolute tolerance for continuous error.
- relative_tolerance_continuous: Relative tolerance for continuous error.
- tolerance_discontinuous: In each subinterval, after scaling to \( [0, 1] \), the bang-bang control functions
should either be less than
tolerance_discontinuousor greater than1 - tolerance_discontinuoussimultaneously. - tolerance_mesh: Skip the check if the mesh width is smaller than this value.
Returns:
Trueif the error is within the tolerance,Falseotherwise.
Lobatto nodes cannot approximate discontinuous functions precisely.
Use radau nodes instead.
Raises:
- NotImplementedError: Always
Adjust the mesh and the number of interpolation points to match the
continuous error tolerance. Same as refine_continuous().
Arguments:
- value: The variable to be checked. If the system has only one phase and no static variables,
valuecan be a singleVariableobject. Otherwise,valueshould be a list ofVariableobjects, one for eachPhase, followed by an array of static-parameter values. - absolute_tolerance_continuous: Absolute tolerance for continuous error.
- relative_tolerance_continuous: Relative tolerance for continuous error.
- tolerance_discontinuous: In each subinterval, after scaling to \( [0, 1] \), the bang-bang control functions
should either be less than
tolerance_discontinuousor greater than1 - tolerance_discontinuoussimultaneously. - num_point_min: Minimum number of interpolation points.
- num_point_max: Maximum number of interpolation points.
- mesh_length_min: Minimum mesh length.
- mesh_length_max: Maximum mesh length.
Returns:
The
Variableobjects interpolated onto the new discretization.
Inherited Members
- pockit.base.systembase.SystemBase
- new_phase
- set_phase
- set_objective
- set_system_constraint
- update
- objective
- constraints
- gradient
- jacobianstructure
- jacobian
- hessianstructure_o
- hessian_o
- hessianstructure_c
- hessian_c
- hessianstructure
- hessian
- check_continuous
- refine_continuous
- n_s
- s
- n_p
- p
- F_o
- n_c
- F_c
- v_lb
- v_ub
- c_lb
- c_ub
- N
- L
- ok
Optimization variable for a discretized phase.
A Variable exposes its data both as a flat array for solvers and through
convenient accessors for individual state and control variables. It also
provides interpolation matrices for plotting and mesh adaptation.
Users normally create instances with constant_guess or linear_guess
and then adjust the initial guess as needed.