A Simple Terminal Constraint Problem

Problem 1: Miser3 manual

Contents

Problem Description

Find u(t) over t in [0; 1 ] to minimize

$$ J = \int_0^{1} (x^2 + u^2) \mathrm{d}t $$

subject to:

$$ \frac{dx}{dt} = u $$

$$ x(0) = 1 $$

$$ x(1) = 0.75 $$

$$ x(0.75) = 0.9 $$

% Copyright (c) 2007-2008 by Tomlab Optimization Inc.

Problem setup

toms t1
p1 = tomPhase('p1', t1, 0, 0.75, 20);
toms t2
p2 = tomPhase('p2', t2, 0.75, 0.25, 20);

setPhase(p1);
tomStates x1p1
tomControls up1
setPhase(p2);
tomStates x1p2
tomControls up2
setPhase(p1);

% Initial guess
x01 = {icollocate({x1p1 == 1-0.1*t1/0.75})
    collocate(up1==0.9*t1/0.75)};

% Box constraints
cbox1 = {-10 <= icollocate(p1,x1p1) <= 10
    -10 <= collocate(p1,up1) <= 10};

% Boundary constraints
cbnd1 = initial(x1p1 == 1);

% ODEs and path constraints
ceq1 = collocate(dot(x1p1) == up1);

% Objective
objective1 = integrate(x1p1.^2+up1.^2);

setPhase(p2);
% Initial guess
x02 = {icollocate({x1p2 == 1-0.1*t2})
    collocate(up2==0.9+0.1*t2)};

% Box constraints
cbox2 = {-10 <= icollocate(p2,x1p2) <= 10
    -10 <= collocate(p2,up2) <= 10};

% Boundary constraints
cbnd2 = {initial(x1p2 == 0.9)
    final(x1p2 == 0.75)};

% ODEs and path constraints
ceq2 = collocate(dot(x1p2) == up2);

% Objective
objective2 = integrate(x1p2.^2+up2.^2);

% Objective
objective = objective1 + objective2;

% Link phase
link = {final(p1,x1p1) == initial(p2,x1p2)};

Solve the problem

options = struct;
options.name = 'Terminal Constraint 2';
constr = {cbox1, cbnd1, ceq1, cbox2, cbnd2, ceq2, link};
solution = ezsolve(objective, constr, {x01, x02}, options);

t = subs(collocate(p1,t1),solution);
t = [t;subs(collocate(p2,t2),solution)];
x1 = subs(collocate(p1,x1p1),solution);
x1 = [x1;subs(collocate(p2,x1p2),solution)];
u = subs(collocate(p1,up1),solution);
u = [u;subs(collocate(p2,up2),solution)];
Problem type appears to be: qp
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2010-02-05
=====================================================================================
Problem:  1: Terminal Constraint 2              f_k       0.920531441473363740
                                       sum(|constr|)      0.000000000372747707
                              f(x_k) + sum(|constr|)      0.920531441846111460
                                              f(x_0)      0.000000000000000000

Solver: CPLEX.  EXIT=0.  INFORM=1.
CPLEX Barrier QP solver
Optimal solution found

FuncEv    8 GradEv    8 ConstrEv    8 Iter    8 
CPU time: 0.015625 sec. Elapsed time: 0.015000 sec. 

Plot result

subplot(2,1,1)
plot(t,x1,'*-');
legend('x1');
title('Terminal Constraint state variable');

subplot(2,1,2)
plot(t,u,'+-');
legend('u');
title('Terminal Constraint control');