lemon-project-template-glpk
view deps/glpk/examples/dbf/ForestMgt_Model_I_GIS_dbf.mod @ 9:33de93886c88
Import GLPK 4.47
author | Alpar Juttner <alpar@cs.elte.hu> |
---|---|
date | Sun, 06 Nov 2011 20:59:10 +0100 |
parents | |
children |
line source
1 # Model I Forest Estate Modelling using GLPK/MathProg
2 # Reading and writing dbf files
4 # by Noli Sicad --- nsicad@gmail.com
5 # 18 December 2009
7 # Forest Management 4th Edition
8 # by Lawrence Davis, K. Norman Johnson, Pete Bettinger, Theodore Howard
9 # Chapter 11 - Daniel Pickett
10 # http://warnell.forestry.uga.edu/Warnell/Bettinger/mgtbook/index.htm
12 # Model I Formulation
14 /* Note: This is not the full LP model mentioned in the book.
15 Some of the constraints are deliberately omitted in this model for the purpose of clarity.
17 The features of MathProg in this example are:
18 * reading and writing dbf from regular dbf files,
19 * reading dbf file (database of shapefile (stands.shp)) (e.g. area parameter),
20 * using the area data in the constraints and
21 * writing dbf file from result of LP model.
23 Model I - Harvest Scheduling formulation for Sustainable Forest Management (SFM)
25 Features are:
26 * Net Present Value for the objective function (Revenue - Cost)
27 * Harvest Constraints by period - Sustainable Yield per Period
28 * Even-Flow Constraint / Volume - Harvest Flow Constraint - Alpha (1-Apha)
29 * Even-Flow Constraint / Volume - Harvest Flow Constraint - Beta (1 +Beta)
30 * Forest / Land Constraint -- Total Area of the forest
31 * Forest Stand Constraint -- Individual stands
33 What is next? -- Forest Mgt Carbon Accounting for Climate Change
35 Note: The model file that the data containing in
36 the dbf files is public domain material (so it is compatible with the
37 GNU GPL) and data can be found in
38 http://warnell.forestry.uga.edu/Warnell/Bettinger/mgtbook/index.htm
40 # Noli Sicad --- nsicad@gmail.com
42 */
44 set G_STAND_TYPE; # A, B, C
46 set I_CULTURAL_PRES;
47 set J_MGT_YEAR;
49 param K_PERIOD;
50 param Forest_Cost{G_STAND_TYPE,I_CULTURAL_PRES, J_MGT_YEAR}; # cost
52 param Yield_Table_Vol{G_STAND_TYPE, I_CULTURAL_PRES, J_MGT_YEAR, 1..K_PERIOD} >= 0;
55 param Alpha >= 0;
56 param Beta >= 0;
58 param TCost_Table{G_STAND_TYPE, I_CULTURAL_PRES, J_MGT_YEAR, 1..K_PERIOD} >= 0;
60 param NetRev_Table{G_STAND_TYPE, I_CULTURAL_PRES, J_MGT_YEAR, 1..K_PERIOD};
63 var XForestLand{g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} >= 0;
66 #reading dbf tables
67 table tab IN "xBASE" "standtype.dbf": G_STAND_TYPE <- [STAND];
68 display G_STAND_TYPE;
71 table tab2 IN "xBASE" "cultural_pres.dbf": I_CULTURAL_PRES <- [CUL_PRES];
72 display I_CULTURAL_PRES;
74 table tab3 IN "xBASE" "mgt_year.dbf": J_MGT_YEAR <- [MGT_YEAR];
75 display J_MGT_YEAR;
77 /*
78 param Forest_Cost{G_STAND_TYPE,I_CULTURAL_PRES, J_MGT_YEAR} default 0; # cost
79 */
81 set S1, dimen 3;
82 table tab4 IN "xBASE" "Forest_Cost.dbf": S1 <- [STAND, CUL_PRES, MGT_YEAR],Forest_Cost ~FCOST;
83 display Forest_Cost;
85 set S2, dimen 4;
86 table tab5 IN "xBASE" "Yield_Table_Vol.dbf": S2 <- [STAND, CUL_PRES, MGT_YEAR, PERIOD],Yield_Table_Vol ~YIELD;
87 display Yield_Table_Vol;
89 set S3, dimen 4;
90 table tab5 IN "xBASE" "TCost_Table.dbf": S3 <- [STAND, CUL_PRES, MGT_YEAR, PERIOD],TCost_Table ~TCOST;
91 display TCost_Table;
94 set S4, dimen 4;
95 table tab5 IN "xBASE" "NetRev_Table.dbf": S4 <- [STAND, CUL_PRES, MGT_YEAR, PERIOD],NetRev_Table ~NETREV;
96 display NetRev_Table;
99 param MGT;
101 param Area_Stand_Indi{g in G_STAND_TYPE, m in 1..MGT} default 0;
103 set ST, dimen 2;
104 table tab5 IN "xBASE" "stands.dbf": ST <- [VEG_TYPE, MGT], Area_Stand_Indi ~ACRES;
105 display Area_Stand_Indi;
107 param Area_Stand_Type{g in G_STAND_TYPE}:= sum {m in 1..MGT } Area_Stand_Indi[g,m];
108 display Area_Stand_Type;
111 param Total_Area := sum {g in G_STAND_TYPE, m in 1..MGT } Area_Stand_Indi[g,m];
112 display Total_Area;
114 param Harvest_Min_Vol_Period;
117 var NetPresentValue;
119 # Objective function
120 maximize Net_Present_Value: NetPresentValue;
122 subject to NPV:
123 NetPresentValue = sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Forest_Cost[g,i,j] * XForestLand[g,i,j];
125 # Harvest Constraint by Period
126 subject to Harvest_Period_H {k in 1..K_PERIOD}:
127 sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j] >= Harvest_Min_Vol_Period;
130 #Even-Flow Constraint / Volume - Harvest Flow Constraint - Alpha
131 subject to Even_Flow_Constaints_Alpha {k in 6..K_PERIOD-1}:
132 (1 - Alpha) * sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j] -
133 sum {g in G_STAND_TYPE,i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k+1] * XForestLand[g,i,j] <= 0;
135 # Even-Flow Constraint / Volume - Harvest Flow Constraint - Beta
136 subject to Even_Flow_Constaints_Beta {k in 6..K_PERIOD-1}:
137 (1 + Beta) * sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j] -
138 sum {g in G_STAND_TYPE,i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k+1] * XForestLand[g,i,j] >= 0;
140 # Forest / Land Constraints
141 subject to Total_Area_Constraint:
142 sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} XForestLand[g,i,j] <= Total_Area;
143 display Total_Area;
145 # Forest / Land Constraints for A B C
146 subject to Area {g in G_STAND_TYPE}:
147 sum {i in I_CULTURAL_PRES,j in J_MGT_YEAR} XForestLand[g,i,j] = Area_Stand_Type[g];
151 solve;
152 #RESULT SECTION
153 printf '#################################\n';
154 printf 'Forest Management Model I - Noli Sicad\n';
155 printf '\n';
156 printf 'Net Present Value = %.2f\n', NetPresentValue;
157 printf '\n';
159 printf '\n';
160 printf 'Variables\n';
161 printf 'Stand_Type Age_Class Mgt_Presc Sign Value \n';
162 printf{g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR}:'%5s %10s %11s = %10.2f\n', g,i,j, XForestLand[g,i,j];
163 printf '\n';
165 printf 'Constraints\n';
166 printf 'Period Harvest Sign \n';
167 for {k in 1..K_PERIOD} {
168 printf '%5s %10.2f >= %.3f\n', k, sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j], Harvest_Min_Vol_Period;
169 }
171 # xbase (dbf) output
172 table Harvest{k in 1..K_PERIOD} OUT "xBASE" "HarvestArea1.dbf" "N(5)N(15,2)" : k ~ Period, (sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j]) ~ H_Area;
174 # xbase (dbf) read
175 set S, dimen 2;
176 table tab2 IN "xBASE" "HarvestArea1.dbf": S <- [Period, H_Area];
177 display S;
182 printf '\n';
183 printf 'Constraint\n';
184 printf 'Harvest Period\n';
185 printf 'Type AgeClass PrescMgt Period Value\n';
186 printf{g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR, k in 1..K_PERIOD}:'%5s %11s %11s %5s %10.2f\n', g,i,j, k, (Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j]);
189 printf 'Even_Flow_Constaint_Alpha (1-Alpha)\n';
190 printf 'Period Sign \n';
191 for {k in 6..K_PERIOD-1} {
192 printf "%s %10.2f <= %s\n", k, ((1 - Alpha) * sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k] * XForestLand[g,i,j] - sum {g in G_STAND_TYPE,i in I_CULTURAL_PRES, j in J_MGT_YEAR} Yield_Table_Vol[g,i,j,k+1] * XForestLand[g,i,j]),0;
193 }
194 printf '\n';
197 # Forest / Land Constraints
198 printf '\n';
199 printf 'Total Area Constraint\n';
200 printf 'Type AgeClass PrescMgt Value Sign Total_Area \n';
201 printf '%5s <= %.3f\n',sum {g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} XForestLand[g,i,j], Total_Area;
203 printf 'Area\n';
204 printf 'Area Value Sign Areas_Stand\n';
205 for {g in G_STAND_TYPE} {
206 printf '%5s %10.2f <= %.3f\n', g, sum {i in I_CULTURAL_PRES,j in J_MGT_YEAR} XForestLand[g,i,j], Area_Stand_Type[g];
207 }
210 #DATA SECTION
212 data;
214 # Most of the data has been moved to dbf format
216 param MGT:=31;
218 param K_PERIOD:= 7;
220 param Alpha:= 0.20;
221 param Beta:= 0.20;
223 param Harvest_Min_Vol_Period:= 12000;
225 end;