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. 
problem.time.t0_idx=...;
problem.time.t0_min=problem_mp.time.t_min(problem.time.t0_idx);
problem.time.t0_max=problem_mp.time.t_max(problem.time.t0_idx);
guess.t0=guess_mp.time(problem.time.t0_idx);

% Final time. Let tf_min=tf_max if tf is fixed.
problem.time.tf_idx=...;
problem.time.tf_min=problem_mp.time.t_min(problem.time.tf_idx);     
problem.time.tf_max=problem_mp.time.t_max(problem.time.tf_idx); 
guess.tf=guess_mp.time(problem.time.tf_idx);

with problem.time.t0_idx and problem.time.tf_idx the index numbers chosen from problem.mp.time 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

problem.mp.time.t_min=[t0_min t1_min ...];     
problem.mp.time.t_max=[t0_max t1_max ...];  
guess.mp.time=[t0_guess t1_guess ...];

Static parameters

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

problem.mp.parameters.pl=[];
problem.mp.parameters.pu=[];
guess.mp.parameters=[];

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

problem.mp.constraints.bll.linear=[bl1_linear_lowerbound bl2_linear_lowerbound ...];
problem.mp.constraints.blu.linear=[bl1_linear_upperbound bl2_linear_upperbound ...];
problem.mp.constraints.blTol.linear=[eps_bl1_linear_bounds eps_bl2_linear_bounds ...]; 

which is followed by the nonlinear ones

problem.mp.constraints.bll.nonlinear=[bl1_nonlinear_lowerbound bl2_nonlinear_lowerbound ...];
problem.mp.constraints.blu.nonlinear=[bl1_nonlinear_upperbound bl2_nonlinear_upperbound ...];
problem.mp.constraints.blTol.nonlinear=[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 
blc_linear(1,:)=blc_linear_1(x0,xf,u0,uf,p,t0,tf,vdat);
blc_linear(2,:)=blc_linear_2(x0,xf,u0,uf,p,t0,tf,vdat);
...

% nonlinear linkage constraints 
blc_nonlinear(1,:)=blc_nonlinear_1(x0,xf,u0,uf,p,t0,tf,vdat);
blc_nonlinear(2,:)=blc_nonlinear_2(x0,xf,u0,uf,p,t0,tf,vdat);
...

Storage of necessary parameter data

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

problem.data.auxdata=auxdata;

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.mp, guess.mp);
[problem.phases{2},guess.phases{2}] = myMultiPhaseProblem_Phase2(problem.mp, guess.mp);
...

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.