PROPT Parameter Estimation Problem: Difference between revisions

From TomWiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 10: Line 10:


<math> J = \sum_{i=1,2,3,5} ( x_1(t_i) - x_1^{m}(t_i) )^2 </math>
<math> J = \sum_{i=1,2,3,5} ( x_1(t_i) - x_1^{m}(t_i) )^2 </math>


subject to:
subject to:


<math> \frac{dx_1}{dt} = x_2 </math>
<math> \frac{dx_1}{dt} = x_2 </math>
<math> \frac{dx_2}{dt} = 1-2*x_2-x_1 </math>
<math> \frac{dx_2}{dt} = 1-2*x_2-x_1 </math>


where
where


<math> x_0 = [p_1 \ p_2] </math>
<math> x_0 = [p_1 \ p_2] </math>
<math> t_i = [1 \ 2 \ 3 \ 5] </math>
<math> t_i = [1 \ 2 \ 3 \ 5] </math>
<math> x_1^{m}(t_i) = [0.264 \ 0.594 \ 0.801 \ 0.959] </math>
<math> x_1^{m}(t_i) = [0.264 \ 0.594 \ 0.801 \ 0.959] </math>
<math> -1.5 <= p_{1:2} <= 1.5 </math>
<math> -1.5 <= p_{1:2} <= 1.5 </math>


<source lang="matlab">
<source lang="matlab">

Revision as of 08:10, 9 November 2011

Notice.png

This page is part of the PROPT Manual. See PROPT Manual.

Example 5: DYNOPT User's Guide version 4.1.0

M. Cizniar, M. Fikar, M. A. Latifi, MATLAB Dynamic Optimisation Code DYNOPT. User's Guide, Technical Report, KIRP FCHPT STU Bratislava, Slovak Republic, 2006.

Problem description

Find p1 and p2 over t in [0; 6 ] to minimize


subject to:


where


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

Problem setup

toms t p1 p2
x1meas = [0.264;0.594;0.801;0.959];
tmeas  = [1;2;3;5];

% Box constraints
cbox = {-1.5 <= p1 <= 1.5
    -1.5 <= p2 <= 1.5};

Solve the problem, using a successively larger number collocation points

for n=[10 40]


    p = tomPhase('p', t, 0, 6, n);
    setPhase(p);
    tomStates x1 x2

    % Initial guess
    if n == 10
        x0 = {p1 == 0; p2 == 0};
    else
        x0 = {p1 == p1opt; p2 == p2opt
            icollocate({x1 == x1opt; x2 == x2opt})};
    end

    % Boundary constraints
    cbnd = initial({x1 == p1; x2 == p2});

    % ODEs and path constraints
    x1err = sum((atPoints(tmeas,x1) - x1meas).^2);
    ceq = collocate({dot(x1) == x2; dot(x2) == 1-2*x2-x1});

    % Objective
    objective = x1err;

Solve the problem

    options = struct;
    options.name   = 'Parameter Estimation';
    options.solver = 'snopt';
    solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);

    % Optimal x, p for starting point
    x1opt = subs(x1, solution);
    x2opt = subs(x2, solution);
    p1opt = subs(p1, solution);
    p2opt = subs(p2, solution);
Problem type appears to be: qp
Time for symbolic processing: 0.049765 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license  999007. Valid to 2011-12-31
=====================================================================================
Problem:  1: Parameter Estimation               f_k       0.000000352979271145
                                       sum(|constr|)      0.000000000000054134
                              f(x_k) + sum(|constr|)      0.000000352979325279
                                              f(x_0)      0.000000000000000000

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

FuncEv    1 Iter    5 MinorIter   17
Elapsed time: 0.002000 sec. 

Problem type appears to be: qp
Time for symbolic processing: 0.051384 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license  999007. Valid to 2011-12-31
=====================================================================================
Problem:  1: Parameter Estimation               f_k       0.000000355693079657
                                       sum(|constr|)      0.000000000000071929
                              f(x_k) + sum(|constr|)      0.000000355693151586
                                              f(x_0)     -1.983813647020728800

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

FuncEv    1 MinorIter   40
Elapsed time: 0.003000 sec. 


end

t  = subs(collocate(t),solution);
x1 = collocate(x1opt);

Plot result

figure(1)
plot(t,x1,'*-',tmeas,x1meas,'ro');
legend('x1','Meas');
title('Parameter Estimation state variable');

ParameterEstimation 01.png