formulation of a general problem agec 641 lab, fall 2011 mario andres fernandez
DESCRIPTION
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 lab instructors. Special thanks to Yuquan “Wolfgang” Zhang. Simple Problem. Variable Specification Equation Specification - PowerPoint PPT PresentationTRANSCRIPT
Formulation of a General ProblemAGEC 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
Simple Problem
Variable Specification
Equation Specification
Model Statement
Solve Statement
What if we had much more data?
negativenonXXXlaborXXXlandXXXprofitXXXMax
CottonWheatCorn
CottonWheatCorn
CottonWheatCorn
CottonWheatCorn
0 , , 500*8 *4 *6
100 *115*90*109
iX
bX
bXts
XMax
i
i
i
i
,0
a
a ..
c
1,2,3i2i2
1,2,3i1i1
1,2,3ii
iX
jbXts
XMax
i
ji
i
,0
,a ..
c
1,2,3iij
1,2,3ii
GAMS and Algebra
• Suppose xi is defined with three elements
• Algebra:
• GAMS: z=SUM(i,x(i));– i: set in GAMS– Z: a scalar or variable– X(i): parameter or variable defined over i– The sum automatically treats all cases of i
i
i xxxx 321
STEPS1. SET definitions2. Data Entry3. Variable Specification4. Equation Specification
a) Declarationb) Algebraic structure
5. Model Statement6. Solve Statement
SET DefinitionAlgebra: subscripts GAMS: sets SET ItemName optional explanatory text / element1 optional explanatory text element2 optional explanatory text /;
SET Definition
SETS ItemName optional explanatory text for item / Element1 optional text, Element2 optional text /;
Data Entry
Scalar
Parameters
Tables
SCALAR
For items that are not set dependent
SCALAR ItemName optional text /value/;SCALAR LandAvailable Total Land /100/;
SCALAR SLandAvailable /100/Pricecorn 1992 price per bushel /2.2/;
PARAMETER Basic format PARAMETER ItemName(setdependency) / element1 associated value, element2 associated value /;
TABLEBasic formatTABLE ItemName(set1, set2) optional text
set2elem1 set2elem2set1elem1 value11 value21set1elem2 value21 value22 ;
Direct AssignmentBasic formatPARAMETER ItemName(set1, set2) optional text;PARAMETER ItemName(set1, set2) = expression;
Parameter CalcRevenue(crop) calculate revenues by crop ;
CalcRevenue(crop) = Revenue(crop)*Production.L(crop) ;
Parameter TotalRevenue calculate total revenue;TotalRevenue=sum(crop, revenue(crop)*Production(crop)) ;
j
jX
j i
jiX
Sum (index, names(index))Sum(j, X(j))
Sum(index1, sum(index2, names(index1, index2)))Or Sum(j, Sum(i, X(j, i))) Or Sum((j, i), X(j, i))
c
cc YX *Summation
Variable DeclarationsBasic formatVARIABLE VarName1(set-dependency) optional text
VarName2(set-dependency) optional text ;
Equation DeclarationsBasic formatEQUATION EquName1(set-dependency) optional text
EquName2(set-dependency) optional text ;
Equation DeclarationsGeneral Structure: EquationName(Set-Dependency)..LHS EquationRelationType ( =e=, =l=, =g= ) RHS
Solution Reports
Shadow price: marginal values of resources.
Reduced costs: marginal cost if a non-basic variable is forced to enter the solutions.