Presentation is loading. Please wait.

Presentation is loading. Please wait.

Power of GAMS AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous lab instructors.

Similar presentations


Presentation on theme: "Power of GAMS AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous lab instructors."— Presentation transcript:

1 Power of GAMS 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

2 Power of GAMS Algebraic Modeling  Context Changes  Expandability of Models  Adding Conditionals Adding Report Writing/Self Documenting Nature Small to Large Model Development Model Library Use by Others

3 Context Changes The same algebraic model can be used in multiple contexts often with the same or very similar structure. SETS Process Production process /CornCorn production WheatWheat production Cotton Cotton production / ResourceResource item used /LandLand used by process Labor Labor used by process/; SETS Process Production process /MakeChair Chair production MakeTable Table production MakeLamp Lamp production / ResourceResource item used /PlantCap Production Capacity Labor Labor used by process/;

4 Context Changes One has to revise data and their set elements for consistency; yet, other structures remain TABLE ResourceUse(Resource,Process) Resource used CornWheatCotton Land 1 1 1 Labor 6 4 8 ; PARAMETERS Revenue(Process) Revenues from process / Corn 109, Wheat 90, Cotton 115 / ResourceAvailable(Resource) Resource availability / Land 100, Labor 500 / ; TABLE ResourceUse(Resource,Process) Resource used MakeChair MakeTable MakeLamp PlantCap 2 3 1.1 Labor 1 2 0.5 ; PARAMETERS Revenue(Process) Revenues from process / MakeChair 11, MakeTable 10, MakeLamp 12/ ResourceAvailable(Resource) Resource availability / PlantCap 12, Labor 5 / ;

5 Crop production problem

6

7 SETS ProcessProduction process /CornCorn production WheatWheat production CottonCotton production Soybeans Soybeans production / ResourceResource item used /LandLand used by process LaborLabor used by process/ ; Instead of growing 3 crops, now a farmer also wants to grow soybeans. One needs only to modify an element in PROCESS set, resource usage data, and revenues. Expand the Scope

8 Other data and the model structure remains the same TABLE ResourceUse(Resource,Process) Resource used Corn Wheat Cotton Soybeans Land 1 1 1 1 Labor 6 4 8 4 ; PARAMETERS Revenue(Process) Revenues from process production / Corn 109 Wheat 90 Cotton 115 Soybeans 95 / ResourceAvailable(Resource) Resource availability / Land 100 Labor 500 / ; Expand the Scope (cont)

9 PARAMETERS Revenue(Process) Revenues from process production / Corn 109 Wheat 90 Cotton 115 Soybeans 95 / ResourceAvailable(Resource) Resource availability / Land 100 Labor 500 / MinLand(Process) Minimum land requirement / Corn 0 Wheat 10 Cotton 0 Soybeans 0 / ; If wheat is used for farmer consumption, it must be grown in at least 10 units (acres). Modification includes adding data on minimum land use, and equation specification on minimum land use. Augmenting Existing Models

10 EQUATIONS Objective Maximize farm income ResourceEq(Resource) Resource constraint MinLandReq(Process) Minimum land requirement; MinLandReq(Process).. ResourceUse(“Land”, Process)*Production(Process) =G= MinLand(Process); Other data and the model structure remains the same Augmenting Existing Models (cont)

11 Self-Documenting Nature Can you figure out what context the example below is from?

12 Self-Documenting Nature One can include comments in the code by Using * in the first character position. The remaining characters in the line to be ignored but printed on the output file. Setting off by $ONTEXT and $OFFTEXT.

13 Small to Large Modeling GAMS expandability allows the same model structure, calculations, and report writing to be used with SETS with few elements vs. SETS with many items. Using a small data set allows up to examine the model structure and function easier and better. To expand, one uses SmallStocks(Stocks) = YES;

14 Model Library Modelers can find a number of sources of models from which they can expand or take insights.

15 Use By Others Create a “t” folder under the project directory When finished running data.gms, GAMS will save all the information in \t\a1 To solve the model, GAMS retrieves information saved in \t\a1. When finished solving mymodel.gms, GAMS will save all information including solutions in \t\a2 where it is ready to be used later

16

17

18 Set declarations Parameter declarations Variable declarations Equation declarations Specifying algebraic structure Model specifications Solve specifications SOLVE Ex USING LP MAXIMIZING Z; SOLVE Ex USING MIP MAXIMIZING Z; SOLVE Ex USING NLP MAXIMIZING Z; Data Model Non-linear and Other Problem Forms

19 Hands On 3 Fix errors in Handson3error.gms and send an electronic copy of the correct *.gms file. Hand in a hard copy of *.lst file (from “Solution Report” to the end).


Download ppt "Power of GAMS AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous lab instructors."

Similar presentations


Ads by Google