examining a model for flaws agec 641 lab, fall 2011 mario andres fernandez

35
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

Upload: reidar

Post on 22-Feb-2016

34 views

Category:

Documents


0 download

DESCRIPTION

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. A company uses two resources to produce three products. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

Examining a model for Flaws

AGEC 641 Lab, Fall 2011Mario Andres Fernandez

Based on material written by Gillig and McCarl. Improved upon by many previous lab instructors. Special thanks to Yuquan “Wolfgang” Zhang

Page 2: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

Maximization Regular Ruffles BBQ Objt 1.2 1.7 2 Available("Capacity") 1 1 1 <= 10000Available("Labor") 0.05 0.08 0.1 <= 0 1, 1, 1, >= 0

A company uses two resources to produce three products

Page 3: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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 1 1 1Labor 0.05 0.08 0.10 ;

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;

Page 4: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

Now labor has cost and limits

Maximization Regular Ruffles BBQ Objt 1.2 1.7 2 Available("Capacity") 1 1 1 <= 10000Available("Labor") 0.05 0.08 0.1 <= 0Purchase Limit (“Maximum”) 8 <= 600Purchase Limit (“Minimum”) 8 >= 320 1, 1, 1, >= 0

Page 5: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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) ;

Page 6: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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 1 1 1Labor 0.05 0.08 0.10 ;

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 64 8 600 320;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;

Page 7: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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 MinimumCapacity

Labor 64 8 600 320;PARAMETER Sign(MinMax) Sign to use in limit equation

/ Maximum 1, Minimum –1 / ;

POSITIVE VARIABLES BuyResource(Resource) Resources purchased ;EQUATIONSObjt Objective Function (Profit)Available(Resource) Resources AvailablePurchaseLimit(Resource,MinMax) Limits on Resource purchase;

Dissecting Revised Resource Allocation Problem

Basics of revision1. Add a purchase variable2. Define a purchase limit constraint

Page 8: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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);

Basics of Revision3. Add term to objective function with cost4. Add term to Resource Availability allowing purchase5. Add terms to constrain limiting purchase imposing min and max6. Add data giving cost, per unit amount, min and max

Page 9: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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 MinimumCapacityLabor 64 8 600 320;

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 revision1. Add a conditional to the purchase limit constraint to only generate if there is a

non zero cost, don’t need this elsewhere

Page 10: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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);

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).

Page 11: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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) ;

Regular Ruffles BBQ

Objt 1.2 1.7 2

Available("Capacity") 1 1 1 <= 10000

Available("Labor") 0.05 0.08 0.1 <= 0

Purchase Limit (“Maximum”) 8 <= 600

Purchase Limit (“Minimum”) 8 >= 320

1, 1, 1, >= 0

Page 12: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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 ;

Page 13: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

OPTION LIMROW = 10;

Page 14: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

OPTION LIMROW = 10

Page 15: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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

Page 16: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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

Page 17: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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

or OPTION MIP = GAMSCHK ; for MIP problem

in the model right before SOLVE

Steps to run GAMS CHECK

Page 18: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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

Page 19: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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.

Page 20: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

As illustration let’s mess up the model. Here are two alternative data input tables. Which one is right?

Alternative AWhat is the meaning of a positive 64 in the Objt?

Alternative BWhat is the meaning of a negative 64 in the Objt?

Page 21: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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

A B

Page 22: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

A

Page 23: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

B

Page 24: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

A

Page 25: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

B

Page 26: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

PICTURE looks atmagnitude, sign and location of coefficients.

Page 27: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

Which one is right, A or B?

B A

Page 28: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

BLOCKPIC is used to look at the whole model summary.

A

Is there anything wrong with this BLOCKPIC?

Page 29: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

B

BLOCKPIC is used to look at the whole model summary.

Page 30: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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

Page 31: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

A

Page 32: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

B

Is this accounting reasonable?

Page 33: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

B

Page 34: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

A POSTOPT : Budgeting is use to reconstruct reduced costs.

Is this accounting reasonable,(SiUiAij – Cj = 0 )? Why Xij = 0?

Page 35: Examining a model for  Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

B

Is this accounting reasonable,(SiUiAij – Cj = 0 )? Why Xij = 0?