Examining a model for Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous.

Slides:



Advertisements
Similar presentations
Solving LP Problems in a Spreadsheet
Advertisements

Optimization problems using excel solver
Chapter 5: Linear Programming: The Simplex Method
Linear Programming. Introduction: Linear Programming deals with the optimization (max. or min.) of a function of variables, known as ‘objective function’,
Linear Programming Problem
What is GAMS?. While they are not NLP solvers, per se, attention should be given to modeling languages like: GAMS- AIMMS-
Assignment (6) Simplex Method for solving LP problems with two variables.
LECTURE 14 Minimization Two Phase method by Dr. Arshad zaheer
Chapter 5 LP formulations. LP formulations of four basic problem Resource allocation problem Transportation problem Feed mix problem Joint products problem.
BA 452 Lesson A.2 Solving Linear Programs 1 1ReadingsReadings Chapter 2 An Introduction to Linear Programming.
SENSITIVITY ANALYSIS.
SOLVING LINEAR PROGRAMS USING EXCEL Dr. Ron Lembke.
Advanced GAMS 1. Good Modeling Practices 2. Fixing Misbehaving Models 3. Linking GAMS 4. Advanced GAMS Syntax.
LP EXAMPLES.
Linear Programming Using the Excel Solver
Managerial Decision Modeling with Spreadsheets
Good modeling practices AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous lab.
GAMSCHK and GAMS Documentation AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl; Improved upon by many previous.
Comparative Analysis Multiple Submissions vs. Loops AGEC 641 Lab, Fall 2010 Mario Andres Fernandez Based on material written by Gillig and McCarl; Improved.
GAMS/GAMSIDE AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl and improved upon by previous lab instructors.
Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl; Improved upon by many previous.
Power of GAMS AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous lab instructors.
QM B Linear Programming
1 Linear Programming Using the software that comes with the book.
Linear Programming Econ Outline  Review the basic concepts of Linear Programming  Illustrate some problems which can be solved by linear programming.
1 1 Slide LINEAR PROGRAMMING Introduction to Sensitivity Analysis Professor Ahmadi.
Computational Methods for Management and Economics Carla Gomes Module 4 Displaying and Solving LP Models on a Spreadsheet.
QM B Lego Simplex. Scenario You manufacture tables and chairs. Tables and chairs are manufactured from small and large bricks. Small brick Large brick.
Spreadsheet Modeling & Decision Analysis:
Linear Programming Example 2 Alternate Optimal Solutions.
COMPREHENSIVE Excel Tutorial 10 Performing What-If Analyses.
Introduction to Mathematical Programming OR/MA 504 Chapter 3.
Chapter 19 Linear Programming McGraw-Hill/Irwin
Linear Programming Chapter 13 Supplement.
Special Conditions in LP Models (sambungan BAB 1)
Linear Programming: Basic Concepts
Managerial Decision Making and Problem Solving
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 15.
Duality Theory LI Xiaolei.
1 1 Slide © 2000 South-Western College Publishing/ITP Slides Prepared by JOHN LOUCKS.
Kerimcan OzcanMNGT 379 Operations Research1 Linear Programming: The Simplex Method Chapter 5.
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
MIS 463: Decision Support Systems for Business Review of Linear Programming and Applications Aslı Sencer.
Chapter 19: The Solver Re-Visited Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
1 1 Slide © 2008 Thomson South-Western. All Rights Reserved © 2011 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or.
A LINEAR PROGRAMMING PROBLEM HAS LINEAR OBJECTIVE FUNCTION AND LINEAR CONSTRAINT AND VARIABLES THAT ARE RESTRICTED TO NON-NEGATIVE VALUES. 1. -X 1 +2X.
1 1 Slide © 2005 Thomson/South-Western Linear Programming: The Simplex Method n An Overview of the Simplex Method n Standard Form n Tableau Form n Setting.
Chapter 4 Linear Programming: The Simplex Method
Lab 3 Solver Add-In In Excel ► Lab 2 Review ► Solver Add-in Introduction ► Practice Solver following Instructor » Saferly Inc.
Simplex Method for solving LP problems with two variables.
Spreadsheet Modeling & Decision Analysis A Practical Introduction to Management Science 5 th edition Cliff T. Ragsdale.
LINEAR PROGRAMMING.
1 Optimization Techniques Constrained Optimization by Linear Programming updated NTU SY-521-N SMU EMIS 5300/7300 Systems Analysis Methods Dr.
LINEAR PROGRAMMING 3.4 Learning goals represent constraints by equations or inequalities, and by systems of equations and/or inequalities, and interpret.
Chapter 4 The Simplex Algorithm and Goal Programming
Appendix A with Woodruff Edits Linear Programming Using the Excel Solver Copyright © 2010 by The McGraw-Hill Companies, Inc. All rights reserved.McGraw-Hill/Irwin.
Solver Feature Excel’s KY San Jose State University Engineering 10.
Lecture 5 Good modeling Chengcheng Fei 2017 Fall
Lecture 7 GAMS Check Chengcheng Fei 2017 Fall
Lecture 4 Power of GAMS Chengcheng Fei 2017 Fall
Excel Solver.
MAN 305 OPERATIONS RESEARCH II Week 4 –Sensitivity Analysis with Spreadsheets DR. KAZIM BARIŞ ATICI.
Chapter 4 Linear Programming: The Simplex Method
Lecture 8 Exam model flaws
Lecture 6 Conditionals, Subsets and Tuples in GAMS
Linear Programming SIMPLEX METHOD.
Chapter 4 The Simplex Algorithm
Lecture 2 General Problem
Presentation transcript:

