Examining a model for Flaws AGEC 641 Lab
Examining a model for Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and Mc. Carl. Improved upon by many previous lab instructors. Special thanks to Yuquan “Wolfgang” Zhang
A company uses two resources to produce three products Maximization Regular Ruffles BBQ Objt Available("Capacity") Available("Labor") 1. 2 1. 7 2 1 1 1 <= 10000 0. 05 0. 08 0. 1 <= 0 1, 1, >= 0
SET Process Resource Types of production Processes / Regular, Ruffles, BBQ / Types of Resources / Capacity, Labor / ; PARAMETERS Price(Process) PRODUCT PRICES BY Process / Regular 1. 2, Ruffles 1. 7, BBQ 2 / Prod. Cost(Process) COST BY Process / Regular 0, Ruffles 0, BBQ 0 / Resor. Avail(Resource) Resource AVAILABLITY / Capacity 10000, Labor 0 / ; TABLE Resour. Use(Resource, Process) Resource USAGE Regular Ruffles BBQ Capacity 1 1 1 Labor 0. 05 0. 08 0. 10 ; VARIABLES Profit TOtal Profit ; POSITIVE VARIABLES Production(Process) EQUATIONS Objt Available(Resource) Items Produced by Process; Objective Function ( Profit ) Resources Available; Objt. . Profit =E= SUM(Process, (Price(Process)-Prod. Cost(Process))* Production(Process)); Available(Resource). . SUM(Process, RESOURUSE(Resource, Process)*Production(Process)) =L= Resor. Avail(Resource); MODEL Res. Alloc /ALL/; SOLVE Res. Alloc USING LP MAXIMIZING Profit;
Now labor has cost and limits Maximization Regular Ruffles BBQ Objt 1. 2 1. 7 2 1 1 1 <= 10000 0. 05 0. 08 0. 1 <= 0 Purchase Limit (“Maximum”) 8 <= 600 Purchase Limit (“Minimum”) 8 >= 320 1, >= 0 Available("Capacity") Available("Labor") 1,
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, Buy. Resource(Resource)*Buy. Terms(Resource, “Cost”)) ; Available(Resource). . SUM(Process, Resour. Use(Resource, Process)*PRODUCTION(Process)) =L= RESORAVAIL(Resource) + Buy. Resource(Resource)*Buy. Terms(Resource, “Amount_Per_Unit"); Purchase. Limit(Resource, Min. Max)$Buy. Terms(Resource, “Cost"). . Sign(Min. Max)*Buy. Resource(Resource)*Buy. Terms(Resource, "Amount_Per_Uni t") =L= Sign(Min. Max)*Buy. Terms(Resource, Min. Max) ;
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 / Prod. Cost(Process) COST BY Process / Regular 0, Ruffles 0, BBQ 0 / Resor. Avail(Resource) Resource AVAILABLITY / Capacity 10000, Labor 0 / ; TABLE Resour. Use(Resource, Process) Resource USAGE Regular Ruffles BBQ Capacity 1 1 1 Labor 0. 05 0. 08 0. 10 ; SET Terms Resource purchase Terms / Cost, Amount_per_unit, Maximum, Minimum / Min. Max(Terms) Min and max subset of Terms / Maximum, Minimum / ; TABLE Buy. Terms(Resource, Terms) Resource purchase Terms Cost Amount_per_unit Maximum Minimum Capacity Labor 64 8 600 320; PARAMETER Sign(Min. Max) Sign to use in limit equation / Maximum 1, Minimum – 1 / ; VARIABLES Profit Total Profit ; POSITIVE VARIABLES Production(Process) Items Produced by Process Buy. Resource(Resource) Resources purchased ; EQUATIONS Objt Objective Function ( Profit ) Available(Resource) Resources Available Purchase. Limit(Resource, Min. Max) Limits on Resource for purchase; Objt. . Profit =E= SUM(Process, (Price(Process)-Prod. Cost(Process))* Production(Process)) - SUM(Resource, Buy. Resource(Resource)*Buy. Terms(Resource, "Cost")) ; Available(Resource). . SUM(Process, RESOURUSE(Resource, Process)*Production(Process)) =L= Resor. Avail(Resource) + Buy. Resource(Resource)*Buy. Terms(Resource, "Amount_per_unit"); Purchase. Limit(Resource, Min. Max)$Buy. Terms(Resource, "cost"). . Sign(Min. Max)*Buy. Resource(Resource)*Buy. Terms(Resource, "Amount_per_unit") =L= Sign(Min. Max)*Buy. Terms(Resource, Min. Max); MODEL Res. Alloc /ALL/; SOLVE Res. Alloc USING LP MAXIMIZING Profit;
Dissecting Revised Resource Allocation Problem SET Terms Resource purchase Terms /Cost, Amount_per_unit, Maximum, Minimum / Min. Max(Terms) min max subset of Terms / Maximum, Minimum / ; TABLE Buy. Terms(Resource, Terms) Resource purchase Terms Cost Amount_per_unit Maximum Minimum Capacity Labor 64 8 600 320; PARAMETER Sign(Min. Max) Sign to use in limit equation / Maximum 1, Minimum – 1 / ; POSITIVE VARIABLES Buy. Resource(Resource) Resources purchased ; EQUATIONS Objt Objective Function (Profit) Available(Resource) Resources Available Purchase. Limit(Resource, Min. Max) Limits on Resource purchase; Basics of revision 1. Add a purchase variable 2. Define a purchase limit constraint
Objt. . Profit =E= SUM(Process, (Price(Process)Prod. Cost(Process))* Production(Process)) - SUM(Resource, Buy. Resource(Resource)*Buy. Terms(Resource, "Cost")); Available(Resource). . SUM(Process, Resour. Use(Resource, Process)*Production(Process)) =L= Resor. Avail(Resource) + Buy. Resource(Resource)*Buy. Terms(Resource, "Amount_per_unit"); Purchase. Limit(Resource, Min. Max)$Buy. Terms(Resource, "cost"). . Sign(Min. Max)*Buy. Resource(Resource)*Buy. Terms(Resource, "Amount_per_un it") =L= Sign(Min. Max)*Buy. Terms(Resource, Min. Max); 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
Dissecting Revised Resource Allocation Problem SET Terms Resource purchase Terms / Cost, Amount_per_unit, Maximum, Minimum / Min. Max(Terms) Min and max subset of Terms / Maximum, Minimum / ; TABLE Buy. Terms(Resource, Terms) Resource purchase Terms Cost Amount_per_unit Maximum Minimum Capacity Labor 64 8 600 320; PARAMETER Sign(Min. Max) Sign to use in limit equation / Maximum 1, Minimum – 1 / ; POSITIVE VARIABLES Buy. Resource(Resource) Resources purchased ; EQUATIONS Objt Objective Function ( Profit ) Available(Resource) Resources Available Purchase. Limit(Resource, Min. Max) Limits on Resource purchase; 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)Prod. Cost(Process))* Production(Process)) - SUM(Resource, Buy. Resource(Resource)*Buy. Terms(Resource, "Cost")) ; Available(Resource). . SUM(Process, Resour. Use(Resource, Process)*Production(Process)) =L= Resor. Avail(Resource) + Buy. Resource(Resource)*Buy. Terms(Resource, "Amount_per_unit"); Purchase. Limit(Resource, Min. Max) $Buy. Terms(Resource, "cost"). . Sign(Min. Max)*Buy. Resource(Resource)*Buy. Terms(Resource, "Amount_pe r_unit") =L= Sign(Min. Max)*Buy. Terms(Resource, Min. Max); 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).
Regular Ruffles BBQ 1. 2 1. 7 2 1 1 1 <= 10000 0. 05 0. 08 0. 1 <= 0 Purchase Limit (“Maximum”) 8 <= 600 Purchase Limit (“Minimum”) 8 >= 320 1, >= 0 Objt Available("Capacity") Available("Labor") 1, 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, Buy. Resource(Resource)*Buy. Terms(Resource, “Cost”)) ; Available(Resource). . SUM(Process, Resour. Use(Resource, Process)*PRODUCTION(Process)) =L= RESORAVAIL(Resource) + Buy. Resource(Resource)*Buy. Terms(Resource, “Amount_Per_Unit"); Purchase. Limit(Resource, Min. Max)$Buy. Terms(resource, "cost"). . Sign(Min. Max)*Buy. Resource(Resource)*Buy. Terms(Resource, "Amount_Per_Unit") =L= Sign(Min. Max)*Buy. Terms(Resource, Min. Max) ;
Two ways to look at your model structure. § LIMROW and LIMCOL options § GAMSCHK Using LIMROW and LIMCOL options MODEL Res. Alloc /All/ ; OPTION LIMROW =10; OPTION LIMCOL =10; SOLVE Res. Alloc 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
Steps to run GAMS CHECK 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
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.
B Which one is right, A or B? A
A BLOCKPIC is used to look at the whole model summary. Is there anything wrong with this BLOCKPIC?
B BLOCKPIC is used to look at the whole model summary.
Revise maximum labor hours from 600 hours to 1200 hours A POSTOPT : used to debug unrealistic solutions. Row Summing : used to reconstruct equation activity. Is there any wrong with this accounting?
A
B Is this accounting reasonable?
B
A POSTOPT : Budgeting is use to reconstruct reduced costs. Is this accounting reasonable, (Si. Ui. Aij – Cj = 0 )? Why Xij = 0?
B Is this accounting reasonable, (Si. Ui. Aij – Cj = 0 )? Why Xij = 0?
- Slides: 35