57
Introduction to the Optimal Control Software GPOPS II Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville, FL 32611-6250 Tutorial on GPOPS II NSF CBMS Workshop 23 July 2018

Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Introduction to the Optimal Control Software GPOPS− II

Anil V. Rao

Department of Mechanical and Aerospace Engineering

University of Florida

Gainesville, FL 32611-6250

Tutorial on GPOPS− II

NSF CBMS Workshop

23 July 2018

Page 2: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Overview of Presentation

• Mathematical Problem Being Solved by GPOPS− II

⊲ Continuous optimal control problem

⊲ Gaussian quadrature approximation of optimal control problem

⊲ Structure of NLP arising from Gauss quadrature approximation

• Layout of GPOPS− II Software

⊲ Main driver function

◦ Specification of bounds on variables and constraints

◦ Providing an initial guess

⊲ Form and syntax of user-defined continuous and endpoint functions

• Use of Various Options in GPOPS− II

⊲ Choice of NLP solvers

⊲ NLP solver options

⊲ Derivative options

Copyright © 2006–2014 Anil V. Rao Page 2

Page 3: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Optimal Control Problem Solved by GPOPS− II

J = φ(

e(1), . . . , e(P ), s)

,

y(p) = a(p)(y(p),u(p), t(p), s), (p = 1, . . . , P ),

bmin ≤ b(

e(1), . . . , e(P ), s)

≤ bmax,

e(p) =[

y(p)(t(p)0 ), t

(p)0 ,y(p)(t

(p)f ), t

(p)f ,q(p)

]

, (p = 1, . . . , P )

c(p)min ≤ c(p)(y(p),u(p), t(p), s) ≤ c(p)max, (p = 1, . . . , P ),

smin ≤ s ≤ smax,

q(p)min ≤ q(p) ≤ q

(p)max, (p = 1, . . . , P ),

q(p)i =

∫ t(p)f

t(p)0

g(p)i (y(p),u(p), t(p), s)dt, (i = 1, . . . n

(p)q ), (p = 1, . . . , P ).

• Form of Cost Functional

⊲ Written purely in Mayer Form

⊲ Integrals are computed separately and treated as variables

⊲ Allows for more general formulation

Copyright © 2006–2014 Anil V. Rao Page 3

Page 4: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

• Generality of Constraints

⊲ Event constraints utilize information from endpoints of any phase

⊲ Can place constraints directly on integrals

⊲ Path constraints can be a function of state, control, static parameters,

and time

Copyright © 2006–2014 Anil V. Rao Page 4

Page 5: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Radau Collocation for a One-Phase Optimal Control Problem

• State Approximation Using Lagrange Polynomials

y(k)(τ) ≈ Y(k)(τ) =

Nk+1∑

j=1

Y(k)j ℓ

(k)j (τ), ℓ

(k)j (τ) =

Nk+1∏

l=1

l 6=j

τ − τ(k)l

τ(k)j − τ

(k)l

,

• Derivative of State Approximation

dY(k)(τ)

dτ=

Nk+1∑

j=1

Y(k)j

dℓ(k)j (τ)

dτ.

• Approximation of Cost Functional

J = φ(Y(1)1 , t0,Y

(K)NK+1, tf ,q),

• Discretized Dynamic Constraints

Nk+1∑

j=1

D(k)ij Y

(k)j −

tf − t02

a(Y(k)i ,U

(k)i , τ

(k)i ; t0, tf ) = 0, (i = 1, . . . , Nk).

Copyright © 2006–2014 Anil V. Rao Page 5

Page 6: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

D(k)ij =

[

dℓ(k)j (τ)

]

τ(k)i

, (i = 1, . . . , Nk, j = 1, . . . , Nk+1, k = 1, . . . , K),

• Equivalent Integral Form of Dynamic Constraints

Y(k)i+1−Y

(k)1 −

tf − t02

Nk∑

j=1

I(k)ij a(Y

(k)i ,U

(k)i , τ

(k)i ; t0, tf ) = 0, (i = 1, . . . , Nk),

I(k) ≡[

D(k)2:Nk+1

]−1

,

• Discretized Path Constraints

cmin ≤ c(Y(k)i ,U

(k)i , τ

(k)i ; t0, tf ) ≤ cmax, (i = 1, . . . , Nk),

• Discretized Integrals

qj ≈K∑

k=1

Nk∑

i=1

tf − t02

w(k)i gj(Y

(k)i ,U

(k)i , τ

(k)i ; t0, tf ), (i = 1, . . . , Nk, j = 1, . . . , nq)

• Discretized Boundary Conditions

bmin ≤ b(Y(1)1 , t0,Y

(K)NK+1, tf ,q) ≤ bmax.

Copyright © 2006–2014 Anil V. Rao Page 6

Page 7: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Y(k)Nk+1 = Y

(k+1)1 , (k = 1, . . . , K − 1),

