Time discretization¶
-
class
rtctools.optimization.collocated_integrated_optimization_problem.
CollocatedIntegratedOptimizationProblem
(**kwargs)[source]¶ Bases:
rtctools.optimization.optimization_problem.OptimizationProblem
Discretizes your model using a mixed collocation/integration scheme.
Collocation means that the discretized model equations are included as constraints between state variables in the optimization problem.
Note
To ensure that your optimization problem only has globally optimal solutions, any model equations that are collocated must be linear. By default, all model equations are collocated, and linearity of the model equations is verified. Working with non-linear models is possible, but discouraged.
Variables: check_collocation_linearity – If True
, check whether collocation constraints are linear. Default isTrue
.-
integrated_states
¶ A list of states that are integrated rather than collocated.
Warning
This is an experimental feature.
Deprecated since version 2.4: Support for integrated states will be removed in a future release.
-
integrator_options
()[source]¶ Configures the implicit function used for time step integration.
Returns: A dictionary of CasADi rootfinder
options. See the CasADi documentation for details.
-
interpolation_method
(variable=None)[source]¶ Interpolation method for variable.
Parameters: variable – Variable name. Returns: Interpolation method for the given variable.
-
map_options
() → Dict[str, Union[str, int]][source]¶ Returns a dictionary of CasADi
map()
options.Option Type Default value mode
``str` openmp
n_threads
int
None
The
mode
option controls the mode of themap()
call. Valid values includeopenmp
,thread
, andunroll
. See the CasADi and documentation for detailed documentation on these modes.The
n_threads
option controls the number of threads used when inthread
mode.Note
Not every CasADi build has support for OpenMP enabled. For such builds, the thread mode offers an alternative parallelization mode.
Note
The use of
expand=True
insolver_options()
may negate the parallelization benefits obtained usingmap()
.Returns: A dictionary of options for the map() call used to evaluate constraints on every time stamp.
-
theta
¶ RTC-Tools discretizes differential equations of the form
\[\dot{x} = f(x, u)\]using the \(\theta\)-method
\[x_{i+1} = x_i + \Delta t \left[\theta f(x_{i+1}, u_{i+1}) + (1 - \theta) f(x_i, u_i)\right]\]The default is \(\theta = 1\), resulting in the implicit or backward Euler method. Note that in this case, the control input at the initial time step is not used.
Set \(\theta = 0\) to use the explicit or forward Euler method. Note that in this case, the control input at the final time step is not used.
Warning
This is an experimental feature for \(0 < \theta < 1\).
Deprecated since version 2.4: Support for semi-explicit collocation (theta < 1) will be removed in a future release.
-