Page 258 - Numerical Methods for Chemical Engineering
P. 258
Optimal control 247
An open-loop optimal control routine
optimal control.m implements the procedure described above, and is called with the syntax
function [TRAJ, iflag] = optimal control(FUN, PARAM, SIM, TRAJ0);
FUN is a structure containing the names of the user-supplied routines that define the
optimal control problem. FUN.f is the routine that returns the time derivative vector for
˙ x = f (t, x, u),
function f =FUN.f(t, x, u, PARAM);
PARAM is an optional user-specified structure of fixed system parameters. FUN.sigma
returns the integrand σ(t, x, u) of the cost functional,
function sigma =FUN.sigma(t, x, u, PARAM);
FUN.pi returns the value of π(x(t H )),
function pi =FUN.pi(xH, PARAM);
FUN.constraint is an optional routine that defines the set of constraints that apply to the
control input in each subinterval,
u
Au [k] ≤ b A (eq) [k] = b (eq) LB( j) ≤ u [k] ≤ UB( j) (5.151)
j
and is called with the syntax
function UCON = FUN.constraint();
UCON contains the fields UCON.A, UCON.b, UCON.A eq, UCON.b eq, UCON.LB, and
UCON.UB. FUN.u0 is a routine that returns the initial guess of the time-dependent con-
trol input u(t),
function u0 =FUN.u0(t, PARAM);
SIM is a data structure that contains information about how the optimization calculation is
to be performed. SIM.t0 is the initial time and SIM.tH is the horizon time. SIM.NS is the
number of subintervals. SIM.x0 is the initial state. SIM.isRestart is 0 if the simulation is to
start at the initial guess supplied by FUN.u0 and is nonzero if the information in the optional
input parameter TRAJ0 sets the initial input trajectory. SIM.constraint is 0 if the control
inputs are not constrained, and is nonzero if FUN.constraint is to be used to define a set of
input control constraints. SIM.verbose is 0 if no information is to be printed to the screen
and is nonzero if the status of the calculation is to be displayed.
The output is TRAJ, a data structure that contains information about the optimal tra-
jectory. TRAJ.t is a vector of the times that separate the piecewise-constant subintervals,
TRAJ.t(k)= t k . The u [k] for that subinterval are found in row k of TRAJ.u. The state tra-
jectory for the optimal control inputs is returned in TRAJ.t xtraj and TRAJ.x xtraj in the
same format used by the ODE solvers. The control inputs at these times are returned in
TRAJ.u xtraj.