Copyright © 2006–2014 Anil V. Rao Page 7

Page 8: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

NLP Arising from Multiple-Phase Radau Collocation

• Objective Function

Φ(Z)

• Constraints

Fmin ≤ F(Z) ≤ Fmax.

• Variable Bounds

Zmin ≤ Z ≤ Zmax.

Copyright © 2006–2014 Anil V. Rao Page 8

Page 9: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

• Decision Vector

Z =

z(1)

...

z(P )

s1...

sns

, z(p) =

V(p)1

...

V(p)

n(p)y

W(p)1

...

W(p)

n(p)u

q(p)

t(p)0

t(p)f

, (p = 1, . . . , P ),

V(p) =

Y(p)1

...

Y(p)

N(p)+1

∈ R(N(p)+1)×n(p)

y , W(p) =

U(p)1

...

U(p)

N(p)

∈ RN(p)×n(p)

u ,

Copyright © 2006–2014 Anil V. Rao Page 9

Page 10: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

• NLP Cost Function in Terms of Optimal Control Cost

Φ(Z) = φ

• NLP Constraints

F =

f (1)

...

f (P )

b

,

Copyright © 2006–2014 Anil V. Rao Page 10

Page 11: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

f (p) =

∆(p)1

...

∆(p)

n(p)y

C(p)1

...

C(p)

n(p)c

ρ(p)

, (p = 1, . . . , P ),

• Defect Constraint Matrix (Differential Form)

∆(p) = D(p)Y(p) −t(p)f − t

(p)0

2A(p) ∈ R

N(p)×n(p)y .

• Defect Constraint Matrix (Integral Form)

∆(p) = E(p)Y(p) −t(p)f − t

(p)0

2I(p)A(p) ∈ R

N(p)×n(p)y ,

Copyright © 2006–2014 Anil V. Rao Page 11

Page 12: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

A(p) =

a(Y(p)1 ,U

(p)1 , t

(p)1 , s)

...

a(Y(p)

N(p) ,U(p)

N(p) , t(p)

N(p) , s)

∈ RN(p)×n(p)

y ,

• Path Constraint Matrix

C(p) =

c(Y(p)1 ,U

(p)1 , t

(p)1 , s)

...

c(Y(p)

N(p) ,U(p)

N(p) , t(p)

N(p) , s)

∈ RN(p)×n(p)

c ,

• Integral Constraints

ρ(p)i = q

(p)i −

t(p)f − t

(p)0

2

[

w(p)]T

G(p)i , (i = 1, . . . , n(p)

q ),

G(p) =

g(Y(p)1 ,U

(p)1 , t

(p)1 , s)

...

g(Y(p)

N(p) ,U(p)

N(p) , t(p)

N(p) , s)

∈ RN(p)×n(p)

q .

Copyright © 2006–2014 Anil V. Rao Page 12

Page 13: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

• Equality Constraints

∆(p) = 0,

ρ(p) = 0,

• Inequality Constraints

C(p)min ≤ C(p) ≤ C

(p)max,

bmin ≤ b ≤ bmax.

Copyright © 2006–2014 Anil V. Rao Page 13

Page 14: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Def

ect

1

