A General-Purpose MATLAB Software for
Solving Multiple-Phase Optimal Control Problems
Version 2.3
Michael A. Patterson, Ph.D.
Anil V. Rao, Ph.D.
December 2016
Copyright © 2013–2016 Michael A. Patterson and Anil V. Rao. All Rights Reserved.
2
Preface
This document serves a user’s guide for Version 2.0 of the MATLAB optimal control software GPOPS − II:
a general-pupose software for solving optimal control problems using variable-order adaptive orthogonal
collocation methods together with sparse nonlinear programming. The class of proble ms that GPOPS −II
can solve is very broad and in clu de applications in engineering, economics, and medicine. GPOPS − II
uses some of the latest advancements in the area of orthogonal collocation methods along with the state-
of-the-art in nonlinear optimization. Specifically, GPOPS −II employs a variable-order adaptive Legendre-
Gauss-Radau quadrature collocation method. GPOPS − II has been designed to work with the nonlinear
programming (NLP) solvers SNOPT and IPOPT, and MATLAB mex files for IPOPT are included with the
software (users must obtain SNOPT on their own, but the complete interface for using SNOPT is included
with GPOPS − II. The software has been des igne d to be extremely fle xi bl e, allowing a user to formulate an
optimal control problem in a way that makes sense for the problem being solved. Few, if any, restrictions
have been placed on the manner in which a problem needs to be modeled. As stated, the software is
general-purpose, that is, it has not been developed for any specific type of problem. While the developers of
GPOPS − II make no guarantee as to the fitness of the software for any particular purpose, it is certainly
hoped that software is useful for a variety of applications.
The new version of GPOPS − II described in this user’s guide differs fr om the first release of May 2013
in the follows ways. First, some of the input syntax has been mo di fie d to be mor e elegant than it was
previously. Second, the software now includes a complete input checker that provides err or s and warnings
regarding user-defined inp u ts . Third, from an algorithmic standpoint the major change is the way in which
NLP solver derivatives can now be obtained. In addition to the original sparse finite-differencing method
(which is still included), the user now has the choice of generating de r ivative source code using the open-
source automatic d iffe r entiation software ADiGator
1
(written by Matt he w J. Weinstei n and available at
http://sourceforge.net/projects/adigator) or by providing user-supplied (analytic) derivatives. These
improvements have been made to incr e ase both computational efficienc y and reliability of the software.
Acknowledgments
The authors of GPOPS − II have many people to thank along the way for their contributions to the research
that has made GPOPS − II possible. While it is impossible to acknowledge everyone who has contributed to
the development of th e under l yi ng methods that are implemented in GPOPS − II, here is a partial (hopefully
complete) list of people and their contributions:
• Dr. Di vya Garg: mathematical theory showing the equivalence between the differ ential and integral
forms of the methods along with the development of the transformed adjoint systems as described in
Refs.
2, 3, and 4.
• Dr. Christopher L. Darby: hp adaptive mesh refinement methods as described in Refs.
5 an d 6.
• Dr. Camila Francolin: costate estimation as described in Ref.
7.
• Matthew Weinste in : development of the open-source automatic differentiation package ADiGa to r as
found at
http://www.sourceforge.net/projects/adigator and described in Ref. 1.
• Fengjin Liu: development of the hp adaptive mesh refinement methods as described in Refs.
8 and 9.
• Professor William W. Hager: for the honor of being able to collaborate over the past several years with
one of the world’s most distinguished applie d mathematicians on our optimal control research and for
his contributions to all of the aforementioned hp adaptive mesh refi ne ment methods as describ ed in
Refs.
5, 6, 8–10.
Disclaimer
The contents of this document and th e corresponding software GPOPS − II are provided “as is” without any
merchantability or fitness for any particular application. In particular,
3
• You get no warranties of any kind;
• If the software damages you in any way, you may only recover direct damages up to the amount you
paid for it (that is, you get zero if you did not pay anything for the software);
• You may not recover any other damages, including those called ”consequential damages.” (The state
or country where you live may not allow you to limit your liability in this way, so this may not apply
to you).
Neither authors nor their employers (past, pre s ent, or future) assume any respons ib il ity whatsoever from
any harm resulting from the software.
GPOPS − II is provided “a s is ” w it ho ut w ar ranty of any kind, expressed or implies, including but not
limited to the war ranties of merchantability, fitnes s for a particular purpose, and non-infringement. I n no
event shall the authors or copyright holders be l iabl e for a ny claim, damages, or other liability, whether in
an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use
or dealings in the software.
Licensing Agreement
By downloading, using, modifying, or distribu ti ng GPOPS2, you agree to the terms of the license agreement as
stated on the website
http://www.gpops2.com/License/License.html. Please read the license terms
and conditions carefully before proceeding to download, install , or use GPOPS − II
Installation Instructions
GPOPS − II can be installed using any version of MATLAB after R2011a on any computer that runs Mi-
crosoft Windows 32-bit and 64-bit, Linux 64-bit, or Mac OS-X 64-bit. The installation ins t r uc ti ons are as
follows:
(1) Unzip t he zip archive from the download link that was supplied when you registered or purchased
GPOPS − II. Once the file is unzipped, place the lic en s e file you received in the directory $GPOPS2/lic en se
(where $GPOPS2 is the root directory where GPOPS − II was unzipped).
(2) Start MATLAB, change to the directory $GPOPS2, and execute the file “gpopsMatlabPathSetup.m”
from the MATLAB command prompt. The execution of “gpopsM atlabPathSetup.m” will attemp t to
write to the master path definition file “pathdef.m”. If “pathdef.m” cannot be written to (for example,
if you are not the administrator of the computer or if you otherwise do not have permission to write
to “pathdef.m”), then the GPOPS − II directories will not be saved when MATLAB is closed. If the
MATLAB path cannot be saved and you want to include the GPOPS − II directories each time MATLAB
starts, you will need to add the GPOPS − II paths using the “addpath” command in a “startup.m” file
and place the “startup.m” file in your MATLAB home working directory.
For completeness, if you do not have permission to write to the “pathdef.m” file, then the following addpath
commands should be included in the “startup.m” file so that you have a functioning GPOPS − II installation
each time MATLAB is started:
addpath(
'$GPOPS2/license');
addpath(
'$GPOPS2/nlp/ipopt');
addpath(
'$GPOPS2/gpopsUtilities');
addpath(
'$GPOPS2/lib/gpopsCommon');
addpath(
'$GPOPS2/lib/gpopsMeshRefinement');
addpath(
'$GPOPS2/lib/gpopsAutomaticScaling');
addpath(
'$GPOPS2/lib/gpopsADiGator');
addpath(
'$GPOPS2/lib/gpopsFiniteDifference');
addpath(
'$GPOPS2/lib/gpopsRPMDifferentiation');
addpath(
'$GPOPS2/lib/gpopsRPMDifferentiation/gpopsIpoptRPMD');
addpath(
'$GPOPS2/lib/gpopsRPMDifferentiation/gpopsSnoptRPMD');
4
addpath('$GPOPS2/lib/gpopsRPMIntegration');
addpath(
'$GPOPS2/lib/gpopsRPMIntegration/gpopsIpoptRPMI');
addpath(
'$GPOPS2/lib/gpopsRPMIntegration/gpopsSnoptRPMI');
Finally, it is noted that the following in for mation is displayed upon execution of “gpops2License”:
GPOPS-II License Information
License Owner : Academic Institution, Not-
for-Profit Corporation, or Commercial Institution
License Type : Academic, Not-
for-Profit, or Commercial
License Class : Single-User, Department -Wide, or Institution-Wide
License Expiration Date [year, month, day] : [Expiration-Year, Expiration-Month, Expiration-Day]
License Valid For The Following MATLAB license(s) : List-of-Valid-MATLAB-License-Numbers
The above installation instructions do not include the installation of the open-source automatic differentiation
software ADiGator.
1
If you would like to use ADiGator with GPOPS − II, please visit the ADiGator website
http://sourceforge.net/projects/adigator and follow the setup instructions included with ADi Gat or .
If you have any questions about installing GPOPS − II, please send an e-mail to support@gpops2.com.
CONTENTS 5
Contents
1 Introduction to the General-Purpose Software GPOPS − II 6
1.1 Radau Orthogonal Collo cati on Me th od Employed by GPOPS −II . . . . . . . . . . . . . . . . 6
1.2 Organization of GPOPS − II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Color Highlighting Throughout Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Constructing an Optimal Control Problem Using GPOPS − II 7
2.1 Syntax for Input Structure
setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Syntax for Structure
setup.functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Syntax for bounds Struct ur e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Syntax of Endpoint Function
setup.functions.endpoint . . . . . . . . . . . . . . . . . . . . . 12
2.5 Syntax for Continuous Function setup.functions.continuous . . . . . . . . . . . . . . . . . 12
2.6 Specifying an Initial Guess of The Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.7 Use of ADiGator
1
to Generate NLP Solver Deri vatives . . . . . . . . . . . . . . . . . . . . . . 14
2.8 Scaling the Optimal Control Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3 Output from an Execution of GPOPS − II 15
4 Useful Information for Debugging a GPOPS − II Problem 16
5 GPOPS − II Examples 16
5.1 Hyper-Sensitive Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2 Low-Thrust Orbit Tr ans fe r Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.3 Initial Guess Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6 Results 22
6.1 Multiple-Stage Launch Vehicle Ascent Problem . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.2 Tumor-Antiangiogenesis Optimal Control Problem . . . . . . . . . . . . . . . . . . . . . . . . 43
6.3 Reusable Launch Vehicle Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.4 Minimum Time-to-Climb of a Supersonic Aircraft . . . . . . . . . . . . . . . . . . . . . . . . . 52
6.5 Two-Strain Tuberculosis Optimal Control Problem . . . . . . . . . . . . . . . . . . . . . . . . 64
7 Concluding Remarks 70