Share E-Book

MATLAB Optimization Toolbox™ Users Guide (The MathWorks, Inc.) (z-library.sk, 1lib.sk, z-lib.sk)

Author

,

Rating No ratings yet

Log in to rate

Matlab
Language English

No Description

Format PDF
Size 7.4 MB
5
Views
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
Optimization Toolbox™ User's Guide R2020a
Page 2
How to Contact MathWorks Latest news: www.mathworks.com Sales and services: www.mathworks.com/sales_and_services User community: www.mathworks.com/matlabcentral Technical support: www.mathworks.com/support/contact_us Phone: 508-647-7000 The MathWorks, Inc. 1 Apple Hill Drive Natick, MA 01760-2098 Optimization Toolbox™ User's Guide © COPYRIGHT 1990–2020 by The MathWorks, Inc. The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathWorks, Inc. FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Documentation, unused, to The MathWorks, Inc. Trademarks MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders. Patents MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for more information.
Page 3
Revision History November 1990 First printing December 1996 Second printing For MATLAB® 5 January 1999 Third printing For Version 2 (Release 11) September 2000 Fourth printing For Version 2.1 (Release 12) June 2001 Online only Revised for Version 2.1.1 (Release 12.1) September 2003 Online only Revised for Version 2.3 (Release 13SP1) June 2004 Fifth printing Revised for Version 3.0 (Release 14) October 2004 Online only Revised for Version 3.0.1 (Release 14SP1) March 2005 Online only Revised for Version 3.0.2 (Release 14SP2) September 2005 Online only Revised for Version 3.0.3 (Release 14SP3) March 2006 Online only Revised for Version 3.0.4 (Release 2006a) September 2006 Sixth printing Revised for Version 3.1 (Release 2006b) March 2007 Seventh printing Revised for Version 3.1.1 (Release 2007a) September 2007 Eighth printing Revised for Version 3.1.2 (Release 2007b) March 2008 Online only Revised for Version 4.0 (Release 2008a) October 2008 Online only Revised for Version 4.1 (Release 2008b) March 2009 Online only Revised for Version 4.2 (Release 2009a) September 2009 Online only Revised for Version 4.3 (Release 2009b) March 2010 Online only Revised for Version 5.0 (Release 2010a) September 2010 Online only Revised for Version 5.1 (Release 2010b) April 2011 Online only Revised for Version 6.0 (Release 2011a) September 2011 Online only Revised for Version 6.1 (Release 2011b) March 2012 Online only Revised for Version 6.2 (Release 2012a) September 2012 Online only Revised for Version 6.2.1 (Release 2012b) March 2013 Online only Revised for Version 6.3 (Release 2013a) September 2013 Online only Revised for Version 6.4 (Release 2013b) March 2014 Online only Revised for Version 7.0 (Release 2014a) October 2014 Online only Revised for Version 7.1 (Release 2014b) March 2015 Online only Revised for Version 7.2 (Release 2015a) September 2015 Online only Revised for Version 7.3 (Release 2015b) March 2016 Online only Revised for Version 7.4 (Release 2016a) September 2016 Online only Revised for Version 7.5 (Release 2016b) March 2017 Online only Revised for Version 7.6 (Release 2017a) September 2017 Online only Revised for Version 8.0 (Release 2017b) March 2018 Online only Revised for Version 8.1 (Release 2018a) September 2018 Online only Revised for Version 8.2 (Release 2018b) March 2019 Online only Revised for Version 8.3 (Release 2019a) September 2019 Online only Revised for Version 8.4 (Release 2019b) March 2020 Online only Revised for Version 8.5 (Release 2020a)
Page 4
(This page has no text content)
Page 5
Acknowledgments Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx Getting Started 1 Optimization Toolbox Product Description . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 First Choose Problem-Based or Solver-Based Approach . . . . . . . . . . . . . . 1-3 Solve a Constrained Nonlinear Problem, Problem-Based . . . . . . . . . . . . . 1-5 Solve a Constrained Nonlinear Problem, Solver-Based . . . . . . . . . . . . . . 1-11 Typical Optimization Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11 Problem Formulation: Rosenbrock's Function . . . . . . . . . . . . . . . . . . . . . 1-11 Define the Problem in Toolbox Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12 Run the Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Interpret the Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16 Set Up a Linear Program, Solver-Based . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18 Convert a Problem to Solver Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18 Model Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18 Solution Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24 Set Up a Linear Program, Problem-Based . . . . . . . . . . . . . . . . . . . . . . . . . 1-25 Convert a Problem to Solver Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-25 Model Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-25 First Solution Method: Create Optimization Variable for Each Problem Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26 Create Problem and Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-27 Create and Include Linear Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . 1-27 Solve Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-27 Examine Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-28 Second Solution Method: Create One Optimization Variable and Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29 Set Variable Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29 Create Problem, Linear Constraints, and Solution . . . . . . . . . . . . . . . . . . 1-29 Examine Indexed Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30 v Contents
Page 6
Setting Up an Optimization 2 Optimization Theory Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Optimization Toolbox Solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 Optimization Decision Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 Choosing the Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 fmincon Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 fsolve Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 fminunc Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 Least Squares Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 Linear Programming Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Quadratic Programming Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Large-Scale vs. Medium-Scale Algorithms . . . . . . . . . . . . . . . . . . . . . . . . 2-10 Potential Inaccuracy with Interior-Point Algorithms . . . . . . . . . . . . . . . . 2-10 Problems Handled by Optimization Toolbox Functions . . . . . . . . . . . . . . 2-12 Complex Numbers in Optimization Toolbox Solvers . . . . . . . . . . . . . . . . . 2-14 Types of Objective Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 Writing Scalar Objective Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17 Function Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17 Anonymous Function Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18 Including Gradients and Hessians . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 Writing Vector and Matrix Objective Functions . . . . . . . . . . . . . . . . . . . . 2-26 What Are Vector or Matrix Objective Functions? . . . . . . . . . . . . . . . . . . . 2-26 Jacobians of Vector Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26 Jacobians of Matrix Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27 Jacobians with Matrix-Valued Independent Variables . . . . . . . . . . . . . . . . 2-27 Writing Objective Functions for Linear or Quadratic Problems . . . . . . . 2-29 Maximizing an Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30 Matrix Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 Types of Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32 Iterations Can Violate Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 Intermediate Iterations can Violate Constraints . . . . . . . . . . . . . . . . . . . 2-33 Algorithms That Satisfy Bound Constraints . . . . . . . . . . . . . . . . . . . . . . . 2-33 Solvers and Algorithms That Can Violate Bound Constraints . . . . . . . . . . 2-33 Bound Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34 Linear Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35 What Are Linear Constraints? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35 Linear Inequality Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35 vi Contents
Page 7
Linear Equality Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36 Nonlinear Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37 Including Gradients in Constraint Functions . . . . . . . . . . . . . . . . . . . . . . 2-38 Anonymous Nonlinear Constraint Functions . . . . . . . . . . . . . . . . . . . . . . 2-38 Or Instead of And Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41 How to Use All Types of Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45 Objective and Nonlinear Constraints in the Same Function . . . . . . . . . . 2-48 Objective and Constraints Having a Common Function in Serial or Parallel, Problem-Based . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-52 Passing Extra Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-57 Extra Parameters, Fixed Variables, or Data . . . . . . . . . . . . . . . . . . . . . . . 2-57 Anonymous Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-57 Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-58 Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-59 What Are Options? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-60 Options in Common Use: Tuning and Troubleshooting . . . . . . . . . . . . . . 2-61 Set and Change Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-62 Choose Between optimoptions and optimset . . . . . . . . . . . . . . . . . . . . . . 2-63 View Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-66 Tolerances and Stopping Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-68 Tolerance Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-71 Checking Validity of Gradients or Jacobians . . . . . . . . . . . . . . . . . . . . . . . 2-74 Check Gradient or Jacobian in Objective Function . . . . . . . . . . . . . . . . . . 2-74 How to Check Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-74 Example: Checking Derivatives of Objective and Constraint Functions . . 2-75 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-80 Examining Results 3 Current Point and Function Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Exit Flags and Exit Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Exit Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Exit Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 Enhanced Exit Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 vii
Page 8
Exit Message Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7 Iterations and Function Counts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 First-Order Optimality Measure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11 What Is First-Order Optimality Measure? . . . . . . . . . . . . . . . . . . . . . . . . 3-11 Stopping Rules Related to First-Order Optimality . . . . . . . . . . . . . . . . . . 3-11 Unconstrained Optimality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11 Constrained Optimality Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12 Constrained Optimality in Solver Form . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13 Iterative Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14 Common Headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14 Function-Specific Headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15 Output Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21 Lagrange Multiplier Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22 Hessian Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24 Returned Hessian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24 fminunc Hessian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24 fmincon Hessian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25 Plot Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27 Plot an Optimization During Execution . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27 Using a Plot Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27 Output Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32 What Is an Output Function? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32 Example: Using Output Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32 Steps to Take After Running a Solver 4 Overview of Next Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 When the Solver Fails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 Too Many Iterations or Function Evaluations . . . . . . . . . . . . . . . . . . . . . . 4-3 Converged to an Infeasible Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6 Problem Unbounded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7 fsolve Could Not Solve Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8 Solver Takes Too Long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Enable Iterative Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Use Appropriate Tolerances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Use a Plot Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Use 'lbfgs' HessianApproximation Option . . . . . . . . . . . . . . . . . . . . . . . . 4-10 Enable CheckGradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 Use Inf Instead of a Large, Arbitrary Bound . . . . . . . . . . . . . . . . . . . . . . 4-10 Use an Output Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 viii Contents
Page 9
Use a Sparse Solver or a Multiply Function . . . . . . . . . . . . . . . . . . . . . . 4-10 Use Parallel Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11 When the Solver Might Have Succeeded . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12 Final Point Equals Initial Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12 Local Minimum Possible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12 When the Solver Succeeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18 What Can Be Wrong If The Solver Succeeds? . . . . . . . . . . . . . . . . . . . . . 4-18 1. Change the Initial Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18 2. Check Nearby Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19 3. Check your Objective and Constraint Functions . . . . . . . . . . . . . . . . . 4-20 Local vs. Global Optima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22 Why the Solver Does Not Find the Smallest Minimum . . . . . . . . . . . . . . . 4-22 Searching for a Smaller Minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22 Basins of Attraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23 Optimizing a Simulation or Ordinary Differential Equation . . . . . . . . . . 4-26 What Is Optimizing a Simulation or ODE? . . . . . . . . . . . . . . . . . . . . . . . . 4-26 Potential Problems and Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-30 Optimization App 5 Optimization App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Optimization App Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Specifying Certain Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6 Importing and Exporting Your Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8 Optimization App Alternatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 Optimize Without Using the App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 Set Options Using Live Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 Set Options: Command Line or Standard Scripts . . . . . . . . . . . . . . . . . . . 5-14 Choose Plot Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15 Pass Solver Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16 Nonlinear algorithms and examples 6 Unconstrained Nonlinear Optimization Algorithms . . . . . . . . . . . . . . . . . . 6-2 Unconstrained Optimization Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 fminunc trust-region Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 fminunc quasi-newton Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 fminsearch Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9 Unconstrained Minimization Using fminunc . . . . . . . . . . . . . . . . . . . . . . 6-11 ix
Page 10
Minimization with Gradient and Hessian . . . . . . . . . . . . . . . . . . . . . . . . . 6-13 Minimization with Gradient and Hessian Sparsity Pattern . . . . . . . . . . . 6-16 Constrained Nonlinear Optimization Algorithms . . . . . . . . . . . . . . . . . . . 6-19 Constrained Optimization Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19 fmincon Trust Region Reflective Algorithm . . . . . . . . . . . . . . . . . . . . . . . 6-19 fmincon Active Set Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-22 fmincon SQP Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29 fmincon Interior Point Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-30 fminbnd Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-32 fseminf Problem Formulation and Algorithm . . . . . . . . . . . . . . . . . . . . . . 6-32 Tutorial for the Optimization Toolbox™ . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-36 Banana Function Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-49 Minimizing an Expensive Optimization Problem Using Parallel Computing Toolbox™ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-56 Nonlinear Inequality Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-61 Nonlinear Constraints with Gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-63 fmincon Interior-Point Algorithm with Analytic Hessian . . . . . . . . . . . . . 6-66 Linear or Quadratic Objective with Quadratic Constraints . . . . . . . . . . . 6-71 Nonlinear Equality and Inequality Constraints . . . . . . . . . . . . . . . . . . . . 6-75 Optimization App with the fmincon Solver . . . . . . . . . . . . . . . . . . . . . . . . 6-77 Step 1: Write a file objecfun.m for the objective function. . . . . . . . . . . . . 6-77 Step 2: Write a file nonlconstr.m for the nonlinear constraints. . . . . . . . . 6-77 Step 3: Set up and run the problem with the Optimization app. . . . . . . . . 6-77 Minimization with Bound Constraints and Banded Preconditioner . . . . 6-81 Minimization with Linear Equality Constraints, Trust-Region Reflective Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-87 Minimization with Dense Structured Hessian, Linear Equalities . . . . . . 6-90 Hessian Multiply Function for Lower Memory . . . . . . . . . . . . . . . . . . . . . 6-90 Step 1: Write a file brownvv.m that computes the objective function, the gradient, and the sparse part of the Hessian. . . . . . . . . . . . . . . . . . . . 6-91 Step 2: Write a function to compute Hessian-matrix products for H given a matrix Y. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-91 Step 3: Call a nonlinear minimization routine with a starting point and linear equality constraints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-91 Preconditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-93 Symbolic Math Toolbox™ Calculates Gradients and Hessians . . . . . . . . . 6-94 Using Symbolic Mathematics with Optimization Toolbox™ Solvers . . . 6-105 x Contents
Page 11
Code Generation in fmincon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-114 What Is Code Generation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-114 Code Generation Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-114 Generated Code Not Multithreaded . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-115 Code Generation for Optimization Basics . . . . . . . . . . . . . . . . . . . . . . . . 6-116 Generate Code for fmincon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-116 Modify Example for Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-116 Static Memory Allocation for fmincon Code Generation . . . . . . . . . . . . 6-120 Optimization Code Generation for Real-Time Applications . . . . . . . . . . 6-122 Time Limits on Generated Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-122 Match the Target Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-122 Set Coder Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-122 Benchmark the Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-123 Set Initial Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-123 Set Options Appropriately . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-123 Global Minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-124 One-Dimensional Semi-Infinite Constraints . . . . . . . . . . . . . . . . . . . . . . 6-125 Two-Dimensional Semi-Infinite Constraint . . . . . . . . . . . . . . . . . . . . . . . 6-128 Analyzing the Effect of Uncertainty Using Semi-Infinite Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-131 Nonlinear Problem-Based 7 Rational Objective Function, Problem-Based . . . . . . . . . . . . . . . . . . . . . . . 7-2 Solve Constrained Nonlinear Optimization, Problem-Based . . . . . . . . . . . 7-4 Convert Nonlinear Function to Optimization Expression . . . . . . . . . . . . . . 7-8 Constrained Electrostatic Nonlinear Optimization, Problem-Based . . . . 7-12 Problem-Based Nonlinear Minimization with Linear Constraints . . . . . . 7-17 Include Derivatives in Problem-Based Workflow . . . . . . . . . . . . . . . . . . . 7-20 Why Include Derivatives? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20 Create Optimization Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20 Convert Problem to Solver-Based Form . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21 Calculate Derivatives and Keep Track of Variables . . . . . . . . . . . . . . . . . 7-21 Edit the Objective and Constraint Files . . . . . . . . . . . . . . . . . . . . . . . . . . 7-22 Run Problem Using Two Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-22 Output Function for Problem-Based Optimization . . . . . . . . . . . . . . . . . . 7-25 Solve Nonlinear Feasibility Problem, Problem-Based . . . . . . . . . . . . . . . 7-30 xi
Page 12
Multiobjective Algorithms and Examples 8 Multiobjective Optimization Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 Multiobjective Optimization Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3 Compare fminimax and fminunc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6 Using fminimax with a Simulink® Model . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8 Signal Processing Using fgoalattain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12 Step 1: Write a file filtmin.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12 Step 2: Invoke optimization routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12 Generate and Plot a Pareto Front . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15 Multi-Objective Goal Attainment Optimization . . . . . . . . . . . . . . . . . . . . . 8-18 Minimax Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24 Linear Programming and Mixed-Integer Linear Programming 9 Linear Programming Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2 Linear Programming Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2 Interior-Point linprog Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2 Interior-Point-Legacy Linear Programming . . . . . . . . . . . . . . . . . . . . . . . . 9-6 Dual-Simplex Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9 Typical Linear Programming Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13 Maximize Long-Term Investments Using Linear Programming: Solver- Based . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15 Mixed-Integer Linear Programming Algorithms . . . . . . . . . . . . . . . . . . . 9-26 Mixed-Integer Linear Programming Definition . . . . . . . . . . . . . . . . . . . . 9-26 intlinprog Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-26 Tuning Integer Linear Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-35 Change Options to Improve the Solution Process . . . . . . . . . . . . . . . . . . 9-35 Some “Integer” Solutions Are Not Integers . . . . . . . . . . . . . . . . . . . . . . . 9-36 Large Components Not Integer Valued . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36 Large Coefficients Disallowed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36 Mixed-Integer Linear Programming Basics: Solver-Based . . . . . . . . . . . 9-37 Factory, Warehouse, Sales Allocation Model: Solver-Based . . . . . . . . . . . 9-40 Traveling Salesman Problem: Solver-Based . . . . . . . . . . . . . . . . . . . . . . . 9-49 xii Contents
Page 13
Optimal Dispatch of Power Generators: Solver-Based . . . . . . . . . . . . . . . 9-55 Mixed-Integer Quadratic Programming Portfolio Optimization: Solver- Based . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-65 Solve Sudoku Puzzles Via Integer Programming: Solver-Based . . . . . . . 9-72 Office Assignments by Binary Integer Programming: Solver-Based . . . . 9-79 Cutting Stock Problem: Solver-Based . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-86 Factory, Warehouse, Sales Allocation Model: Problem-Based . . . . . . . . . 9-90 Traveling Salesman Problem: Problem-Based . . . . . . . . . . . . . . . . . . . . . 9-98 Optimal Dispatch of Power Generators: Problem-Based . . . . . . . . . . . . 9-104 Office Assignments by Binary Integer Programming: Problem-Based 9-113 Mixed-Integer Quadratic Programming Portfolio Optimization: Problem- Based . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-118 Cutting Stock Problem: Problem-Based . . . . . . . . . . . . . . . . . . . . . . . . . 9-125 Solve Sudoku Puzzles Via Integer Programming: Problem-Based . . . . 9-129 Minimize Makespan in Parallel Processing . . . . . . . . . . . . . . . . . . . . . . 9-135 Investigate Linear Infeasibilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-139 Problem-Based Optimization 10 Problem-Based Optimization Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2 Problem-Based Workflow for Solving Equations . . . . . . . . . . . . . . . . . . . . 10-4 Optimization Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-6 What Are Optimization Expressions? . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-6 Expressions for Objective Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-6 Expressions for Constraints and Equations . . . . . . . . . . . . . . . . . . . . . . . 10-7 Optimization Variables Have Handle Behavior . . . . . . . . . . . . . . . . . . . . 10-9 Pass Extra Parameters in Problem-Based Approach . . . . . . . . . . . . . . . 10-11 Review or Modify Optimization Problems . . . . . . . . . . . . . . . . . . . . . . . . 10-14 Review Problem Using show or write . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14 Change Default Solver or Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14 Correct a Misspecified Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-16 Duplicate Variable Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-19 xiii
Page 14
Named Index for Optimization Variables . . . . . . . . . . . . . . . . . . . . . . . . . 10-20 Create Named Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20 Use Named Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-21 View Solution with Index Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-22 Examine Optimization Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25 Obtain Numeric Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25 Examine Solution Quality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26 Infeasible Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26 Solution Takes Too Long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-27 Create Efficient Optimization Problems . . . . . . . . . . . . . . . . . . . . . . . . . 10-28 Separate Optimization Model from Data . . . . . . . . . . . . . . . . . . . . . . . . . 10-30 Problem-Based Optimization Algorithms . . . . . . . . . . . . . . . . . . . . . . . . 10-32 Variables with Duplicate Names Disallowed . . . . . . . . . . . . . . . . . . . . . . 10-34 Expression Contains Inf or NaN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-35 Supported Operations on Optimization Variables and Expressions . . . 10-36 Notation for Supported Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-36 Operations Returning Optimization Expressions . . . . . . . . . . . . . . . . . . 10-36 Operations Returning Optimization Variables . . . . . . . . . . . . . . . . . . . . 10-38 Operations on Optimization Expressions . . . . . . . . . . . . . . . . . . . . . . . . 10-38 Operations Returning Constraint Expressions . . . . . . . . . . . . . . . . . . . . 10-38 Some Undocumented Operations Work on Optimization Variables and Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-38 Unsupported Functions and Operations Require fcn2optimexpr . . . . . . 10-38 Mixed-Integer Linear Programming Basics: Problem-Based . . . . . . . . 10-40 Create Initial Point for Optimization with Named Index Variables . . . . 10-43 Quadratic Programming 11 Quadratic Programming Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2 Quadratic Programming Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2 interior-point-convex quadprog Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 11-2 trust-region-reflective quadprog Algorithm . . . . . . . . . . . . . . . . . . . . . . . 11-7 active-set quadprog Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11 Quadratic Minimization with Bound Constraints . . . . . . . . . . . . . . . . . . 11-15 Step 1: Load the Hessian and define f, lb, and ub. . . . . . . . . . . . . . . . . . 11-15 Step 2: Call a quadratic minimization routine with a starting point xstart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-15 Quadratic Minimization with Dense, Structured Hessian . . . . . . . . . . . 11-17 Take advantage of a structured Hessian . . . . . . . . . . . . . . . . . . . . . . . . 11-17 xiv Contents
Page 15
Step 1: Decide what part of H to pass to quadprog as the first argument. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17 Step 2: Write a function to compute Hessian-matrix products for H. . . . 11-17 Step 3: Call a quadratic minimization routine with a starting point. . . . 11-18 Preconditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-19 Large Sparse Quadratic Program with Interior Point Algorithm . . . . . 11-21 Bound-Constrained Quadratic Programming, Solver-Based . . . . . . . . . 11-24 Quadratic Programming for Portfolio Optimization Problems, Solver- Based . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-28 Quadratic Programming with Bound Constraints: Problem-Based . . . . 11-34 Large Sparse Quadratic Program, Problem-Based . . . . . . . . . . . . . . . . . 11-37 Bound-Constrained Quadratic Programming, Problem-Based . . . . . . . 11-40 Quadratic Programming for Portfolio Optimization, Problem-Based . . 11-44 Code Generation for quadprog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-51 What Is Code Generation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-51 Code Generation Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-51 Generated Code Not Multithreaded . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-52 Generate Code for quadprog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-53 First Steps in quadprog Code Generation . . . . . . . . . . . . . . . . . . . . . . . 11-53 Modify Example for Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-54 Quadratic Programming with Many Linear Constraints . . . . . . . . . . . . 11-57 Least Squares 12 Least-Squares (Model Fitting) Algorithms . . . . . . . . . . . . . . . . . . . . . . . . 12-2 Least Squares Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2 Linear Least Squares: Interior-Point or Active-Set . . . . . . . . . . . . . . . . . . 12-2 Trust-Region-Reflective Least Squares . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3 Levenberg-Marquardt Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6 Nonlinear Data-Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-9 lsqnonlin with a Simulink® Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17 Nonlinear Least Squares Without and Including Jacobian . . . . . . . . . . 12-21 Nonnegative Linear Least Squares, Solver-Based . . . . . . . . . . . . . . . . . 12-24 Optimization App with the lsqlin Solver . . . . . . . . . . . . . . . . . . . . . . . . . 12-27 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-27 xv
Page 16
Setting Up the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-27 Jacobian Multiply Function with Linear Least Squares . . . . . . . . . . . . . 12-30 Large-Scale Constrained Linear Least-Squares, Solver-Based . . . . . . . 12-34 Shortest Distance to a Plane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-38 Nonnegative Linear Least Squares, Problem-Based . . . . . . . . . . . . . . . . 12-40 Large-Scale Constrained Linear Least-Squares, Problem-Based . . . . . 12-44 Nonlinear Curve Fitting with lsqcurvefit . . . . . . . . . . . . . . . . . . . . . . . . . 12-48 Fit a Model to Complex-Valued Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-50 Fit an Ordinary Differential Equation (ODE) . . . . . . . . . . . . . . . . . . . . . 12-54 Nonlinear Least-Squares, Problem-Based . . . . . . . . . . . . . . . . . . . . . . . . 12-62 Fit ODE, Problem-Based . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-77 Nonlinear Data-Fitting Using Several Problem-Based Approaches . . . 12-84 Write Objective Function for Problem-Based Least Squares . . . . . . . . . 12-92 Systems of Equations 13 Equation Solving Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2 Equation Solving Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2 Trust-Region Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2 Trust-Region-Dogleg Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4 Levenberg-Marquardt Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5 fzero Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6 \ Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6 Nonlinear Equations with Analytic Jacobian . . . . . . . . . . . . . . . . . . . . . . . 13-7 Step 1: Write a file bananaobj.m to compute the objective function values and the Jacobian. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-7 Step 2: Call the solve routine for the system of equations. . . . . . . . . . . . . 13-8 Nonlinear Equations with Finite-Difference Jacobian . . . . . . . . . . . . . . . 13-9 Nonlinear Equations with Jacobian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-11 Step 1: Write a file nlsf1.m that computes the objective function values and the Jacobian. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-11 Step 2: Call the solve routine for the system of equations. . . . . . . . . . . 13-11 xvi Contents
Page 17
Nonlinear Equations with Jacobian Sparsity Pattern . . . . . . . . . . . . . . . 13-13 Step 1: Write a file nlsf1a.m that computes the objective function values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-13 Step 2: Call the system of equations solve routine. . . . . . . . . . . . . . . . . 13-13 Nonlinear Systems with Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-15 Solve Equations with Inequality Constraints . . . . . . . . . . . . . . . . . . . . . 13-15 Use Different Start Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-15 Use Different Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-16 Use lsqnonlin with Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-16 Set Equations and Inequalities as fmincon Constraints . . . . . . . . . . . . . 13-17 Solve Nonlinear System of Equations, Problem-Based . . . . . . . . . . . . . 13-19 Solve Nonlinear System of Polynomials, Problem-Based . . . . . . . . . . . . 13-21 Follow Equation Solution as a Parameter Changes . . . . . . . . . . . . . . . . 13-23 Nonlinear System of Equations with Constraints, Problem-Based . . . . 13-30 Parallel Computing for Optimization 14 What Is Parallel Computing in Optimization Toolbox? . . . . . . . . . . . . . . . 14-2 Parallel Optimization Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2 Parallel Estimation of Gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2 Nested Parallel Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3 Using Parallel Computing in Optimization Toolbox . . . . . . . . . . . . . . . . . 14-5 Using Parallel Computing with Multicore Processors . . . . . . . . . . . . . . . 14-5 Using Parallel Computing with a Multiprocessor Network . . . . . . . . . . . . 14-5 Testing Parallel Computations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-6 Minimizing an Expensive Optimization Problem Using Parallel Computing Toolbox™ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-8 Improving Performance with Parallel Computing . . . . . . . . . . . . . . . . . 14-13 Factors That Affect Speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-13 Factors That Affect Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-13 Searching for Global Optima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-14 Argument and Options Reference 15 Function Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2 Function Output Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4 xvii
Page 18
Optimization Options Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-6 Optimization Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-6 Hidden Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-16 Current and Legacy Option Name Tables . . . . . . . . . . . . . . . . . . . . . . . . 15-21 Output Function Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-26 What Are Output Functions? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-26 Structure of the Output Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-26 Fields in optimValues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-27 States of the Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-31 Stop Flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-31 intlinprog Output Function and Plot Function Syntax . . . . . . . . . . . . . . 15-33 What Are Output Functions and Plot Functions? . . . . . . . . . . . . . . . . . . 15-33 Custom Function Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-33 optimValues Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-34 Functions 16 xviii Contents
Page 19
Acknowledgments xix
Page 20
Acknowledgments MathWorks® would like to acknowledge the following contributors to Optimization Toolbox algorithms. Thomas F. Coleman researched and contributed algorithms for constrained and unconstrained minimization, nonlinear least squares and curve fitting, constrained linear least squares, quadratic programming, and nonlinear equations. Dr. Coleman is Professor of Combinatorics and Optimization at the University of Waterloo. Yin Zhang researched and contributed the large-scale linear programming algorithm. Dr. Zhang is Professor of Computational and Applied Mathematics at Rice University. Acknowledgments xx
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List