Examining a model for Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous lab instructors. Special thanks to Yuquan “Wolfgang” Zhang

Maximization RegularRufflesBBQ Objt Available("Capacity")111<=10000 Available("Labor") <=0 1, >=0 A company uses two resources to produce three products

SET Process Types of production Processes / Regular, Ruffles, BBQ / Resource Types of Resources / Capacity,Labor / ; PARAMETERS Price(Process) PRODUCT PRICES BY Process / Regular 1.2, Ruffles 1.7, BBQ 2 / ProdCost(Process) COST BY Process / Regular 0, Ruffles 0, BBQ 0 / ResorAvail(Resource) Resource AVAILABLITY / Capacity 10000, Labor 0 / ; TABLE ResourUse(Resource,Process) Resource USAGE Regular Ruffles BBQ Capacity Labor ; VARIABLES Profit TOtal Profit ; POSITIVE VARIABLES Production(Process) Items Produced by Process; EQUATIONS Objt Objective Function ( Profit ) Available(Resource) Resources Available; Objt.. Profit =E= SUM(Process,(Price(Process)-ProdCost(Process))* Production(Process)); Available(Resource).. SUM(Process,RESOURUSE(Resource,Process)*Production(Process)) =L= ResorAvail(Resource); MODEL ResAlloc /ALL/; SOLVE ResAlloc USING LP MAXIMIZING Profit;

Now labor has cost and limits Maximization RegularRufflesBBQ Objt Available("Capacity")111<=10000 Available("Labor") <=0 Purchase Limit (“Maximum”)8<=600 Purchase Limit (“Minimum”)8>=320 1, >=0

Setting up GAMS. Lets take the old resource allocation problem and expand by adding a buying possibility for resources. Objt.. Profit =E= SUM(Process,(PRICE(Process)- PRODCOST(Process))* PRODUCTION(Process)) - SUM(Resource,BuyResource(Resource)*BuyTerms(Resource,“Cost”)) ; Available(Resource).. SUM(Process,ResourUse(Resource,Process)*PRODUCTION(Process)) =L= RESORAVAIL(Resource) + BuyResource(Resource)*BuyTerms(Resource,“Amount_Per_Unit"); PurchaseLimit(Resource,MinMax)$BuyTerms(Resource,“Cost").. Sign(MinMax)*BuyResource(Resource)*BuyTerms(Resource,"Amount_Per_Unit") =L= Sign(MinMax)*BuyTerms(Resource,MinMax) ;

