170 likes | 295 Views
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
E N D
Formulation of a General ProblemAGEC 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
Simple Problem Variable Specification Equation Specification Model Statement Solve Statement
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
STEPS • SET definitions • Data Entry • Variable Specification • Equation Specification a) Declaration b) Algebraic structure 5. Model Statement 6. Solve Statement
SET Definition Algebra: subscripts GAMS: sets SET ItemNameoptional explanatory text / element1optional explanatory text element2 optional explanatory text /;
SET Definition SETS ItemName optional explanatory text for item / Element1optional text, Element2optional text /;
Data Entry Scalar Parameters Tables
SCALAR For items that are not set dependent SCALAR ItemNameoptional text /value/; SCALAR LandAvailableTotal Land /100/; SCALAR S LandAvailable /100/ Pricecorn1992 price per bushel /2.2/;
PARAMETER Basic format PARAMETER ItemName(setdependency) / element1associated value, element2 associated value /;
TABLE Basic format TABLE ItemName(set1, set2) optional text set2elem1 set2elem2 set1elem1 value11 value21 set1elem2value21 value22 ;
Direct Assignment Basic format PARAMETER 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)) ; Summation
Variable Declarations Basic format VARIABLE VarName1(set-dependency)optional text VarName2(set-dependency)optional text ;
Equation Declarations Basic format EQUATION EquName1(set-dependency)optional text EquName2(set-dependency)optional text ;
Equation Declarations General Structure: EquationName(Set-Dependency).. LHSEquationRelationType ( =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.