133
Anwar Ali, D.Eng [email protected]

Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Anwar Ali, D.Eng

[email protected]

Page 2: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Overview The slides are meant for those who are interested to

learn linear programming application but have no time for proper graduate study

The emphasis is on practical model building and solving the models using solvers

The slides are free preview of a 3-day training “Practical Business Optimization Using Solvers” offered by the author

The author has 27 years semiconductor manufacturing experience, of which 18 years are in Industrial Engineering and Operations Research

A Primer on Optimization Using Solvers - Anwar Ali 2

Page 3: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Agenda Introduction to Analytics and Operations Research

Optimization Modeling with Textbook Examples

Formulating and Solving Mathematical Models

Optimization Applications in Industry

How to Get Started

A Primer on Optimization Using Solvers - Anwar Ali 3

Page 4: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Analytics Landscape

Descriptive

Prescriptive

Predictive

Degree of Complexity

Com

petitive A

dvanta

ge

Standard Reporting

Ad hoc reporting

Query/drill down

Alerts

Simulation

Forecasting

Predictive modeling

Optimization

What exactly is the problem?

What will happen next if ?

What if these trends continue?

What could happen…. ?

What actions are needed?

How many, how often, where?

What happened?

Stochastic Optimization

How can we achieve the best outcome?

How can we achieve the best outcome

including the effects of variability?

Source: IBM, Based on: Competing on Analytics,

Davenport and Harris, 2007 A Primer on Optimization Using Solvers - Anwar Ali 4

Page 5: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Analytics Descriptive analytics (what has occurred)

The simplest class of analytics, condense big data into smaller, more useful nuggets of information

e.g. counts, likes, posts, views, sales, finance

Predictive analytics (what will occur)

Use available data to predict data we don’t have using variety of statistical, modeling, data mining, and machine learning techniques

Prescriptive analytics (what should occur)

Recommend one or more courses of action and showing the likely outcome of each decision so that the business decision-maker can take this information and act

Adapted from Information Week, definitions by Dr Michael Wu http://www.informationweek.com/big-data/big-data-analytics/big-data-analytics-descriptive-vs-predictive-vs-prescriptive/d/d-id/1113279

A Primer on Optimization Using Solvers - Anwar Ali 5

Page 6: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Business Intelligence Framework