SET Process Types of production Processes / Regular, Ruffles, BBQ / Resource Types of Resources / Capacity,Labor / ; PARAMETERS Price(Process) PRODUCT PRICES BY Process / Regular 1.2, Ruffles 1.7, BBQ 2 / ProdCost(Process) COST BY Process / Regular 0, Ruffles 0, BBQ 0 / ResorAvail(Resource) Resource AVAILABLITY / Capacity 10000, Labor 0 / ; TABLE ResourUse(Resource,Process) Resource USAGE Regular Ruffles BBQ Capacity Labor ; SET Terms Resource purchase Terms / Cost, Amount_per_unit, Maximum, Minimum / MinMax(Terms) Min and max subset of Terms / Maximum, Minimum / ; TABLE BuyTerms(Resource,Terms) Resource purchase Terms Cost Amount_per_unit Maximum Minimum Capacity Labor ; PARAMETER Sign(MinMax) Sign to use in limit equation/ Maximum 1, Minimum –1 / ; VARIABLES Profit Total Profit ; POSITIVE VARIABLES Production(Process) Items Produced by Process BuyResource(Resource) Resources purchased ; EQUATIONS Objt Objective Function ( Profit ) Available(Resource) Resources Available PurchaseLimit(Resource,MinMax) Limits on Resource for purchase; Objt.. Profit =E= SUM(Process,(Price(Process)-ProdCost(Process))* Production(Process)) - SUM(Resource,BuyResource(Resource)*BuyTerms(Resource,"Cost")) ; Available(Resource).. SUM(Process,RESOURUSE(Resource,Process)*Production(Process)) =L= ResorAvail(Resource) + BuyResource(Resource)*BuyTerms(Resource,"Amount_per_unit"); PurchaseLimit(Resource,MinMax)$BuyTerms(Resource,"cost").. Sign(MinMax)*BuyResource(Resource)*BuyTerms(Resource,"Amount_per_unit") =L= Sign(MinMax)*BuyTerms(Resource,MinMax); MODEL ResAlloc /ALL/; SOLVE ResAlloc USING LP MAXIMIZING Profit;

SET Terms Resource purchase Terms /Cost, Amount_per_unit, Maximum, Minimum / MinMax(Terms) min max subset of Terms / Maximum, Minimum / ; TABLE BuyTerms(Resource,Terms) Resource purchase Terms Cost Amount_per_unit Maximum Minimum Capacity Labor ; PARAMETER Sign(MinMax) Sign to use in limit equation / Maximum 1, Minimum –1 / ; POSITIVE VARIABLES BuyResource(Resource) Resources purchased ; EQUATIONS Objt Objective Function (Profit) Available(Resource) Resources Available PurchaseLimit(Resource,MinMax) Limits on Resource purchase; Dissecting Revised Resource Allocation Problem Basics of revision 1.Add a purchase variable 2.Define a purchase limit constraint

Objt.. Profit =E= SUM(Process,(Price(Process)- ProdCost(Process))* Production(Process)) - SUM(Resource,BuyResource(Resource)*BuyTerms(Resource,"Cost")); Available(Resource).. SUM(Process,ResourUse(Resource,Process)*Production(Process)) =L= ResorAvail(Resource) + BuyResource(Resource)*BuyTerms(Resource,"Amount_per_unit"); PurchaseLimit(Resource,MinMax)$BuyTerms(Resource,"cost").. Sign(MinMax)*BuyResource(Resource)*BuyTerms(Resource,"Amount_per_u nit") =L= Sign(MinMax)*BuyTerms(Resource,MinMax); Basics of Revision 3.Add term to objective function with cost 4.Add term to Resource Availability allowing purchase 5.Add terms to constrain limiting purchase imposing min and max 6.Add data giving cost, per unit amount, min and max

SET Terms Resource purchase Terms / Cost, Amount_per_unit, Maximum, Minimum / MinMax(Terms) Min and max subset of Terms / Maximum, Minimum / ; TABLE BuyTerms(Resource,Terms) Resource purchase Terms Cost Amount_per_unit Maximum Minimum Capacity Labor ; PARAMETER Sign(MinMax) Sign to use in limit equation / Maximum 1, Minimum –1 / ; POSITIVE VARIABLES BuyResource(Resource) Resources purchased ; EQUATIONS Objt Objective Function ( Profit ) Available(Resource) Resources Available PurchaseLimit(Resource,MinMax) Limits on Resource purchase; Dissecting Revised Resource Allocation Problem Tricks in revision 1.Add a conditional to the purchase limit constraint to only generate if there is a non zero cost, don’t need this elsewhere