{ State 1 { State 2 { State ny

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Zeros or Diagonal

Block+D

-Matrix

Zeros or Diagonal

Block+D

-Matrix

{D

efec

t 2{

Def

ect ny

{

{Control 1 {Control nu

Pat

h 1

Either Zeros or

Diagonal Block

{

Pat

h nc

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

{

Ev

ent

Co

nst

rain

ts

{ Either Zeros orEndpoints only

Either Zeros orEndpoints only All Zeros

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Zeros or Diagonal

Block+D

-Matrix

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

t0 tf

q1 qnq

ρnq

ρ1

Identity

All Zeros

All Zeros

s1 sns

Copyright © 2006–2014 Anil V. Rao Page 14

Page 15: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

{Control nu

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

t0 tf

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Diagonal Block

With Corners

Diagonal Block

With Corners

Diagonal Block

With Corners

Diagonal Block

With Corners

{Control 1{ State ny{ State 1

q1 qnq

All Zeros

All Zeros

s1 sns

Copyright © 2006–2014 Anil V. Rao Page 15

Page 16: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Def

ect

1

{ State 1 { State 2 { State ny

{D

efec

t 2{

Def

ect ny

{

{Control 1 {Control nu

Pat

h 1

Either Zeros or

Diagonal Block

{

Pat

h nc

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

{

Ev

ent

Co

nst

rain

ts

{ Either Zeros orEndpoints only

Either Zeros orEndpoints only All Zeros

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

t0 tf

q1 qnq

ρnq

ρ1

Identity

All Zeros

All Zeros

Zeros or Integration

Block+F-Matrix

Zeros or Integration

Block+F-Matrix

Zeros or Integration

Block+F-Matrix

Either Zeros or

Integration Block

Either Zeros or

Integration Block

Either Zeros or

Integration Block

Either Zeros or

Integration Block

Either Zeros or

Integration Block

Either Zeros or

Integration Block

Either Zeros or

Integration Block

Either Zeros or

Integration Block

Either Zeros or

Integration Block

Either Zeros or

Integration Block

s1 sns

Copyright © 2006–2014 Anil V. Rao Page 16

Page 17: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

{Control nu

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

t0 tf

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Either Zeros or

Diagonal Block

Diagonal Block

With Corners

Diagonal Block

With Corners

Diagonal Block

With Corners

Diagonal Block

With Corners

{Control 1{ State ny{ State 1

q1 qnq

All Zeros

All Zeros

s1 sns

Copyright © 2006–2014 Anil V. Rao Page 17

Page 18: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Sparse Structure of NLP

• Structure Has Been Described in Detail by Patterson and Rao

• Multiple-Phase Optimal Control Problem

⊲ Constraint Jacobian: Block Diagonal Version of One-Phase Jacobian

⊲ Lagrangian Hessian: Block Diagonal Version of One-Phase Hessian

Copyright © 2006–2014 Anil V. Rao Page 18

Page 19: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

NLP Scaling

• Variables and Constraints Scaled to Approximately Order One

• Variable Scaling: Put All Variables on Unit Interval [−1/2, 1/2]

⊲ Suppose x ∈ [a, b]

⊲ Then x ∈ [−1/2, 1/2]

x = vxx+ rx,

vx =1

b− a,

rx =1

2−

b

b− a.

• Constraint Scaling: Make Constraints O(1)

⊲ Defect constraints scaled same as states

⊲ Objective, event & path constraints: scale by sampled average of

gradient

Copyright © 2006–2014 Anil V. Rao Page 19

Page 20: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Computation of Derivatives

• Exploits Sparse Structure of NLP

⊲ Patterson and Rao: only need optimal control function derivatives

⊲ GPOPS− II: Sparse forward, central, or backward approximations

• Example: Consider the optimal control function f(x), f : Rn −→ Rm

⊲ Forward Difference Approximation of ∂f/∂x

∂f

∂xi

≈f(x+ hi)− f(x)

hi

,

⊲ hi = Perturbation of ith component of x.

⊲ Then

hi = hiei

⊲ ei =ith row of the n× n identity matrix

⊲ hi =Perturbation Associated with xi.

⊲ Note that

hi = h(1 + |xi|),

Copyright © 2006–2014 Anil V. Rao Page 20

Page 21: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

⊲ Base Perturbation Size = optimal for ≈ O(1) Function

Copyright © 2006–2014 Anil V. Rao Page 21

Page 22: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Adaptive Mesh Refinement

• GPOPS− II Uses Variable-Order Mesh Refinement

• What Can Change Between Meshes?

⊲ Number of mesh intervals

⊲ Width of each mesh interval

⊲ Polynomial degree within a mesh interval

• Iterate on Mesh Until Specified Accuracy Tolerance is Met

• Either Method: Need to Place Lower and Upper Limits on Polynomial

Degree

• Error Based on Relative Error in State

• Fundamental Difference Between Mesh Refinement Methodsf

⊲ hp method: use curvature to modify mesh

⊲ ph method: use exponential converge of Radau collocation

⊲ If Maximum Polynomial Degree Limit is Hit: Divide Into More Mesh

Intervals

Copyright © 2006–2014 Anil V. Rao Page 22

Page 23: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Algorithmic Flow of GPOPS− II

INPUT:

Initial Setup for OptimalControl Problem

Find Properties ofOptimal Control Problem

from the User-Provided Setup

Find Derivative Dependenciesof the Optimal Control

Problem Functions

Find Optimal ControlProblem Variable and

Function Scaling

Optimal Control ProblemTranscribed to NonlinearProgramming Problem

on Current Mesh

Is Estimated Error <Desired Error Tolerance?

Determine New Mesh for theOptimal Contol Problem

Set Initial Guess of theOptimal Control Problem

to the Current Solution

Estimate the Errorof the Optimal Control

Problem Solution

False

True OUTPUT:

Solution to OptimalControl Problem

Copyright © 2006–2014 Anil V. Rao Page 23

Page 24: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Overview of GPOPS− II Usage

Copyright © 2006–2014 Anil V. Rao Page 24

Page 25: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Main call to GPOPS− II:

output=gpops2(input),

Required Fields:

• name: a string with no blank spaces that contains the name of the problem;

• functions: a structure that contains the name of the continuous function

and the endpoint function;

• bounds: an structure that contains the information about the lower and

upper bounds on the different variables and constraints in the problem;

• guess: an structure that contains a guess of the time, state, control,

integrals, and static parameters in the problem;

Optional Fields:

• auxdata: a structure containing auxiliary data that may be used by

different functions in the problem. Including auxdata eliminates any need

to specify global variables for use in the problem. The following table

provided the possible values and their defaults for the field setup.auxdata:

Copyright © 2006–2014 Anil V. Rao Page 25

Page 26: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Field Possible Values Default

setup.auxdata Any Problem-Specific Data Not Provided

• derivatives: a structure that specifies the derivative approximation to be

used by the NLP solver and the derivative order (’first’ or ’second’) to be

used by the NLP solver. The field setup.derivatives contains three fields

supplier, derivativelevel, and dependencies where the field

setup.derivatives.supplier contains the type of derivative approximation

, the field setup.derivatives.derivativelevel contains the derivative order,

while the field setup.derivatives.dependencies determines how the

dependencies are found. The following table provided the possible values

and their defaults for the field setup.derivatives:Field Possible Values Default

setup.derivatives.supplier ’sparseFD’ or ’sparseBD’ or ’sparseCD’ or ’adigator’ ’sparseFD’

setup.derivatives.derivativelevel ’first’ or ’second’ ’first’

setup.derivatives.dependencies ’full’, ’sparse’ or ’sparseNaN’ ’sparseNaN’

Note that the option setup.derivatives.supplier is ignored when the

derivative option is set to either ’analytic’ or ’adigator’.

• scales: a structure that specifies how the problem to be solved is scaled.

The field scales itself contains a field method that can be set to one of

Copyright © 2006–2014 Anil V. Rao Page 26

Page 27: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

the following:

Field Possible Values Default

’none’ or ’automatic-bounds’

setup.scales.method or ’automatic-bounds’ or ’automatic-guess’ ’none’

’automatic-guessUpdate’ or ’automatic-hybrid’

or ’automatic-hybridUpdate’ or ’defined’

• method: a string that defines the version of the collocation to be used

when solving the problem. Valid options are

Field Possible Values Default

setup.method ’RPM-Differentiation’ or ’RPM-Integration’ ’RPM-Differentiation’

• mesh: a structure that specifies the information as to the type of mesh

refinement method to be used and the mesh refinement accuracy tolerance,

as well as the initial mesh. The structure setup.mesh contains the fields

method, tolerance, maxiterations, and phase. The field

setup.mesh.method is a string that specified the particular mesh

refinement method to be used, while the field setup.mesh.tolerance

contains the desired accuracy tolerance of the mesh, while the field

setup.mesh.maxiterations contains the maximum number of allowed mes

iterations.

Copyright © 2006–2014 Anil V. Rao Page 27

Page 28: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Field Possible Values Default

setup.mesh.method ’hp-PattersonRao’ or ’hp-DarbyRao’ or ’hp-LiuRao’ ’hp-PattersonRao’

setup.mesh.tolerance Positive Number Between 0 and 1 10−3

setup.mesh.maxiteration Non-Negative Integer 10

Field Possible Values Default

setup.mesh.phase(p).fractionRow Vector of Length M ≥ 1 of Positive

Numbers > 0 and < 1 that Sum to Unity0.1*ones(1,10)

setup.mesh.phase(p).colpoints

Row Vector of Length M ≥ 1

of Positive Integers > 1 and < 10

(M is the same as in setup.mesh.phase(p).fraction)

4*ones(1,10)

• nlp: a structure that specifies the NLP solver to be used and the options

to be used within the chosen NLP solver. setup.nlp contains the field

solver and options. The field solver contains a string indicating the NLP

solver to be used. The fields ipoptoptions and snoptoptions are

structures that themselves contains fields with options for the NLP solvers

IPOPT and SNOPT, respectively, which can be set from GPOPS− II.Field Possible Values Default

setup.nlp.solver ’snopt’ or ’ipopt’ ’ipopt’

Field nlp.ipoptoptions for the NLP solver IPOPT:Field Possible Values Default

setup.nlp.ipoptoptions.linear_solver ’mumps’ or ’ma57’ ’mumps’

setup.nlp.ipoptoptions.tolerance Positive Real Number 10−7

setup.nlp.ipoptoptions.maxiterations Positive Integer 2000

Copyright © 2006–2014 Anil V. Rao Page 28

Page 29: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Field nlp.snoptoptions for the NLP solver SNOPT:

setup.nlp.snoptoptions.tolerance Positive Real Number 10−6

setup.nlp.snoptoptions.maxiterations Positive Integer 2000

• displaylevel: a integer that takes on the values 0, 1, or 2 and provides the

amount of output that is sent to the MATLAB command window during

an execution of GPOPS− II. The following table provided the possible

values and their defaults for the field setup.auxdata:

Field Possible Values Default

setup.displaylevel 0, 1, or 2 2

Copyright © 2006–2014 Anil V. Rao Page 29

Page 30: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Syntax for Structure setup.functions

setup.functions.continuous = @continuousfun.m

setup.functions.endpoint = @endpointfun.m

Copyright © 2006–2014 Anil V. Rao Page 30

Page 31: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Syntax for bounds Structure

• bounds.phase(p).initialtime.{lower,upper}: scalars that contain the

information about the lower and upper bounds on the initial time in phase

p ∈ [1, . . . , P ].

bounds.phase(p).initialtime.lower = tlower0

bounds.phase(p).initialtime.upper = tupper0

• bounds.phase(p).finaltime.{lower,upper}: scalars that contain the

information about the lower and upper bounds on the final time in phase

p ∈ [1, . . . , P ].

bounds.phase(p).finaltime.lower = tlowerf

bounds.phase(p).finaltime.upper = tupperf

• bounds.phase(p).initialstate.{lower,upper}: row vectors of length

n(p)y that contain the lower and upper bounds on the initial state in phase

Copyright © 2006–2014 Anil V. Rao Page 31

Page 32: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

p ∈ [1, . . . , P ].

bounds.phase(p).initialstate.lower =[

ylower0,1 · · · ylower

0,n(p)y

]

bounds.phase(p).initialstate.upper =[

yupper0,1 · · · yupper

0,n(p)y

]

• bounds.phase(p).state.{lower,upper}: row vectors of length n(p)y that

contain the lower and upper bounds on the state during phase

p ∈ [1, . . . , P ].

bounds.phase(p).state.lower =[

ylower1 · · · ylower

n(p)y

]

bounds.phase(p).state.upper =[

yupper1 · · · yupper

n(p)y

]

• bounds.phase(p).finalstate.{lower,upper}: row vectors of length n(p)y

that contain the lower and upper bounds on the final state in phase

p ∈ [1, . . . , P ].

bounds.phase(p).finalstate.lower =[

ylowerf,1 · · · ylower

f,n(p)y

]

bounds.phase(p).finalstate.upper =[

yupperf,1 · · · yupper

f,n(p)y

]

Copyright © 2006–2014 Anil V. Rao Page 32

Page 33: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

• bounds.phase(p).control.{lower,upper}: row vectors of length n(p)y

that contain the lower and upper bounds on the control during phase

p ∈ [1, . . . , P ].

bounds.phase(p).control.lower =[

ulower1 · · · ulower

n(p)u

]

bounds.phase(p).control.upper =[

uupper1 · · · uupper

n(p)u

]

• bounds.phase(p).path.{lower,upper}: row vectors of length n(p)c that

contain the lower and upper bounds on the path constraints during phase

p ∈ [1, . . . , P ].

bounds.phase(p).path.lower =[

clower1 · · · clower

n(p)u

]

bounds.phase(p).path.upper =[

cupper1 · · · cupper

n(p)u

]

• bounds.phase(p).integral.{lower,upper}: row vectors of length n(p)q

that contain the lower and upper bounds on the integrals in phase

Copyright © 2006–2014 Anil V. Rao Page 33

Page 34: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

p ∈ [1, . . . , P ].

bounds.phase(p).integral.lower =[

qlower1 · · · qlower

n(p)q

]

bounds.phase(p).integral.upper =[

qupper1 · · · qupper

n(p)q

]

• bounds.phase(p).duration.{lower,upper}: scalars that contain the

lower and upper bounds on the duration of a phases p ∈ [1, . . . , P ]. The

duration is the difference between the final time of the phase and the initial

time of the phase, t(p)f − t

(p)0 .

• bounds.parameter.{lower,upper}: row vectors of length ns that

contain the lower and upper bounds on the static parameters in the

problem.

bounds.parameter.lower =[

slower1 · · · slower

ns

]

bounds.parameter.upper =[

supper1 · · · supper

ns

]

• bounds.eventgroup(g).{lower,upper}: row vectors of length n(g)b that

contain the lower and upper bounds on the group g = 1, . . . , G of event

Copyright © 2006–2014 Anil V. Rao Page 34

Page 35: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

constraints.

bounds.eventgroup(g).lower =[

blower1 · · · blower

n(g)b

]

bounds.eventgroup(g).upper =[

bupper1 · · · bupper

n(g)b

]

Copyright © 2006–2014 Anil V. Rao Page 35

Page 36: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Syntax for Endpoint Function

function output=endpointfun(input)

• input.phase(p).initialtime: a scalar that contains the initial time in

phase p = 1, . . . , P ;

• input.phase(p).finaltime: a scalar that contains the final time in phase

p = 1, . . . , P ;

• input.phase(p).initialstate: a row vector of length n(p)y that contains the

initial state in phase p = 1, . . . , P ;

• input.phase(p).finalstate: a row vector of length n(p)y that contains the

final state in phase p = 1, . . . , P ;

• input.phase(p).integral: a row vector of length n(p)d that contains the

integrals in phase p = 1, . . . , P ;

• input.parameter: a row vector of length ns that contains the static

parameters in phase p = 1, . . . , P ;

• output.objective: a scalar that contains the result of computing the

Copyright © 2006–2014 Anil V. Rao Page 36

Page 37: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

objective function on the current call to input.functions.endpoint;

• output.eventgroup: an array of structures of length G (where G is the

number of event groups) such that the gth element in output.eventgroup

is a row vector of length n(g)b that contains the result of evaluating gth

group of event constraints at the values given in the call to the function

input.functions.endpoint;

Copyright © 2006–2014 Anil V. Rao Page 37

Page 38: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Syntax for Endpoint Function

function output=continuousfun(input)

Fields of Structure input:

• input.phase(p).time: a column vector of length N (p), where N (p) is the

number of collocation points in phase p = 1, . . . , P .

• input.phase(p).state: a matrix of size N (p) × n(p)y , where N (p) and n

(p)y

are, respectively, the number of collocation points and the dimension of the

state in phase p = 1, . . . , P ;

• input.phase(p).control: a matrix of size N (p) × n(p)u , where N (p) and n

(p)u

are, respectively, the number of collocation points and the dimension of the

control in phase p = 1, . . . , P ;

• input.phase(p).parameter: a matrix of size N (p) × ns, where N (p) is the

number of collocation points in phase p = 1, . . . , P and and ns is the

dimension of the static parameter. [Note: see below for the reason why

the static parameter has a size N (p) × ns];

Copyright © 2006–2014 Anil V. Rao Page 38

Page 39: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Fields of Structure output:

• output.dynamics: a matrix of size N (p) × n(p)y , where N (p) and n

(p)y are,

respectively, the number of collocation points and the dimension of the

state in phase p = 1, . . . , P ;

• output.path: a matrix of size N (p) × n(p)c , where N (p) and n

(p)c are,

respectively, the number of collocation points and the number of path

constraints in phase p = 1, . . . , P ;

• output.integrand: a matrix of size N (p) × n(p)d , where N (p) and n

(p)d are,

respectively, the number of collocation points and the number of integrals

in phase p = 1, . . . , P ;

Copyright © 2006–2014 Anil V. Rao Page 39

Page 40: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Specifying an Initial Guess for a GPOPS− II Run

• setup.guess.phase(p).time: a column vector of length M (p) in phase

p = 1, . . . , P ;

• setup.guess.phase(p).state: a matrix of size M (p) × n(p)y , where n

(p)y is

the dimension of the state in phase p = 1, . . . , P ;

• setup.guess.phase(p).control: a matrix of size M (p) × n(p)u , where n

(p)u is

the dimension of the control in phase p = 1, . . . , P ;

• setup.guess.phase(p).integral: a row vector of length n(p)d , where n

(p)d is

the number of integrals in phase p = 1, . . . , P ;

• setup.guess.parameter: a row vector of length size ns, where ns is the

number of static parameters in the problem.

Copyright © 2006–2014 Anil V. Rao Page 40

Page 41: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

NLP Solver Options with GPOPS− II

• IPOPT (Default)

⊲ Open source

⊲ Employs and interior-point method

⊲ Two different derivative modes

◦ Quasi-Newton: first derivatives only

◦ Full-Newton: first and second derivatives

⊲ Key characteristics of IPOPT

◦ Mediocre performance in quasi-Newton mode

◦ Extremely fast in full-Newton mode

◦ Scales extremely well as problem size increases

◦ Issue using mesh refinement

· Does not take full advantage of good initial guess

· Backs away From solution due to interior-point method

◦ Kinds of problems for which IPOPT works well (in full-Newton mode)

· Multiple time-scale (ill-conditioned) problems

Copyright © 2006–2014 Anil V. Rao Page 41

Page 42: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

· Problems with not so well defined minima

· Problems that do not require a good initial guess

• SNOPT (not included; must be obtained separately)

⊲ Available commercially

⊲ Employs a quasi-Newton SQP method

⊲ Key characteristics of SNOPT

◦ Very good general-purpose NLP solver

◦ Not always fast, but good for reasonable range of problems

◦ Does not scale well as problem size increases

◦ Converges very quickly with good initial guess

Copyright © 2006–2014 Anil V. Rao Page 42

Page 43: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Examples of Using GPOPS− II

Copyright © 2006–2014 Anil V. Rao Page 43

Page 44: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Hyper-Sensitive Problem

minimize 12

∫ tf

0

(x2 + u2)dt subject to

x = −x3 + u,

x(0) = 1,

x(tf ) = 1.5,

tf = 10000.

Initial Guess

xguess = linear(0, tf , x(0), x(tf )),

uguess = 0,

tguessf = tf .

Next: Closer Examination of the GPOPS− II Code

Copyright © 2006–2014 Anil V. Rao Page 44

Page 45: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

0 2000 4000 6000 8000 10000-0.2

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

0 2000 4000 6000 8000 10000-1

-0.5

0

0.5

1

1.5

2

2.5

Copyright © 2006–2014 Anil V. Rao Page 45

Page 46: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

GPOPS − II

SOS

t

x(t)

0

0

1

5 10 20 2515-0.2

0.2

0.4

0.6

1.2

1.4

1.6

1.8

GPOPS − II

SOS

t

x(t)

0

1

9985 9990 9995 100009975 9980-0.2

0.2

0.4

0.6

1.2

1.4

1.6

1.8

GPOPS − II

SOS

t

u(t)

0

0

1

5 10 20 25

-0.8

-0.6

-0.4

15

-0.2

-1

0.2

0.4

0.6

1.8

GPOPS − II

SOS

t

u(t)

0

1

2

3

4

5

6

7

8

9985 9990 9995 100009975 9980-1

Copyright © 2006–2014 Anil V. Rao Page 46

Page 47: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Mesh

Refi

nem

en

tIt

era

tio

n

Mesh Point Locations

01

2

3

4

5

6

7

8

100002000 4000 6000 8000

Copyright © 2006–2014 Anil V. Rao Page 47

Page 48: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Mesh Relative Error Estimate

1 2.827× 101

2 2.823× 100

3 7.169× 10−1

4 1.799× 10−1

5 7.092× 10−2

6 8.481× 10−3

7 1.296× 10−3

8 5.676× 10−7

• Note Performance of GPOPS− II

• Accurately Captures Rapid Transients in Solution

• Achieves a High-Accuracy Solution

• Concentrates Mesh Points Near Key Features in Solution

Copyright © 2006–2014 Anil V. Rao Page 48

Page 49: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Reusable Launch Vehicle Entry

Maximize

J = φ(tf )

Subject to

r = v sin γ , θ =v cos γ sinψ

r cosφ,

φ =v cos γ cosψ

r, v = −

D

m− g sin γ,

γ =L cosσ

mv−

( g

v−

v

r

)

cos γ , ψ =L sinσ

mv cos γ+v cos γ sinψ tanφ

r,

and the boundary conditions

h(0) = 79248 km , h(tf ) = 24384 km,

θ(0) = 0 deg , θ(tf ) = Free,

φ(0) = 0 deg , φ(tf ) = Free,

v(0) = 7.803 km/s , v(tf ) = 0.762 km/s

γ(0) = −1 deg , γ(tf ) = −5 deg,

ψ(0) = 90 deg , ψ(tf ) = Free

Next: Closer Examination of the GPOPS− II Code

Copyright © 2006–2014 Anil V. Rao Page 49

Page 50: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

SOS

GPOPS − II

t (s)

h(t)

(km

)

020

30

40

50

60

70

80

500 1500 25001000 2000

SOS

GPOPS − II

t (s)

v(t)

(km

/s)

00

1

2

3

4

5

500 1500 2500

6

7

8

1000 2000

SOS

GPOPS − II

t (s)

φ(t)

(deg

)

00

5

15

20

25

30

35

500 1500 2500

10

1000 2000

SOS

GPOPS − II

t (s)

γ(t)

(deg

)

0

0

1

500 1500 2500-6

-5

-4

-3

-2

-1

1000 2000

SOS

GPOPS − II

t (s)

α(t)

(deg

)

16.5

17

17.5

0 500 1500 25001000 2000

SOS

GPOPS − II

t (s)

σ(t)

(deg

)

-10

-20

-30

-40

-50

-60

-70

-80

0

0 500 1500 2500

10

1000 2000

Copyright © 2006–2014 Anil V. Rao Page 50

Page 51: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Mesh Estimated Number of Estimated Number of

Iteration Error (GPOPS − II) Collocation Points Error (SOS) Collocation Points

1 2.463 × 10−3 41 1.137 × 10−2 51

2 2.946 × 10−4 103 1.326 × 10−3 101

3 1.202 × 10−5 132 3.382 × 10−5 101

4 8.704 × 10−8 175 1.314 × 10−6 101

5 – – 2.364 × 10−7 201

6 – – 2.364 × 10−7 232

7 – – 1.006 × 10−7 348

8 – – 9.933 × 10−8 353

• Note Performance of GPOPS− II vs SOS

• GPOPS− II Uses Fewer Mesh Refinement Iterations

• Also, GPOPS− II Generates a Much Smaller Mesh

Copyright © 2006–2014 Anil V. Rao Page 51

Page 52: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Space Station Attitude Control

J = 12

∫ tf

t0

uTudt

subject to the dynamic constraints

ω = J−1 {τ gg(r)− ω⊗ [Jω + h]− u} ,

r = 12

[

rrT + I+ r]

[ω − ω(r)] ,

h = u,

the inequality path constraint

‖h‖ ≤ hmax,

Copyright © 2006–2014 Anil V. Rao Page 52

Page 53: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

and the boundary conditions

t0 = 0,

tf = 1800,

ω(0) = ω0,

r(0) = r0,

h(0) = h0,

0 = J−1 {τ gg(r(tf ))− ω⊗(tf ) [Jω(tf ) + h(tf )]} ,

0 = 12

[

r(tf )rT(tf ) + I+ r(tf )

]

[ω(tf )− ω0(r(tf ))] ,

ω0(r) = −ωorbC2,

τ gg = 3ω2orbC

⊗3 JC3,

and C2 and C3 are the second and third column, respectively, of the matrix

C = I+2

1 + rTr

(

r⊗r⊗ − r⊗)

.

Copyright © 2006–2014 Anil V. Rao Page 53

Page 54: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

In this example the matrix J is given as

J =

2.80701911616× 107 4.822509936× 105 −1.71675094448× 107

4.822509936× 105 9.5144639344× 107 6.02604448× 104

−1.71675094448× 107 6.02604448× 104 7.6594401336× 107

,

ω0 =

−9.5380685844896× 10−6

−1.1363312657036× 10−3

+5.3472801108427× 10−6

,

r0 =

2.9963689649816× 10−3

1.5334477761054× 10−1

3.8359805613992× 10−3

,

h0 =

5000

5000

5000

.

Next: Closer Examination of the GPOPS− II Code

Copyright © 2006–2014 Anil V. Rao Page 54

Page 55: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

SOS

GPOPS − II

t (s)

ω1(t)×

10−

4

-8

-6

-4

-2

0

0

2

500 1500

6

4

1000 2000

SOS

GPOPS − II

t (s)

ω2(t)×

10−

4

-11.6

-11.5

-11.4

-11.3

-11.2

-11.1

-11

-10.9

0 500 15001000 2000

SOS

GPOPS − II

t (s)

ω3(t)×

10−

4

-3

-2

-1

0

0

1

2

3

5

500 1500

4

1000 2000

SOS

GPOPS − II

t (s)

r1(t)

0

0 500 15001000 2000-0.05

0.05

0.1

0.15

SOS

GPOPS − II

t (s)

r2(t)

0 500 15000.144

0.146

0.148

0.152

0.154

0.156

0.158

1000 2000

0.15

SOS

GPOPS − II

t (s)

r3(t)

00 500 15001000 2000

0.005

0.01

0.015

0.02

0.025

0.03

0.035

0.04

SOS

GPOPS − II

t (s)

h1(t)

-5

-10

0

0

5

500 1500

10

1000 2000

SOS

GPOPS − II

t (s)

h2(t)

-4

-2

0

0

2

500 1500

6

8

4

1000 2000

SOS

GPOPS − II

t (s)

h3(t)

-6

-4

-2

0

0

2

500 1500

6

4

1000 2000

SOS

GPOPS − II

t (s)

u1(t)

-150

-100

-50

0

0

50

100

500 15001000 2000

SOS

GPOPS − II

t (s)

u2(t)

-5

-15

-10

0

0

5

15

20

25

500 1500

10

1000 2000

SOS

GPOPS − II

t (s)

u3(t) -10

-20

-30

-40

-50

0

0

20

500 1500

10

1000 2000

Copyright © 2006–2014 Anil V. Rao Page 55

Page 56: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

Multiple-Stage Launch Vehicle Ascent

J = m(t(4)f )

Subject to

r(p) = v(p),

v(p) = −µ

‖r(p)‖3r(p) +

T (p)

m(p)u(p) +

D(p)

m(p),

m(p) = −T (p)

g0Isp,

(p = 1, . . . , 4),

r(t0) = r0 = (5605.2, 0, 3043.4)× 103 m,

v(t0) = v0 = (0, 0.4076, 0)× 103 m/s,

m(t0) = m0 = 301454 kg.

Copyright © 2006–2014 Anil V. Rao Page 56

Page 57: Introduction to the Optimal Control Software GPOPS IIjuliu/cbms18/img/Rao2.pdf · Anil V. Rao Department of Mechanical and Aerospace Engineering University of Florida Gainesville,

Not for Redistribution Without Permission of the Author

r(p)(t(p)f )− r(p+1)(t

(p+10 ) = 0,

v(p)(t(p)f )− v(p+1)(t

(p+1)0 ) = 0, (p = 1, . . . , 3)

m(p)(t(p)f )−m

(p)dry −m(p+1)(t

(p+1)0 ) = 0,

a(t(4)f ) = af = 24361.14 km,

e(t(4)f ) = ef = 0.7308,

i(t(4)f ) = if = 28.5 deg,

θ(t(4)f ) = θf = 269.8 deg,

φ(t(4)f ) = φf = 130.5 deg,

‖r(p)‖22 ≥ Re,

‖u(p)‖22 = 1,(p = 1, . . . , 4).

Next: Closer Examination of the GPOPS− II Code

Copyright © 2006–2014 Anil V. Rao Page 57