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
![Page 1: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/1.jpg)
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
![Page 2: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/2.jpg)
Simple Problem
Variable Specification
Equation Specification
Model Statement
Solve Statement
![Page 3: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/3.jpg)
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
![Page 4: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/4.jpg)
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
![Page 5: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/5.jpg)
STEPS1. SET definitions2. Data Entry3. Variable Specification4. Equation Specification
a) Declarationb) Algebraic structure
5. Model Statement6. Solve Statement
![Page 6: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/6.jpg)
SET DefinitionAlgebra: subscripts GAMS: sets SET ItemName optional explanatory text / element1 optional explanatory text element2 optional explanatory text /;
![Page 7: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/7.jpg)
SET Definition
SETS ItemName optional explanatory text for item / Element1 optional text, Element2 optional text /;
![Page 8: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/8.jpg)
Data Entry
Scalar
Parameters
Tables
![Page 9: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/9.jpg)
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/;
![Page 10: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/10.jpg)
PARAMETER Basic format PARAMETER ItemName(setdependency) / element1 associated value, element2 associated value /;
![Page 11: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/11.jpg)
TABLEBasic formatTABLE ItemName(set1, set2) optional text
set2elem1 set2elem2set1elem1 value11 value21set1elem2 value21 value22 ;
![Page 12: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/12.jpg)
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) ;
![Page 13: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/13.jpg)
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
![Page 14: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/14.jpg)
Variable DeclarationsBasic formatVARIABLE VarName1(set-dependency) optional text
VarName2(set-dependency) optional text ;
![Page 15: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/15.jpg)
Equation DeclarationsBasic formatEQUATION EquName1(set-dependency) optional text
EquName2(set-dependency) optional text ;
![Page 16: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/16.jpg)
Equation DeclarationsGeneral Structure: EquationName(Set-Dependency)..LHS EquationRelationType ( =e=, =l=, =g= ) RHS
![Page 17: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez](https://reader034.vdocuments.site/reader034/viewer/2022051821/5681666d550346895dda0a80/html5/thumbnails/17.jpg)
Solution Reports
Shadow price: marginal values of resources.
Reduced costs: marginal cost if a non-basic variable is forced to enter the solutions.