Time discretization

class rtctools.optimization.collocated_integrated_optimization_problem.CollocatedIntegratedOptimizationProblem(**kwargs)[source]

Bases: 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.

Integration means that the model equations are solved from one time step to the next in a sequential fashion, using a rootfinding algorithm at each and every step. The results of the integration procedure feature as inputs to the objective functions as well as to any constraints that do not originate from the DAE model.


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.


check_collocation_linearity – If True, check whether collocation constraints are linear. Default is True.


Configures the implicit function used for time step integration.


A dictionary of CasADi rootfinder options. See the CasADi documentation for details.


Interpolation method for variable.


variable – Variable name.


Interpolation method for the given variable.

map_options() Dict[str, str | int][source]

Returns a dictionary of CasADi map() options.



Default value







The mode option controls the mode of the map() call. Valid values include openmp, thread, and unroll. See the CasADi and documentation for detailed documentation on these modes.

The n_threads option controls the number of threads used when in thread mode.


Not every CasADi build has support for OpenMP enabled. For such builds, the thread mode offers an alternative parallelization mode.


The use of expand=True in solver_options() may negate the parallelization benefits obtained using map().


A dictionary of options for the map() call used to evaluate constraints on every time stamp.

property 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.


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.

abstract times(variable=None)[source]

List of time stamps for variable (to optimize for).


variable – Variable name.


A list of time stamps for the given variable.