## 104  Singular Control 4

ITERATIVE DYNAMIC PROGRAMMING, REIN LUUS

10.2.3 Example 4

CHAPMAN & HALL/CRC Monographs and Surveys in Pure and Applied Mathematics

### 104.1  Problem Formulation

Find u over t in [0; 5 ] to minimize

 J = x4(tF)

subject to:

 dx1 dt
= x2
 dx2 dt
= x3
 dx3 dt
= u
 dx4 dt
= x12

The initial condition are:

 x(0) = [1  0  0  0]
 −1 <= u <= 1

Reference: 

### 104.2  Problem setup

```toms t
p = tomPhase('p', t, 0, 5, 100);
setPhase(p)

tomStates x1 x2 x3 x4
tomControls u

% Initial guess
x0 = {icollocate({x1 == 1; x2 == 0
x3 == 0; x4 == 0})
collocate(u == 0)};

% Box constraints
cbox = {-1 <= collocate(u) <= 1};

% Boundary constraints
cbnd = initial({x1 == 1; x2 == 0
x3 == 0; x4 == 0});

% ODEs and path constraints
ceq = collocate({dot(x1) == x2; dot(x2) == x3
dot(x3) == u; dot(x4) == x1.^2});

% Objective
objective = final(x4);
```

### 104.3  Solve the problem

```options = struct;
options.name = 'Singular Control 4';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t = subs(collocate(t),solution);
u = subs(collocate(u),solution);
```
```Problem type appears to be: lpcon
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2011-02-05
=====================================================================================
Problem: ---  1: Singular Control 4             f_k       1.252389645383043400
sum(|constr|)      0.000000063932046493
f(x_k) + sum(|constr|)      1.252389709315090000
f(x_0)      0.000000000000000000

Solver: snopt.  EXIT=0.  INFORM=1.
SNOPT 7.2-5 NLP code
Optimality conditions satisfied

FuncEv    1 ConstrEv   92 ConJacEv   92 Iter   89 MinorIter  652
CPU time: 5.484375 sec. Elapsed time: 5.672000 sec.
```

### 104.4  Plot result

```figure(1)
plot(t,u,'+-');
legend('u');
title('Singular Control 4 control');
``` 