Back in Business, by Ronald K. Klimberg and Virginia Miori, OR/MS Today, Vol 37, No 5, October 2010, [http://www.informs.org/ORMS-Today/Public-Articles/October-Volume-37-Number-5/Back-in-Business]

OR/MS = Operations Research/ Management Science

A Primer on Optimization Using Solvers - Anwar Ali 6

Page 7: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

What is Operations Research? O.R. is the discipline of applying advanced analytical

methods to help make better decisions

Also called Management Science or Decision Science, O.R. is the science of Decision-Making

Employing techniques from mathematical sciences, O.R. arrives at optimal or near-optimal solutions to complex decision-making problems

Determine the maximum (e.g. profit, performance, or yield) or minimum (e.g. loss, risk, or cost)

A Primer on Optimization Using Solvers - Anwar Ali 7

Page 8: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Analytics Landscape

Descriptive

Prescriptive

Predictive

Degree of Complexity

Com

petitive A

dvanta

ge

Standard Reporting

Ad hoc reporting

Query/drill down

Alerts

Simulation

Forecasting

Predictive modeling

Optimization

What exactly is the problem?

What will happen next if ?

What if these trends continue?

What could happen…. ?

What actions are needed?

How many, how often, where?

What happened?

Stochastic Optimization

How can we achieve the best outcome?

How can we achieve the best outcome

including the effects of variability?

Adapted from: IBM, Based on: Competing on Analytics,

Davenport and Harris, 2007

Operations Research

A Primer on Optimization Using Solvers - Anwar Ali 8

Page 9: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

O.R. Leading Edge Techniques Simulation

Giving you the ability to try out approaches and test ideas for improvement

Optimization

Narrowing your choices to the very best where there are virtually innumerable feasible options and comparing them is difficult

Probability and statistics

Helping you measure risk, mine data to find valuable connections and insights, test conclusions, and make reliable forecasts

A Primer on Optimization Using Solvers - Anwar Ali 9

Page 10: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

O.R. Leading Edge Techniques Simulation (predictive)

Giving you the ability to try out approaches and test ideas for improvement

Optimization (prescriptive)

Narrowing your choices to the very best where there are virtually innumerable feasible options and comparing them is difficult

Probability and statistics (predictive)

Helping you measure risk, mine data to find valuable connections and insights, test conclusions, and make reliable forecasts

A Primer on Optimization Using Solvers - Anwar Ali 10

Page 11: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

O.R. Leading Edge Techniques Simulation

Giving you the ability to try out approaches and test ideas for improvement

Optimization – THIS TRAINING

Narrowing your choices to the very best where there are virtually innumerable feasible options and comparing them is difficult

Probability and statistics

Helping you measure risk, mine data to find valuable connections and insights, test conclusions, and make reliable forecasts

A Primer on Optimization Using Solvers - Anwar Ali 11

Page 12: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Examples of O.R. Application Deciding where to invest capital in order to grow

Figuring out the best way to run a call center

Locating a warehouse or depot to deliver materials over shorter distances at reduced cost

Solving complex scheduling problems

Deciding when to discount, and how much

Getting more out of manufacturing equipment

Optimizing a portfolio of investments

A Primer on Optimization Using Solvers - Anwar Ali 12

Page 13: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Terminology Evolved Previous Current

Operations Research

Statistics

Decision Support

Data sets (structured)

Data Analyst

Business Analytics

Data Science

Business Intelligence / Analytics

Big Data (unstructured)

Data Scientist

A Primer on Optimization Using Solvers - Anwar Ali 13

Page 14: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

What are the Benefits of O.R.? Operations Research is called “The Science of Better”,

i.e. using science to make:

bold decisions and run everyday operations with less risk and better outcomes (no more gut-feel)

repeatable, quantitative decision analysis

Adapted from: The Guide to Operational Research, http://www.scienceofbetter.co.uk/

A Primer on Optimization Using Solvers - Anwar Ali 14

Page 15: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Signs O.R. Could Be Beneficial The management face complex decision making

The management is not sure what the main problem is

The management is uncertain about potential outcomes

The organization is having problems with decision making processes

Management is troubled by risk

The organization is not making the most of its data

The organization needs to beat stiff competition

The Guide to Operational Research, http://www.scienceofbetter.co.uk/

A Primer on Optimization Using Solvers - Anwar Ali 15

Page 16: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Agenda Introduction to Analytics and Operations Research √

Optimization Modeling with Textbook Examples

Formulating and Solving Mathematical Models

Optimization Applications in Industry

How to Get Started

A Primer on Optimization Using Solvers - Anwar Ali 16

Page 17: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Optimization Modeling Optimization models have

Objective function

Decision variables

Constraints

Formulated as mathematical equations

Solved graphically (for problems with 2 decision variables) or using ‘Solver’ (will be explained later)

We will start with simple Linear Programming (LP) model examples from textbooks

A Primer on Optimization Using Solvers - Anwar Ali 17

Page 18: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 1: Dorian Auto

Operations Research: Applications and Algorithms

Wayne L. Winston

Duxbury Press; 4th edition (2003)

A Primer on Optimization Using Solvers - Anwar Ali 18

Page 19: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 1: Dorian Auto Dorian Auto manufactures luxury cars and trucks

The company believes that its most likely customers are high-income women and men

To reach these groups, Dorian Auto has embarked on an ambitious TV advertising campaign and will purchase 1-minute commercial spots on two type of programs: comedy shows and football games

A Primer on Optimization Using Solvers - Anwar Ali 19

Page 20: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 1: Dorian Auto Each comedy commercial is seen by 7 million high

income women and 2 million high-income men and costs $50,000

Each football game is seen by 2 million high-income women and 12 million high-income men and costs $100,000

Dorian Auto would like for commercials to be seen by at least 28 million high-income women and 24 million high-income men

We will use LP to determine how Dorian Auto can meet its advertising requirements at minimum cost

A Primer on Optimization Using Solvers - Anwar Ali 20

Page 21: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 1: Solution Decision variables:

x = the number of 1-minute comedy ads

y = the number of 1-minute football ads

The objective is to minimize advertising cost

Minimize z = 50x + 100y

Constraints:

Ads must be seen by at least 28 million high-income women; 7x + 2y ≥ 28

Ads must be seen by at least 24 million high-income men; 2x + 12y ≥ 24

Sign restrictions; x ≥ 0 and y ≥ 0

A Primer on Optimization Using Solvers - Anwar Ali 21

Page 22: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Graphical Solution

x (comedy ads)

y (football ads)

4 8 12 16

4

12

16

8

2

6

10

14

2 6 10 14 A Primer on Optimization Using Solvers - Anwar Ali 22

Min z = 50x + 100y subject to: 7x + 2y ≥ 28 2x + 12y ≥ 24 x, y ≥ 0

Page 23: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Graphical Solution

x (comedy ads)

y (football ads)

4 8 12 16

4

12

16

8

2

6

10

14

2 6 10 14

High-income women constraint; 7x + 2y ≥ 28

A Primer on Optimization Using Solvers - Anwar Ali 23

Min z = 50x + 100y subject to: 7x + 2y ≥ 28 2x + 12y ≥ 24 x, y ≥ 0

Page 24: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Graphical Solution

x (comedy ads)

y (football ads)

4 8 12 16

4

12

16

8

2

6

10

14

2 6 10 14

High-income women constraint; 7x + 2y ≥ 28

High-income men constraint; 2x + 12y ≥ 24

A Primer on Optimization Using Solvers - Anwar Ali 24

Min z = 50x + 100y subject to: 7x + 2y ≥ 28 2x + 12y ≥ 24 x, y ≥ 0

Page 25: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Unbounded feasible region

Graphical Solution

x (comedy ads)

y (football ads)

4 8 12 16

4

12

16

8

2

6

10

14

2 6 10 14

High-income women constraint

High-income men constraint

A Primer on Optimization Using Solvers - Anwar Ali 25

Min z = 50x + 100y subject to: 7x + 2y ≥ 28 2x + 12y ≥ 24 x, y ≥ 0

Page 26: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Unbounded feasible region

Graphical Solution

x (comedy ads)

y (football ads)

4 8 12 16

4

12

16

8

2

6

10

14

2 6 10 14

High-income women constraint

High-income men constraint

A Primer on Optimization Using Solvers - Anwar Ali 26

Min z = 50x + 100y subject to: 7x + 2y ≥ 28 2x + 12y ≥ 24 x, y ≥ 0

Page 27: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Unbounded feasible region

Graphical Solution

x (comedy ads)

y (football ads)

4 8 12 16

4

12

16

8

2

6

10

14

2 6 10 14

High-income women constraint

High-income men constraint

x = 3.6 y = 1.4

A Primer on Optimization Using Solvers - Anwar Ali 27

Min z = 50x + 100y subject to: 7x + 2y ≥ 28 2x + 12y ≥ 24 x, y ≥ 0

Page 28: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Optimal Answer To minimize advertising cost, purchase

3.6 slots of comedy ads (x)

1.4 slots of football ads (y)

The total advertising cost (in thousands) is

z = 50x + 100 y

z = 50(3.6) + 100(1.4)

z = 320

But in reality, it is not possible to purchase fractional number of 1-minute ads. The decision variables x and y must be integers

A Primer on Optimization Using Solvers - Anwar Ali 28

Page 29: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Integer Programming When an LP model has integer decision variable(s), it

is called integer linear programming (ILP). Why ILP?

We cannot buy 3.6 slots of ads, must be either 3 or 4

Yes/no decisions can be modeled as 0 or 1 variables

When an LP model has mixture of continuous and integer variables, it is called mixed integer linear programming (MILP)

ILP and MILP models are harder and take longer to solve compared to LP models

We will use the term “math programming” to refer to LP, ILP, and MILP

A Primer on Optimization Using Solvers - Anwar Ali 29

Page 30: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Unbounded feasible region

Graphical Integer Solution

x (comedy ads)

y (football ads)

4 8 12 16

4

12

16

8

2

6

10

14

2 6 10 14

High-income women constraint

High-income men constraint Feasible integer solutions

A Primer on Optimization Using Solvers - Anwar Ali 30

Min z = 50x + 100y subject to: 7x + 2y ≥ 28 2x + 12y ≥ 24 x, y ≥ 0 x, y integers

Page 31: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Unbounded feasible region

Graphical Integer Solution

x (comedy ads)

y (football ads)

4 8 12 16

4

12

16

8

2

6

10

14

2 6 10 14

High-income women constraint

High-income men constraint

Lowest z value in feasible region

Optimal integer solutions Feasible integer solutions

A Primer on Optimization Using Solvers - Anwar Ali 31

Min z = 50x + 100y subject to: 7x + 2y ≥ 28 2x + 12y ≥ 24 x, y ≥ 0 x, y integers

Page 32: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Unbounded feasible region

Graphical Integer Solutions

x (comedy ads)

y (football ads)

4 8 12 16

4

12

16

8

2

6

10

14

2 6 10 14

x = 6, y = 1 x = 4, y = 2

2 solutions with z = 400

A Primer on Optimization Using Solvers - Anwar Ali 32

Min z = 50x + 100y subject to: 7x + 2y ≥ 28 2x + 12y ≥ 24 x, y ≥ 0 x, y integers

Page 33: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Graphical Integer Solutions There are 2 solutions with z = 400

4 slots of comedy ads (x) and 2 slots of football ads (y); z = 50(4) + 100(2) = 400

6 slots of comedy ads (x) and 1 slot of football ads (y); z = 50(6) + 100(1) = 400

For more complex problems which cannot be solve graphically, branch-and-bound method is used

A Primer on Optimization Using Solvers - Anwar Ali 33

Page 34: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 2: Diet Problem

Introduction to Management Science

Bernard W. Taylor III

Prentice Hall, 7th edition (2002); the diet problem is from this edition

Latest is 11th edition (2012)

A Primer on Optimization Using Solvers - Anwar Ali 34

Page 35: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 2: Diet Problem

Breakfast to include at least 420 calories, 5 milligrams of iron, 400 milligrams of calcium, 20 grams of protein, 12 grams of fiber, and must have no more than 20 grams of fat and 30 milligrams of cholesterol

A Primer on Optimization Using Solvers - Anwar Ali 35

Page 36: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 2: Diet Problem The objective is to minimize meal cost while meeting

the following nutritional requirement:

Calories ≥ 420

Iron ≥ 5

Calcium ≥ 400

Protein ≥ 20

Fiber ≥ 12

Fat ≤ 20

Cholesterol ≤ 30

A Primer on Optimization Using Solvers - Anwar Ali 36

Page 37: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 2: Decision Variables x1 = cups of bran cereal

x2 = cups of dry cereal

x3 = cups of oatmeal

x4 = cups of oat bran

x5 = eggs

x6 = slices of bacon

x7 = oranges

x8 = cups of milk

x9 = cups of orange juice

x10 = slices of wheat toast

A Primer on Optimization Using Solvers - Anwar Ali 37

Page 38: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 2: Problem Formulation Minimize

0.18x1 + 0.22x2 + 0.10x3 + 0.12x4 + 0.10x5 + 0.09x6 + 0.40x7 + 0.16x8 + 0.50x9 + 0.07x10

Subject to:

90x1 + 110x2 + 100x3 + 90x4 + 75x5 + 35x6 + 65x7 + 100x8 + 120x9 + 65x10 ≥ 420

6x1 + 4x2 + 2x3 + 3x4 + x5 + x7 + x10 ≥ 5

20x1 + 48x2 + 12x3 + 8x4 + 30x5 + 52x7 + 250x8 + 3x9 + 26x10 ≥ 400

3x1 + 4x2 + 5x3 + 64 + 7x5 + 2x6 + x7 + 9x8 + x9 + 3x10 ≥ 20

5x1 + 2x2 + 3x3 + 4x4 + x7 + 3x10 ≥ 12

2x2 + 2x3 + 2x4 + 5x5 + 3x6 + 4x8 + x10 ≤ 20

270x5 + 8x6 + 12x8 ≤ 30

x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 ≥ 0

A Primer on Optimization Using Solvers - Anwar Ali 38

Page 39: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Example 2: Solution The diet problem cannot be solved graphically as it has

10 decision variables

We will use ‘Solver’ to find solution for the problem

A Primer on Optimization Using Solvers - Anwar Ali 39

Page 40: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Solver Mathematical software, either stand-alone or library,

that 'solves' a mathematical programming problem

Uses algorithms such as SIMPLEX and branch-and-bound to solve the problem

May include Integrated Development Environment (IDE), e.g. GUI and editor

Solvers used in this training:

Excel Solver, free Excel ad-in with limited capability

IBM ILOG CPLEX and LPSolve have complete IDE

LPSolve is free (GNU lesser general public license) and can be downloaded from sourceforge.net

A Primer on Optimization Using Solvers - Anwar Ali 40

Page 41: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Decision Modeling with Excel Knowledge on the following is required: named range

and SUMPRODUCT() function

Named ranges can help make Excel spreadsheet formulas more readable

SUMPRODUCT() can simplify lengthy formulas if the worksheet is designed properly

We will explain how the Diet problem Excel Solver model is developed using named ranges and SUMPRODUCT() function

We also need to enable Excel Solver Add-in

41 A Primer on Optimization Using Solvers - Anwar Ali

Page 42: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Enabling Excel Solver Add-in Start Excel

From File, Options, highlight Add-Ins

From Manage, select Excel Add-ins drop down menu and hit Go button

Note: Excel Solver interface

screenshots are from Excel 2010. Other screenshots are from Excel 2007 & Excel 2010

42 A Primer on Optimization Using Solvers - Anwar Ali

Page 43: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Enabling Excel Solver Add-In Check the box for Solver

Add-in, then hit OK

43 A Primer on Optimization Using Solvers - Anwar Ali

Page 44: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Enter diet data into Excel

44 A Primer on Optimization Using Solvers - Anwar Ali

Page 45: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name B3:B12 as serving

A Primer on Optimization Using Solvers - Anwar Ali 45

These cells are the decision variables x1 to x10

Page 46: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name D3:D12 as cost

46 A Primer on Optimization Using Solvers - Anwar Ali

Page 47: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name E3:E12 as calories

47 A Primer on Optimization Using Solvers - Anwar Ali

Page 48: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Naming Ranges: Continue with F3:F12 as fat

G3:G12 as cholesterol

H3:H12 as iron

I3:I12 as calcium

J3:J12 as protein

K3:K12 as fiber

A Primer on Optimization Using Solvers - Anwar Ali 48

Page 49: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Add SUMPRODUCT() to col E:K

49 A Primer on Optimization Using Solvers - Anwar Ali

Page 50: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

What is SUMPRODUCT()?

Given that serving is defined as B3:B12 and calories is defined as E3:E12, SUMPRODUCT(serving,calories) equals to B3*E3 + B4*E4 + B5*E5 + B6*E6 + B7*E7 + B8*E8 + B9*E9 + B10*E10 + B11*E11 + B12*E12

50 A Primer on Optimization Using Solvers - Anwar Ali

Page 51: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Enter SUMPRODUCT() @ cells E14 =SUMPRODUCT(serving,calories)

F14 =SUMPRODUCT(serving,fat)

G14 =SUMPRODUCT(serving,cholesterol)

H14 =SUMPRODUCT(serving,iron)

I14 =SUMPRODUCT(serving,calcium)

J14 =SUMPRODUCT(serving,protein)

K14 =SUMPRODUCT(serving,fiber)

51 A Primer on Optimization Using Solvers - Anwar Ali

Page 52: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Adding Constraints The ≥ and ≤ signs in row 15 are optional

To make the spreadsheet more readable

Add Nutritional Requirement values in row 16

52 A Primer on Optimization Using Solvers - Anwar Ali

Page 53: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Objective Function

53 A Primer on Optimization Using Solvers - Anwar Ali

Page 54: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Objective Function Name cell B18 as meal_cost

Enter =SUMPRODUCT(serving,cost) into cell B18

The objective function is to minimize cell B18, meal_cost

Now, we need to enter the objective function and the constraints into Excel Solver

54 A Primer on Optimization Using Solvers - Anwar Ali

Page 55: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Excel Solver Interface

From Excel menu, select Data. Solver should be visible on the right. Select Solver

55 A Primer on Optimization Using Solvers - Anwar Ali

Page 56: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Excel Solver Interface

Objective (Min)

Enter meal_cost

Select Min radio button

By Changing Variable Cells (Decision Variables)

Enter serving

Subject to the Constraints:

Add the constraints one at a time

56 A Primer on Optimization Using Solvers - Anwar Ali

Page 57: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Excel Solver Parameters

57 A Primer on Optimization Using Solvers - Anwar Ali

Page 58: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Solving…. Hit Solve button and the

dialog box should appear, with the answers in cells serving

Hit OK

58 A Primer on Optimization Using Solvers - Anwar Ali

Page 59: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Excel Solver Solution

59 A Primer on Optimization Using Solvers - Anwar Ali

Page 60: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Excel Solver Excel Solver has

determined these are the optimal answers

60 A Primer on Optimization Using Solvers - Anwar Ali

Page 61: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Excel Solver But the solution requires

fractional cups and/or slices of food

How to make them as round number?

We will show how to make the answer for wheat toast slice as a round number

61 A Primer on Optimization Using Solvers - Anwar Ali

Page 62: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Mixed-Integer Diet Problem Add another constraint

with type integer

62 A Primer on Optimization Using Solvers - Anwar Ali

Page 63: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Integer variable added

63 A Primer on Optimization Using Solvers - Anwar Ali

Page 64: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Solution with Integer Variable

64 A Primer on Optimization Using Solvers - Anwar Ali

Page 65: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Model in IBM ILOG CPLEX

A Primer on Optimization Using Solvers - Anwar Ali 65

Page 66: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

IBM ILOG CPLEX Solution

A Primer on Optimization Using Solvers - Anwar Ali 66

Page 67: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

CPLEX Model (Integer variable)

A Primer on Optimization Using Solvers - Anwar Ali 67

Page 68: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Model in LPSolve

A Primer on Optimization Using Solvers - Anwar Ali 68

Page 69: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

LPSolve Solution

A Primer on Optimization Using Solvers - Anwar Ali 69

Page 70: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

LPSolve Model (Integer Variable)

A Primer on Optimization Using Solvers - Anwar Ali 70

Page 71: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

LPSolve Solution (Integer Variable)

A Primer on Optimization Using Solvers - Anwar Ali 71

Page 72: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Key Take Away In university, we were taught how to model and then

solve the problem by hand

In practice, solvers like Excel Solver, ILOG CPLEX and LPSolve can find the solution(s) very quickly SIMPLEX used for linear programming

Brand-and-bound used for integer model

It is important to understand the modeling concepts and able to formulate the problems correctly

But real-world models are a lot more complex than the textbook examples May have multiple conflicting objectives

Many (thousands) decision variables and constraints

A Primer on Optimization Using Solvers - Anwar Ali 72

Page 73: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Conflicting Objectives

Cost Profit Labor

Service

Time

Regulations Policy Laws

Process

Quality Systems

Safety

Compliance

A Primer on Optimization Using Solvers - Anwar Ali 73

Page 74: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Choice of Solver The choice of solver depends on the problem size and

the ability to integrate with enterprise system

Excel Solver is recommended for rapid prototyping and quick-wins

Demonstrate the concept to users and management

Can be used if the problem is small

When all data is local and no database interface is required

Commercial solver is required for large problems and data integration with enterprise system

Scalable with powerful database interfaces

A Primer on Optimization Using Solvers - Anwar Ali 74

Page 75: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Agenda Introduction to Analytics and Operations Research √

Optimization Modeling with Textbook Examples √

Formulating and Solving Mathematical Models

Optimization Applications in Industry

How to Get Started

A Primer on Optimization Using Solvers - Anwar Ali 75

Page 76: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Problem Formulation Problem formulation is the most challenging part in

math programming

Once the problem has been formulated correctly, putting the problem into solvers is easy

Need to use the correct approach in developing the mathematical equations of a problem

The more experience we have in problem formulation, the easier it becomes

A Primer on Optimization Using Solvers - Anwar Ali 76

Page 77: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

The formulation of a problem is often more essential than its solution, which may be merely a matter of mathematical or experimental skill

Albert Einstein

A Primer on Optimization Using Solvers - Anwar Ali 77

Picture from Wikipedia

Page 78: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Recommended Modeling Approach First, must understand the problem well

e.g. business rules, objective(s), constraints, input data and output/decisions required

Talk to the experts how decisions are made without a model

Relate the problem to the relevant model types

Look at examples of the relevant model types

Many Excel Solver examples are downloadable from Frontline Systems

IBM ILOG CPLEX has examples of different complexity

Develop and refine the model until it represents the problem faithfully

A Primer on Optimization Using Solvers - Anwar Ali 78

Page 79: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Additional Reference – Williams

Model Building in Mathematical Programming

H. Paul Williams

John Wiley & Sons, Ltd. 5th edition (2013)

A Primer on Optimization Using Solvers - Anwar Ali 79

Page 80: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia
Page 81: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Bin packing / knapsack problem

A Primer on Optimization Using Solvers - Anwar Ali 81

Page 82: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Cut into different sizes and shapes and minimize the waste

Cutting stock problem

A Primer on Optimization Using Solvers - Anwar Ali 82

Page 83: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Start from a city, visit each city only once, and return to the original city after all cities visited. Minimize the travel distance / cost

Traveling salesman problem (TSP) A Primer on Optimization Using Solvers - Anwar Ali 83

Page 84: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Assign gates to planes considering plane type, schedule, domestic/international, airlines Assignment problem

A Primer on Optimization Using Solvers - Anwar Ali 84

Page 85: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Blending problem A Primer on Optimization Using Solvers - Anwar Ali 85

Page 86: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Minimize breakfast cost and include at least 420 calories, 5 milligrams of iron, 400 milligrams of

calcium, 20 grams of protein, 12 grams of fiber, and must have no more than 20 grams of fat and 30

milligrams of cholesterol

Diet problem A Primer on Optimization Using Solvers - Anwar Ali 86

Page 87: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Summary of Problems Linear Programming

Blending problem

Diet problem

Integer Programming

Bin packing / knapsack problem

Cutting stock problem

Traveling salesman problem (TSP)

Assignment problem

We pick the interesting TSP problem and demonstrate how it is formulated and solved

A Primer on Optimization Using Solvers - Anwar Ali 87

Page 88: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

TSP Described You are given a set of n cities

You are given the distances between the cities

You start and terminate your tour at your home city

You must visit each other city exactly once

Your mission is to determine the shortest tour

A Primer on Optimization Using Solvers - Anwar Ali 88

Page 89: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

TSP LP Formulation Set of cities 𝑁 = 1,2,… , 𝑛

Decision variables, 𝑥𝑖𝑗

𝑥𝑖𝑗 = 1 if we go from city i to city j

𝑥𝑖𝑗 = 0 otherwise, 𝑖 ≠ 𝑗

𝑑𝑖𝑗 = direct distance from between city i and city j

Example: 𝑛 = 4, 𝑥 =

0 1 0 00 0 1 00 0 0 11 0 0 0

represents the tour (1,2,3,4,1)

A Primer on Optimization Using Solvers - Anwar Ali 89

Page 90: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

TSP Objective Function

𝑚𝑖𝑛 𝑧 =

𝑛

𝑖=1

𝑑𝑖𝑗𝑥𝑖𝑗

𝑛

𝑗=1𝑖≠𝑗

A Primer on Optimization Using Solvers - Anwar Ali 90

Page 91: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

TSP Constraints

Each city must be “entered” exactly once and “exited” exactly once

𝑥𝑖𝑗

𝑛

𝑗=1𝑗≠𝑖

= 1, ∀𝑖 ∈ 𝑁

𝑥𝑖𝑗

𝑛

𝑖=1𝑖≠𝑗

= 1, ∀𝑗 ∈ 𝑁

Subject to:

A Primer on Optimization Using Solvers - Anwar Ali 91

Page 92: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

But it may create sub-tours

Example solution, 𝑥 =

0 1 0 01 0 0 00 0 0 10 0 1 0

represents two sub-tours (1,2,1) and (3,4,3)

This is not feasible for TSP

1

2

3

4

A Primer on Optimization Using Solvers - Anwar Ali 92

Page 93: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Sub-tour Elimination Constraint The various methods of adding sub-tour elimination

constraints were summarized by Orman, A. J. and Williams, H. Paul

http://eprints.lse.ac.uk/22747/

For implementation in Excel, we select the Sequential Formulation by Miller, Tucker and Zemlin as it has the least number of decision variables and constraints

A Primer on Optimization Using Solvers - Anwar Ali 93

Page 94: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Sub-tour Elimination Constraint Add continuous variables,

𝑢𝑖= sequence in which city i is visited (𝑖 ≠ 1)

And add constraints

𝑢𝑖 − 𝑢𝑗 + 𝑛𝑥𝑖𝑗 ≤ 𝑛 − 1, ∀𝑖, 𝑗 ∈ 𝑁 − 1 , 𝑖 ≠ 𝑗

The simpler, layman version:

𝑢𝑖 − 𝑢𝑗 + 𝑛𝑥𝑖𝑗 ≤ 𝑛 − 1, ∀𝑖, 𝑗 ∈ 2,3, . . , 𝑛 , 𝑖 ≠ 𝑗

A Primer on Optimization Using Solvers - Anwar Ali 94

Page 95: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Complete TSP Formulation

𝑚𝑖𝑛 𝑧 =

𝑛

𝑖=1

𝑑𝑖𝑗𝑥𝑖𝑗

𝑛

𝑗=1𝑖≠𝑗

𝑥𝑖𝑗

𝑛

𝑗=1𝑗≠𝑖

= 1, ∀𝑖 ∈ 𝑁

𝑥𝑖𝑗

𝑛

𝑖=1𝑖≠𝑗

= 1, ∀𝑗 ∈ 𝑁

Subject to:

𝑢𝑖 − 𝑢𝑗 + 𝑛𝑥𝑖𝑗 ≤ 𝑛 − 1, ∀𝑖, 𝑗 ∈ 𝑁 − 1 , 𝑖 ≠ 𝑗

𝑁 = 𝑐𝑖𝑡𝑖𝑒𝑠 {1,2, . . , 𝑛}

A Primer on Optimization Using Solvers - Anwar Ali 95

Page 96: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

TSP Demo Due to limitations of free Excel Solver, we can only

solve a 10-city problem. Excel 2007 is used here

Let’s travel to 10 capital cities of ASEAN

Start and terminate the tour at a city

Must visit each other city exactly once

Objective: minimize the total air travel distance

A Primer on Optimization Using Solvers - Anwar Ali 96

Country Capital Airport BWN PNH CGK VTE KUL NYT MNL SIN BKK HAN

Brunei Bandar Seri Begawan BWN 1330 1534 1977 1487 2603 1255 1278 1833 2060

Cambodia Phnom Penh PNH 1330 1975 757 1038 1289 1782 1138 504 1081

Indonesia Jakarta CGK 1534 1975 2719 1129 3083 2788 882 2297 3042

Laos Vientiane VTE 1977 757 2719 1697 694 2007 1857 517 495

Malaysia Kuala Lumpur KUL 1487 1038 1129 1697 1970 2490 297 1221 2102

Myanmar Naypyidaw NYT 2603 1289 3083 694 1970 2696 2202 819 1016

Philippines Manila MNL 1255 1782 2788 2007 2490 2696 2375 2188 1773

Singapore Singapore SIN 1278 1138 882 1857 297 2202 2375 1417 2218

Thailand Bangkok BKK 1833 504 2297 517 1221 819 2188 1417 995

Vietnam Hanoi HAN 2060 1081 3042 495 2102 1016 1773 2218 995

Page 97: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

A Primer on Optimization Using Solvers - Anwar Ali 97

Page 98: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Setup the Excel worksheet

A Primer on Optimization Using Solvers - Anwar Ali 98

Page 99: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name D2:M11 as distance

A Primer on Optimization Using Solvers - Anwar Ali 99

Page 100: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name D13:M22 as var_X

A Primer on Optimization Using Solvers - Anwar Ali 100

Page 101: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

D23=SUM(D13:D22), copy to E23:M23

A Primer on Optimization Using Solvers - Anwar Ali 101

Page 102: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name D23:M23 as constraint1

A Primer on Optimization Using Solvers - Anwar Ali 102

Page 103: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

N13=SUM(D13:M13), copy to N14:N22

A Primer on Optimization Using Solvers - Anwar Ali 103

Page 104: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name N13:N22 as constraint2

A Primer on Optimization Using Solvers - Anwar Ali 104

Page 105: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name E25:M25 as var_U

A Primer on Optimization Using Solvers - Anwar Ali 105

Page 106: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Sub-tour elimination constraint We need to implement this into the Excel model

While the equation looks simple, the indexing of variable u makes it more challenging in Excel Use INDEX() function; row = index i, column = index j

Name top left cell as ref_cell (where i, j = 1)

Name the constraint range as subtour_elim with i, j ≥ 2

Each cell in subtour_elim needs to calculate its i and j indices by referencing to ref_cell

We cannot exclude i ≠ j in the named ranges; the model in Excel is not 100% correct but will still work

A Primer on Optimization Using Solvers - Anwar Ali 106

𝑢𝑖 − 𝑢𝑗 + 𝑛𝑥𝑖𝑗 ≤ 𝑛 − 1

∀𝑖, 𝑗 ∈ 𝑁 − {1 , 𝑖 ≠ 𝑗

Page 107: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name D29 as ref_cell

A Primer on Optimization Using Solvers - Anwar Ali 107

Page 108: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Enter sub-tour elimination constraint

A Primer on Optimization Using Solvers - Anwar Ali 108

Page 109: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Copy to the range, subtour_elim

A Primer on Optimization Using Solvers - Anwar Ali 109

Page 110: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Name D40 as total_distance, =SUMPRODUCT(distance,var_X)

A Primer on Optimization Using Solvers - Anwar Ali 110

Page 111: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Solver Parameters

A Primer on Optimization Using Solvers - Anwar Ali 111

Under Options, select the checkboxes Assume Linear Model Assume Non-Negative

Page 112: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Solution

A Primer on Optimization Using Solvers - Anwar Ali 112

Page 113: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Solution

A Primer on Optimization Using Solvers - Anwar Ali 113

BWN CGK SIN KUL PNH BKK NYT VTE HAN MNL BWN Total distance = 9291 km

Page 114: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

CPLEX OPL TSP Model

A Primer on Optimization Using Solvers - Anwar Ali 114

/*********************************************

* OPL 12.6.2.0 Model

* Author: Anwar Ali

* 10-city TSP model of ASEAN capital cities

*********************************************/

int n = 10;

range cities = 1..n;

range uvar = 2..n;

string city[cities] = ["BWN", "PNH", "CGK", "VTE", "KUL", "NYT", "MNL", "SIN", "BKK", "HAN"];

int dist[cities][cities] = [

[0, 1330, 1534, 1977, 1487, 2603, 1255, 1278, 1833, 2060],

[1330, 0, 1975, 757, 1038, 1289, 1782, 1138, 504, 1081],

[1534, 1975, 0, 2719, 1129, 3083, 2788, 882, 2297, 3042],

[1977, 757, 2719, 0, 1697, 694, 2007, 1857, 517, 495],

[1487, 1038, 1129, 1697, 0, 1970, 2490, 297, 1221, 2102],

[2603, 1289, 3083, 694, 1970, 0, 2696, 2202, 819, 1016],

[1255, 1782, 2788, 2007, 2490, 2696, 0, 2375, 2188, 1773],

[1278, 1138, 882, 1857, 297, 2202, 2375, 0, 1417, 2218],

[1833, 504, 2297, 517, 1221, 819, 2188, 1417, 0, 995],

[2060, 1081, 3042, 495, 2102, 1016, 1773, 2218, 995, 0]

];

Page 115: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

CPLEX OPL TSP Model

A Primer on Optimization Using Solvers - Anwar Ali 115

dvar boolean x[cities][cities];

dvar float+ u[uvar];

minimize

sum(i in cities, j in cities: i!=j) x[i][j]*dist[i][j];

subject to {

forall(i in cities) sum(j in cities: j!=i) x[i][j] == 1;

forall(j in cities) sum(i in cities: i!=j) x[i][j] == 1;

forall(i in uvar, j in uvar: i!=j) u[i] - u[j] + n*x[i][j] <= n - 1;

}

execute {

var from;

var dest;

from = 1;

for (var cnt=1; cnt<=10; cnt++) {

for (dest=1; dest<=n; dest++)

if (x[from][dest]==1) {

write(city[from]," --> ");

from = dest;

break;

}

}

writeln(city[dest]);

}

Page 116: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

CPLEX OPL Solution // solution (optimal) with objective 9291

BWN --> CGK --> SIN --> KUL --> PNH --> BKK --> NYT --> VTE --> HAN --> MNL --> BWN

A Primer on Optimization Using Solvers - Anwar Ali 116

Page 117: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

CPLEX OPL Solution

A Primer on Optimization Using Solvers - Anwar Ali 117

Page 118: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

A Primer on Optimization Using Solvers - Anwar Ali 118

Page 119: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

TSP Key Learning Textbook TSP formulation can be directly used to solve

real-world problems

As the formulation gets more complex, it becomes harder to model in Excel, but still easy in OPL

Excel named ranges are only for rectangles

Some tricks required for indexing of variables

A Primer on Optimization Using Solvers - Anwar Ali 119

Page 120: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Agenda Introduction to Analytics & Operations Research √

Optimization Modeling with Textbook Examples √

Formulating and Solving Mathematical Models √

Optimization Applications in Industry

How to Get Started

A Primer on Optimization Using Solvers - Anwar Ali 120

Page 121: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Waste neither time nor money, but make the best use of both

Benjamin Franklin

A Primer on Optimization Using Solvers - Anwar Ali 121

Picture from Wikipedia

Page 122: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Supply Chain Optimization Plan

Facilities

Resources required

Source Make vs Buy

Materials

Make Prod planning

Deliver Warehouse

Transportation

Location (where to open)

Min capital & headcount, max usage

Make in-house or sub-con?

How much to buy? Which supplier?

Who does what? How much to make?

Sequencing, batching decisions

Location and inventory level

Which air, sea & ground network

A Primer on Optimization Using Solvers - Anwar Ali 122

Page 123: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Supply Chain Optimization This can be very complex depending on company’s size

For large companies, it is recommended to get complete solutions from various solution providers

It is not just system implementation, but business processes changes as well

It is better to start with small wins (phase-by-phase) instead of big bang approach

A Primer on Optimization Using Solvers - Anwar Ali 123

Page 124: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Airline Industry Optimization Crew scheduling

Aircraft scheduling

Airport gates assignment

Baggage handling

Tickets pricing

A Primer on Optimization Using Solvers - Anwar Ali 124

Page 125: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

TSP Application Examples Vehicle routing problem

Modified (more complex) TSP. Find the optimal route to deliver goods from central depot to customers who placed orders for such goods

Design and fabrication of integrated circuits (IC)

Minimize time spent during lithography to reduce the capital cost of semiconductor factory

Design and manufacturing of printed circuit board (PCB) and substrates

Placement of components, routing, drilling

A Primer on Optimization Using Solvers - Anwar Ali 125

Page 126: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Vehicle Routing Problem

A Primer on Optimization Using Solvers - Anwar Ali 126

Page 127: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

PCB Example

A Primer on Optimization Using Solvers - Anwar Ali 127

Page 128: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

PCB Holes Drilling

A Primer on Optimization Using Solvers - Anwar Ali 128

Page 129: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

PCB Holes Drilling Without TSP

Less travel distance with TSP, hence less drill time

A Primer on Optimization Using Solvers - Anwar Ali 129

Page 130: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Agenda Introduction to Analytics and Operations Research √

Optimization Modeling with Textbook Examples √

Formulating and Solving Mathematical Models √

Optimization Applications in Industry √

How to Get Started

A Primer on Optimization Using Solvers - Anwar Ali 130

Page 131: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Getting Started with Optimization Get management sponsors

Convince management the benefits of optimization

Identify the challenges in decision making process

Unable to predict the outcome?

Complexity in decision making

Drill down the decision making process

Objectives, rules, and boundary conditions

Input data required

What kind of outcomes/decisions needed

Build and demo quick-win optimization model(s)

Refine it until it can replace the current process

A Primer on Optimization Using Solvers - Anwar Ali 131

Page 132: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Competencies Required Spreadsheet modeling

Mathematical optimization

Data integration

Business acumen

Hire consultant and/or upskill employees

Read this:

http://www.scienceofbetter.co.uk/

A Primer on Optimization Using Solvers - Anwar Ali 132

Page 133: Anwar Ali, D.Eng anwar.ali.mohamed@gmail€¦ · A Primer on Optimization Using Solvers - Anwar Ali 5 Business Intelligence Framework Back in Business, by Ronald K. Klimberg and Virginia

Training & Consulting Current training:

3-day “Practical Business Optimization Using Solvers”

If you need help with optimization modeling for your business needs, I will be happy to offer my service

My email: [email protected]

My profile: https://www.linkedin.com/pub/anwar-ali-mohamed/54/2bb/57b

Location: Penang & Kuala Lumpur, Malaysia

A Primer on Optimization Using Solvers - Anwar Ali 133