COIN-OR::LEMON - Graph Library

source: glpk-cmake/examples/dbf/ForestMgt_Model_I_GIS_dbf.mod

Last change on this file was 1:c445c931472f, checked in by Alpar Juttner <alpar@…>, 14 years ago

Import glpk-4.45

  • Generated files and doc/notes are removed
File size: 7.3 KB
Line 
1#  Model I Forest Estate Modelling using GLPK/MathProg
2#  Reading and writing dbf files
3
4#  by Noli Sicad --- nsicad@gmail.com
5# 18 December 2009
6
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
11
12#  Model I Formulation
13
14/*  Note: This is not the full LP model mentioned in the book.
15Some of the constraints are deliberately omitted in this model for the purpose of clarity.
16
17The 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.
22
23Model I - Harvest Scheduling formulation for Sustainable Forest Management (SFM)
24
25Features 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
32
33What is next? -- Forest Mgt Carbon Accounting for Climate Change
34
35Note: The model file that the data containing in
36the dbf files is public domain material (so it is compatible with the
37GNU GPL) and data can be found in
38http://warnell.forestry.uga.edu/Warnell/Bettinger/mgtbook/index.htm
39
40# Noli Sicad --- nsicad@gmail.com
41
42*/
43
44set G_STAND_TYPE; # A, B, C
45
46set I_CULTURAL_PRES;
47set J_MGT_YEAR;
48
49param K_PERIOD;
50param Forest_Cost{G_STAND_TYPE,I_CULTURAL_PRES, J_MGT_YEAR}; # cost
51
52param Yield_Table_Vol{G_STAND_TYPE, I_CULTURAL_PRES, J_MGT_YEAR, 1..K_PERIOD} >= 0;
53
54
55param Alpha >= 0;
56param Beta >= 0;
57
58param TCost_Table{G_STAND_TYPE, I_CULTURAL_PRES, J_MGT_YEAR, 1..K_PERIOD} >= 0;
59
60param NetRev_Table{G_STAND_TYPE, I_CULTURAL_PRES, J_MGT_YEAR, 1..K_PERIOD};
61
62
63var XForestLand{g in G_STAND_TYPE, i in I_CULTURAL_PRES, j in J_MGT_YEAR} >= 0;
64
65
66#reading dbf tables
67table tab IN "xBASE" "standtype.dbf": G_STAND_TYPE <- [STAND];
68display G_STAND_TYPE;
69
70
71table tab2 IN "xBASE" "cultural_pres.dbf": I_CULTURAL_PRES <- [CUL_PRES];
72display I_CULTURAL_PRES;
73
74table tab3 IN "xBASE" "mgt_year.dbf": J_MGT_YEAR <- [MGT_YEAR];
75display J_MGT_YEAR;
76
77/*
78param Forest_Cost{G_STAND_TYPE,I_CULTURAL_PRES, J_MGT_YEAR} default 0; # cost
79*/
80
81set S1, dimen 3;
82table tab4 IN "xBASE" "Forest_Cost.dbf": S1 <- [STAND, CUL_PRES, MGT_YEAR],Forest_Cost ~FCOST;
83display Forest_Cost;
84
85set S2, dimen 4;
86table tab5 IN "xBASE" "Yield_Table_Vol.dbf": S2 <- [STAND, CUL_PRES, MGT_YEAR, PERIOD],Yield_Table_Vol ~YIELD;
87display Yield_Table_Vol;
88
89set S3, dimen 4;
90table tab5 IN "xBASE" "TCost_Table.dbf": S3 <- [STAND, CUL_PRES, MGT_YEAR, PERIOD],TCost_Table ~TCOST;
91display TCost_Table;
92
93
94set S4, dimen 4;
95table tab5 IN "xBASE" "NetRev_Table.dbf": S4 <- [STAND, CUL_PRES, MGT_YEAR, PERIOD],NetRev_Table ~NETREV;
96display NetRev_Table;
97
98
99param MGT;
100
101param Area_Stand_Indi{g in G_STAND_TYPE, m in 1..MGT} default 0;
102
103set ST, dimen 2;
104table tab5 IN "xBASE" "stands.dbf": ST <- [VEG_TYPE, MGT], Area_Stand_Indi ~ACRES;
105display Area_Stand_Indi;
106
107param Area_Stand_Type{g in G_STAND_TYPE}:= sum {m in 1..MGT } Area_Stand_Indi[g,m];
108display Area_Stand_Type;
109
110
111param Total_Area := sum {g in G_STAND_TYPE, m in 1..MGT } Area_Stand_Indi[g,m];
112display Total_Area;
113
114param Harvest_Min_Vol_Period;
115
116
117var NetPresentValue;
118
119# Objective function
120maximize Net_Present_Value: NetPresentValue;
121
122subject 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];
124
125# Harvest Constraint by Period
126subject 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;
128   
129
130#Even-Flow Constraint / Volume - Harvest Flow Constraint - Alpha
131subject 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;
134
135# Even-Flow Constraint / Volume - Harvest Flow Constraint - Beta
136subject 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;
139   
140# Forest / Land Constraints
141subject 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;
143display Total_Area;   
144
145# Forest / Land Constraints for A B C
146subject 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];
148
149
150
151solve;
152#RESULT SECTION
153printf '#################################\n';
154printf 'Forest Management Model I - Noli Sicad\n';
155printf '\n';
156printf 'Net Present Value = %.2f\n', NetPresentValue;
157printf '\n';
158
159printf '\n';
160printf 'Variables\n';
161printf 'Stand_Type  Age_Class  Mgt_Presc  Sign Value \n';
162printf{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];
163printf '\n';
164
165printf 'Constraints\n';
166printf 'Period Harvest Sign \n';
167for {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   }
170
171# xbase (dbf) output
172table 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;
173
174# xbase (dbf) read
175set S, dimen 2;
176table tab2 IN "xBASE" "HarvestArea1.dbf": S <- [Period, H_Area];
177display S;
178
179
180
181
182printf '\n';
183printf 'Constraint\n';
184printf 'Harvest Period\n';
185printf 'Type AgeClass  PrescMgt Period    Value\n';
186printf{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]);
187
188
189printf 'Even_Flow_Constaint_Alpha (1-Alpha)\n';
190printf 'Period Sign \n';
191for {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  }
194printf '\n';
195
196
197# Forest / Land Constraints
198printf '\n'; 
199printf 'Total Area Constraint\n';
200printf 'Type AgeClass  PrescMgt  Value Sign Total_Area \n';
201printf '%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;
202
203printf 'Area\n';
204printf 'Area Value Sign Areas_Stand\n';
205for {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   }
208
209
210#DATA SECTION
211     
212data;
213
214# Most of the data has been moved to dbf format
215
216param MGT:=31;
217
218param K_PERIOD:= 7;
219
220param Alpha:= 0.20;
221param Beta:= 0.20;
222
223param Harvest_Min_Vol_Period:= 12000;
224
225end;
226
Note: See TracBrowser for help on using the repository browser.