Quickguide PROPT Optimal Control

From TomWiki
Jump to navigationJump to search

Notice.png

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

The PROPT MATLAB Optimal Control Software is a new generation platform for solving applied optimal control (with ODE or DAE formulation) and parameters estimation problems.

The platform was developed by MATLAB Programming Contest Winner, Per Rutquist in 2008.

Description

PROPT is a combined modeling, compilation and solver engine for generation of highly complex optimal control problems. PROPT uses a pseudospectral collocation method for solving optimal control problems. This means that the solution takes the form of a polynomial, and this polynomial satisfies the DAE and the path constraints at the collocation points.

In general PROPT has three main functions:

  • Computation of the constant matrices used for the differentiation and integration of the polynomials used to approximate the solution to the trajectory optimization problem.
  • Text manipulation to turn user-supplied expressions into MATLAB code for the cost function f and constraint function c that are passed to a nonlinear programming solver in TOMLAB, while generating highly optimized first and second order derivatives. The code is also compatible with MAD (TOMLAB package for automatic differentiation).
  • Functionality for plotting and computing a variety of information for the solution to the problem.
  • Many other functions such as:
    • Automatic generation of m-file code that can be edited by user
    • Optimized solver selection based on solver type
    • Generation of sparsity pattern for Hessian, constraint Jacobian and Hessian to the Lagrangian function
    • Identification of linear, quadratic objective
    • Separation of simple bounds, linear and nonlinear constraints

Modeling

The PROPT system uses tomSym objects to model optimal control problems. It is possible to define independent variables, dependent functions, scalars and constant parameters:

  toms tf
  toms t
  p = tomPhase('p', t, 0, tf, 30);
  x0 = {tf ==20};
  cbox = {10 <= tf <= 40};
 
  toms z1
  cbox = {cbox; 0 <= z1 <= 500};
  x0 = {x0; z1 ==0};
 
  ki0 = [1e3; 1e7; 10; 1e-3];

States and controls only differ in the sense that states need be continuous between phases:

  tomStates x1
  x0 = {icollocate({x1 ==0})};
 
  tomControls u1
  cbox = {-2 <= collocate(u1) <= 1};
  x0 = {x0; collocate(u1 ==-0.01)};

A variety of boundary, path, event and integral constraints are shown below:

  cbnd = initial(x1 ==1);       % Starting point for x1
  cbnd = final(x1 ==1);         % End point for x1
  cbnd = final(x2 ==2);         % End point for x2
  pathc = collocate(x3 >= 0.5);  % Path constraint for x3
  intc  = {integrate(x2) ==1};  % Integral constraint for x2
  cbnd = final(x3 >= 0.5);       % Final event constraint for x3
  cbnd = initial(x1 <= 2.0);     % Initial event constraint x1

Example

Minimize:

subject to:

To solve the problem with PROPT the following code can be used (with 60 collocation points). The source code file for this, proptQG.m is listed below:

File: tomlab/quickguide/proptQG.m

 toms t
 p = tomPhase('p', t, 0, 5, 60);
 setPhase(p);
 
 tomStates x1 x2 x3
 tomControls u
 
 % Initial guess
 x0 = {icollocate({x1 ==0; x2 ==1; x3 ==0})
     collocate(u ==-0.01)};
 
 % Box constraints
 cbox = {-10  <= icollocate(x1) <= 10
     -10  <= icollocate(x2) <= 10
     -10  <= icollocate(x3) <= 10
     -0.3 <= collocate(u)   <= 1};
 
 % Boundary constraints
 cbnd = initial({x1 ==0; x2 ==1; x3 ==0});
 
 % ODEs and path constraints
 ceq = collocate({dot(x1) ==(1-x2.^2).*x1-x2+u
     dot(x2) ==x1; dot(x3) ==x1.^2+x2.^2+u.^2});
 
 % Objective
 objective = final(x3);
 
 % Solve the problem
 options = struct;
 options.name = 'Van Der Pol';
 solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);

PROPT User's Guide

For more information about how to setup and solve an optimal control problem using TOMLAB /PROPT, see the TOMLAB /PROPT User's Guide. It is available at http://tomopt.com/tomlab/download/manuals.php.

Also, PROPT has a dedicated webpage here: http://tomdyn.com/