Formulating an optimal control problem in ICLOCS2 is straight-forward, and this guide will assist you in setting up the problem correctly and efficiently.
A general purpose optimal control problem can be formulated in the following Bolza form
and can be directly implement in ICLOCS2 through the following procedures.
We can specify the system dynamics and path constraints in function myProblem_Dynamics_Internal(x,u,p,t,vdat) with
where the function myProblem_Dynamics_Internal returns the value of variable dx for system dynamics, and optionally g_eq for equality path constraints and g_neq for inequality constraints.
Similarly, the (optional) simulation dynamics can be specifed in function myProblem_Dynamics_Sim .
First we provide the function handles for system dynamics with,
the optional files providing analytic derivatives,
and the function handle for the settings file.
Next we define the time variables with
for the initial time and
for the final time. If the upper bound and the lower bounds are the same, then the final time can be fixed. Otherwise it is a variable terminal time problem.
The upper and lower bounds as well as the initial guess of any static parameters (as part of optimization variables) can be defined as follows
For state variables, we need to provide the initial conditions
and bounds on intial conditions
The initial states can be fixed by setting upper and lower bounds the same, and can be left free/bounded to have different upper and lower bounds and with problem.states.x0=.
Furthermore, we can to specify the bounds on the state variables
as well as (optionally) bounds on the rate of change of state variables
For unbounded variables, -inf and inf may be used accordingly.
In ICLOCS2, we allow the user to specify the level of accuracy required for each variable. Here the bounds on the absolute local error and the integrated residual error of state variables can be specified respectively as
together with the tolerances for state and state rate variable box constraint violations
Next is to define the terminal state bounds
It is also recommend to give an initial guess of the state values at various times along the trajectory in the following form
If guess.time is not specified, guess.states can take on a two point guess corresponding to guess.t0 and guess.tf.
Firstly, it is possible to define the number of control actions. For current versions of ICLOCS, leave this option as default: the number of control actions is in correspondence with the number of integration intervals, with
Then smilarly, we need to define simple bounds. for input variables
bounds on the first control action.
and bounds on the rate of change. for control variables (optional)
Furthermore, we need tolerance for control variable and input rate box constraint violation
as well as an initial guess of the input trajectory (optional but recommended)
We need to specify the number of equality path constraints g_eq(x,u,p,t)=0 with
and the upper and lower bounds for inequality path constraints with
as well as path constraint violation tolerances
In ICLOCS version 2.5, we provide an (optional) option to define the time duration for each inequality constraint to be active, when the external constraint handling funtionality is enabled. For example, one may define
For additional boundary constraints (in addition to simple bounds on variables), we will define the bounds of the boundary constraint function here.
We may store the necessary problem parameters used in the functions in the following form
To use the automatic regularization function, a regularization parameter could be setup as followswith problem.data.penalty.values defining the sequence of weights for, and problem.data.penalty.i the starting index. The parameter could be called with vdat.penalty.values(vdat.penalty.i) in problem formulation (e.g. in myProblem_Dynamics_Internal, L_unscaled, E_unscaled and/or b_unscaled).
Now we can start to define the sub-functions.
First, the Lagrange (stage) cost can be defined in L_unscaled(x,xr,u,ur,p,t,vdat) as
and the Mayer (boundary) cost in sub-function E_unscaled(x0,xf,u0,uf,p,t0,tf,data) as
Any boundary constraints that are not formulated as variable simple bounds need to be specified in sub-function b_unscaled(x0,xf,u0,uf,p,t0,tf,vdat,varargin) . The user should only modify the follwing sections of codes
This conclude the process of formulating an optimal control problem in ICLOCS2 for a single phase problem.