Control3 : Optimal Control Problem with a Nonlinear Dynamic Constraint and Boundary Conditions Solved as a General Nonlinear Programming Problem

Reference

  • Neculai Andrei, Nonlinear Optimization Applications Using the GAMS Technology,Springer Optimization and Its Applications, Model Control3 (12.25) in chapter Optimal Control , 2013

Category : GAMS NOA library


Mainfile : control3.gms

$onText
Optimal control problem with a nonlinear dynamic constraint and boundary
conditions solved as a General Nonlinear Programming Problem.

Divya Garg, et al., Direct trajectory optimization and costate estimation of
finite-horizon and infinite-horizon optimal control problems using a
Radau pseudospectral method. Computational optimization and Applications,
vol.49, nr. 2, June 2011, pp. 335-358.
$offText

Sets n states / state1 /
     set k /t1*t100/
     ku(k) control horizon
     ki(k) initial period
     kt(k) terminal period ;

ku(k) = yes$(ord(k) lt card(k));
ki(k) = yes$(ord(k) eq 1);
kt(k) = not ku(k);

Display k, ki, kt, ku;

Parameter rk penalty control / 0.01 /
          xinit(n) initial value / state1 2 / ;

Variables x(n,k) state variable
          u(k) control variable
          j criterion

Equations cost criterion definition
          stateq(n,k) state equation ;

cost..
j =e= .5*sum((k,n), (x(n,k)) +
      .5*sum((ku), (u(ku))*rk*(u(ku))) );

stateq(n,k+1)..

x(n,k+1) =e= 2*x(n,k) + 2*u(k)*sqrt(x(n,k)) ;

Model control3 /all/;

$ifThenI x%mode%==xbook
x.l(n,k) = xinit(n);
x.fx(n,ki) = xinit(n);
x.fx(n,kt) = 2;
$endIf

Solve control3 minimizing j using nlp;

Display x.l, u.l;

$ifThenI x%mode%==xbook
file res1 /control3.dat/;
put res1
loop(k, put x.l('state1',k):10:5,',', put/)

loop(k, put u.l(k):10:5,',', put/)
$endIf

* End Control3