17
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

Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

  • Upload
    edythe

  • View
    39

  • Download
    0

Embed Size (px)

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 Presentation

Citation preview

Page 1: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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

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

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

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

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

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

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

Data Entry

Scalar

Parameters

Tables

Page 9: Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez

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

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

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

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

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

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

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

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

Solution Reports

Shadow price: marginal values of resources.

Reduced costs: marginal cost if a non-basic variable is forced to enter the solutions.