Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Modeling and Solving Optimization Problems

Mary Fenelon

1
Outline

▪ Introduction

▪ Nonlinear problem

▪ Hydroelectric dam operation

▪ Location planning

▪ Takeaways

2
Introduction

3
What can you do with optimization?

BuildingIQ: Reduce energy Realtek: Optimize designs PTTEP: Plan gas field production
consumption

STIWA: Optimize trajectories Clearpath Robotics: Minimize Tessella: Minimize propellant


travel distance consumption 4
Formulating an Optimization Problem: Transportation Problem
Objective
What is my goal?

Constraints
Variables
What restricts my choices?
What are my choices?

Data

5
Formulating an Optimization Problem: Transportation Problem
Objective
What is my goal?
minimize cost of transportation

Constraints
Variables
What restricts my choices?
What are my choices?
Supply and demand at sites
Amount shipped from/to sites

Data
supply, demand, cost

6
Formulating an Optimization Problem: Transportation Problem
Objective
What is my goal?
minimize cost of transportation
𝑚 𝑛

෍ ෍ 𝑐𝑖𝑗 𝑥𝑖𝑗 Constraints


Variables 𝑖=1 𝑗=1
What restricts my choices?
What are my choices?
Supply and demand at sites
Amount shipped from/to sites 𝑚 𝑛

𝑥𝑖𝑗 ෍ 𝑥𝑖𝑗 = 𝑠𝑖 ෍ 𝑥𝑖𝑗 = 𝑑𝑗


𝑗=1 𝑖=1

𝑥𝑖𝑗 ≥ 0

Data
supply, demand, cost
𝑠𝑖 𝑑𝑗 𝑐𝑖𝑗 𝑚 𝑛
7
Specify the problem using expressions with Problem-Based
Optimization

8
Problem-Based Optimization makes optimization easier to use

▪ Familiar MATLAB syntax for expressions


▪ No need to write functions and build coefficient matrices
▪ fcn2optimexpr enables use of non-supported operators and functions

▪ Functions to help debugging show, evaluate, infeasibility


▪ Automatic solver selection
▪ Automatic differentiation

9
Solve many types of optimization problems with MATLAB Optimization Toolbox
Global Optimization Toolbox

Constraint Type Objective Type


Linear Quadratic Least Squares Smooth Nonsmooth Multiobjective
nonlinear
None quadprog lsqcurvefit fminsearch fminsearch fgoalattain
lsqnonlin fminunc ga fminimax
paretosearch
gamultiobj

Bound quadprog lsqcurvefit fmincon fminbnd ga fgoalattain


lsqnonlin surrogatopt fminimax
lsqnonneg patternsearch paretosearch
lsqlin particleswarm gamultiobj
simulannealbnd

Linear linprog quadprog lsqlin fmincon ga fgoalattain


patternsearch fminimax
surrogatept paretosearch
gamultiobj

Second-Order Cone coneprog coneprog

General smooth fmincon fmincon fmincon fmincon ga fgoalattain


patternsearch fminimax
surrogateopt paretosearch
gamultiobj

General nonsmooth ga ga ga ga ga paretosearch


patternsearch patternsearch patternsearch patternsearch patternsearch gamultiobj
surrogateopt

Discrete intlinprog ga
surrogateopt

10
Exercises

11
Instructions to get started with the exercises
Clickable links are in the Chat and in the handout

1. Access MATLAB Online using the link. Sign in with your MathWorks account

2. Access the shared folder on MATLAB Drive using the link


a. Create your own unshared copy of the folder and its contents and add it to your files, by
clicking Add to my Files and select Copy Folder
b. Click Files on the left side of the page to access the folder in your MATLAB Drive.

3. Return to the MATLAB Online window and open the Live Script
a. Double-click on Expo2021_Optimization_Workshop folder in the Current Folder pane
b. Double-click on 1_Simple_Nonlinear_Problem folder
c. Double-click on Work_NonlinearProblem.mlx to open

12
Exercise 1 - Nonlinear Problem

Purpose:
▪ Ensure MATLAB Online is running properly
▪ Create and solve a nonlinear optimization problem
▪ Include a black-box MATLAB function

To Do:
▪ Open the 1-Simple_Nonlinear_Problem folder
▪ Open Work_NonlinearProblem.mlx
– Accept the prompt to open MATLAB Online
▪ Follow along with instructor

13
Nonlinear Problem Review

Data

Problem optimproblem

Variables optimvar
Workflow
ObjectiveSense
Objective
Objective

Constraints Constraints

Solve solve

14
Exercise 2 - Hydroelectric Dam Operation

Purpose:
▪ Solve a planning problem over multiple time periods
▪ Use vectors of variables and constraints

To Do:
▪ Open the 2-HydroelectricDamOperation folder
▪ Open Work_HydroelectricDamOperation.mlx
▪ Follow along with instructor

15
Hydroelectric Dam Operation Review

▪ Constructed the model so that any size data can be used


▪ Created vectors of variables and constraints
▪ Created intermediate optimization expressions as a convenience
▪ Solved a quadratic program

16
Exercise 3 - Disaster Response Facility Location

Purpose:
▪ Solve a facility location problem
▪ Use arrays of variables and constraints

To Do:
▪ Open the 3-LocationPlanning folder
▪ Open Work_DisasterResponseFacilityLocation.mlx
▪ Work on your own

17
Facility Location Review

▪ Indexed variables by strings


▪ Created 2-D arrays of variables
▪ Solved an integer linear program

18
Takeaways

19
Problem-Based Optimization makes optimization easier to use

▪ Familiar MATLAB syntax for expressions


▪ No need to write functions and build coefficient matrices
▪ fcn2optimexpr enables use of non-supported functions

▪ Functions to help debugging show, evaluate, infeasibility


▪ Automatic solver selection
▪ Automatic differentiation

▪ eqnproblem for nonlinear systems of equations

20
Use these resources to learn about optimization with MATLAB
Getting Started How-To Videos
Optimization Overview Video Documentation Master Class: Solving Mathematical Modeling with
Toolbox Optimization Problems Optimization

Design Optimization with Linear and Mixed-Integer


Global Overview Video Documentation MATLAB Linear Programming
Optimization
Toolbox Optimize Live Task Advanced Statistics and
Optimization
Cheat Sheets
Surrogate Optimization Multiobjective Optimization
Training: Optimization Techniques in MATLAB
Global Search MultiStart Optimization

Basics Examples
Nonlinear Programming Flight Path Optimization Traveling Salesman Problem

Linear Programming
Production Planning Portfolio Optimization
Integer Programming
Minimizing Electrostatic Energy Optimal Dispatch of Power
Quadratic Programming Generators
Genetic Algorithm
Antenna Design Circuit Component Selection
Least Squares and Nonlinear Systems of Equations
21
Thank you

© 2021 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See mathworks.com/trademarks
for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.

22

You might also like