Get Started

Formulate your problem in ICLOCS2: multi-phase problems

Defining individual phases

Firstly, individual phases can be specified according to the instructions on defining single phase problems. The only difference would be for the time variables with the initial and final time of each phases now configured with

% Initial time. 

% Final time. Let tf_min=tf_max if tf is fixed.

with problem.time.t0_idx and problem.time.tf_idx the index numbers chosen from variables defined in the main problem formulation file myMultiPhaseProblem.m.

Defining the multi-phase problem in myMultiPhaseProblem.m

Time variables

First, we can specify the time variables needed in all phases with[t0_min t1_min ...];[t0_max t1_max ...];[t0_guess t1_guess ...];

Static parameters

Next, we can specify the static parameters that will be shared with all phases[];[];[];

Linkage constraints

The unique charateristics of a multi-phase problem is the connection between different phases through the use of linkage constraints. In ICLOCS version 2.5, the linear and nonlinear linkage constraints can be specfied separately for compuatational benfits. First, we specify the upper and lower bounds, as well as the tolerance of linear linkage constraints with[bl1_linear_lowerbound bl2_linear_lowerbound ...];[bl1_linear_upperbound bl2_linear_upperbound ...];[eps_bl1_linear_bounds eps_bl2_linear_bounds ...]; 

which is followed by the nonlinear ones[bl1_nonlinear_lowerbound bl2_nonlinear_lowerbound ...];[bl1_nonlinear_upperbound bl2_nonlinear_upperbound ...];[eps_bl1_nonlinear_bounds eps_bl2_nonlinear_bounds ...];  

The actual linkage constraint equations will need to be specified in the function bclink(x0,xf,u0,uf,p,t0,tf,vdat), with variable of different phase could be obtained using syntex of, for example, xf{4}(2): the value of second state at tf of phase number 4.

% linear linkage constraints 

% nonlinear linkage constraints 

Storage of necessary parameter data

We may store the necessary problem parameters used in the functions in the following form;

Initialize different phases of OCP

We may initialize different phases of the OCP by linking the funtions of individual phases

[problem.phases{1},guess.phases{1}] = myMultiPhaseProblem_Phase1(,;
[problem.phases{2},guess.phases{2}] = myMultiPhaseProblem_Phase2(,;

In multi-phase formulation of ICLOCS 2.5, each phase could use different discretization method

phaseoptions{1}=problem.phases{1}.settings(Nps); % h method for phase 1
phaseoptions{2}=problem.phases{2}.settings(Nps,Npd); % hp method for phase 2

with, for example, Nps being the number mesh intervals, and Npd the polynomial order for the hp-LGR method.

This conclude the process of formulating an optimal control problem in ICLOCS2 for a multi-phase phase problem.