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