Objt.. Profit =E= SUM(Process,(Price(Process)- ProdCost(Process))* Production(Process)) - SUM(Resource,BuyResource(Resource)*BuyTerms(Resource,"Cost")) ; Available(Resource).. SUM(Process,ResourUse(Resource,Process)*Production(Process)) =L= ResorAvail(Resource) + BuyResource(Resource)*BuyTerms(Resource,"Amount_per_unit"); PurchaseLimit(Resource,MinMax) $BuyTerms(Resource,"cost").. Sign(MinMax)*BuyResource(Resource)*BuyTerms(Resource,"Amount_pe r_unit") =L= Sign(MinMax)*BuyTerms(Resource,MinMax); 1.Add a parameter called sign that puts a different sign on limit depending on whether the constraint is min or max (multiplying through by –1 for min).

After setting up the LP problem, how to assure that it is transformed to a GAMS formulation correctly? Objt.. Profit =E= SUM(Process,(PRICE(Process)-PRODCOST(Process))* PRODUCTION(Process)) - SUM(Resource,BuyResource(Resource)*BuyTerms(Resource,“Cost”)) ; Available(Resource).. SUM(Process,ResourUse(Resource,Process)*PRODUCTION(Process)) =L= RESORAVAIL(Resource) + BuyResource(Resource)*BuyTerms(Resource,“Amount_Per_Unit"); PurchaseLimit(Resource, MinMax)$BuyTerms(resource,"cost").. Sign(MinMax)*BuyResource(Resource)*BuyTerms(Resource,"Amount_Per_Unit") =L= Sign(MinMax)*BuyTerms(Resource, MinMax) ; RegularRufflesBBQ Objt Available("Capacity")111<=10000 Available("Labor") <=0 Purchase Limit (“Maximum”)8<=600 Purchase Limit (“Minimum”)8>=320 1, >=0

Two ways to look at your model structure.  LIMROW and LIMCOL options  GAMSCHK Using LIMROW and LIMCOL options MODEL ResAlloc /All/ ; OPTION LIMROW =10; OPTION LIMCOL =10; SOLVE ResAlloc USING LP MAXIMATION Profit ;

OPTION LIMROW = 10;

OPTION LIMROW = 10

This non-negativity is already specified in the variable specification step

An alternative way to check the model structure is to use GAMSCHK  for examining the model structure and solutions.  DISPLAYCR: Listing selected equations and/or variables  PICTURE: Generating schematics on location of coefficients by sign and magnitude on an individual equation/variable basis  BLOCKPIC: Generating a whole model summary  POSTOPT: Debugging unrealistic optimal solutions

Here are steps to run GAMSCHK. Step 1:Insert a command line OPTION LP = GAMSCHK ; for LP problem or OPTION NLP = GAMSCHK ; for NLP problem orOPTION MIP = GAMSCHK ; for MIP problem in the model right before SOLVE Steps to run GAMS CHECK

Step 2: Create a new file with extension *.gck that has the same corresponding name as the program file. If your program file is called chipprob.gms, then make a new file called chipprob.gck

To create a new file, go to the FILE menu and use the NEW option. You will then get a file called untitled with an empty screen. Then save your program as chipprob.gck using the file SAVE option.

As illustration let’s mess up the model. Here are two alternative data input tables. Which one is right? Alternative A What is the meaning of a positive 64 in the Objt? Alternative B What is the meaning of a negative 64 in the Objt?

DISPLAYCR mirrors LIMROW and LIMCOL, but allows to select specific items to be displayed. A B

A

B

A

B

PICTURE looks at magnitude, sign and location of coefficients.

Which one is right, A or B? B A

BLOCKPIC is used to look at the whole model summary. A Is there anything wrong with this BLOCKPIC?

B BLOCKPIC is used to look at the whole model summary.

POSTOPT : used to debug unrealistic solutions. Row Summing : used to reconstruct equation activity. A Is there any wrong with this accounting? Revise maximum labor hours from 600 hours to 1200 hours

A

B Is this accounting reasonable?

B

A POSTOPT : Budgeting is use to reconstruct reduced costs. Is this accounting reasonable, (  i U i A ij – C j = 0 )? Why X ij = 0?

B Is this accounting reasonable, (S i U i A ij – C j = 0 )? Why X ij = 0?