Commit 9c830dc469332d39edf3e6953fcee998a36889b8

Authored by Eduardo Eloy
1 parent a42a9bab
Exists in Standardized

added REAME file

MODFIRE-Prototype/HOWTORUN.txt
... ... @@ -1,45 +0,0 @@
1   -Run through the make file.
2   -
3   -MainWithSpecific parameters:
4   -1st- Maximum Area Limit (50)
5   -2nd- Directory with data about forest (res)
6   -3rd- Minimum Border Lenght (50)
7   -4th- Single or Multi Criteria
8   -5th- Name of file with the UGs to be considered (in subregions folder)
9   -6th and onward- Choose the criterias to be optimized, if the 4th parameter is Single only the first criteria will be optimized
10   -
11   -0-Wood Yield
12   -1-Soil Loss
13   -2-Perc_r
14   -3-Biodiversity
15   -4-Cashflow
16   -5-Carbon Stock
17   -6-NPV
18   -7-Perc_rait
19   -8-R
20   -9-Rait
21   -10-Sbiom
22   -
23   -Example to optimize Wood Yield and Soil Loss in Paredes: MainWithSpecific 50 res 50 Multi Paredes 0 1
24   -
25   -By default the time limit for finding solutions is 8 hours (28800000 miliseconds)
26   -
27   -
28   -MainTime: Same as MainWithSpecific but the 4th parameter sets the time limit for finding solutions in miliseconds
29   -
30   -Example: MainTime 50 res 0 28800000 Paredes 0 1
31   -
32   -
33   -Output files Multi-Criteria:
34   -
35   -allSolutionPairs.csv:- UG/Presc pairs for every valid solution found
36   -outputPairsMulti.csv:- UG/Presc pairs for every pareto solution (determined by choco solver)
37   -nonPareto.csv:- Values of the optimizable criteria for every valid solution found
38   -pareto.csv:- Values of the optimizable criteria for every pareto solution found
39   -Times/resultsM:- UG/Presc pairs for every pareto solution along with associated values of objective criteria.
40   -
41   -
42   -Remove the ",end" collumn in the nonPareto and pareto files by running the cut -d, -f-[NUMBER OF CRITERIA] [FILENAME]
43   -
44   -
45   -
MODFIRE-Prototype/MANUAL
1   --Step 1: Necessary Setup Files
2   --The examples show a forest with only 4 MUs
3   -
4   -
5   --6 files need to be prepared in the following manner
6   -
7   -
8   -external_init.txt - This file serves to indicate how many Management Units exist in the forest, so each line should have a number to serve as an External identifier of each MU. There should be as many lines as there are MUs in the forest
9   -
10   -Each of these External IDs have an Internal ID which corresponds to the index of their row starting from 0
11   ------------------EXAMPLE:
12   -30
13   -201
14   -333
15   -335
16   --------------------------
17   -So they have the following Internal IDs
18   -----------------
19   -0
20   -1
21   -2
22   -3
23   -----------------
24   -
25   -
26   -area_init.txt - This file sets up the area of each MU.
27   ------------------Example:
28   -42.6017806736
29   -8.26386417601
30   -6.03153252031
31   -26.9439445316
32   -------------------------
33   -
34   -adj_init.txt - This file sets up the adjacencies of each MU each line should list the Internal IDs of the MUs adjacent to the respective MU separated by a comma.
35   -If the MU has no adjacent MUs the line should just have a -1
36   ------------------Example:
37   -1,2
38   -0
39   -0,1
40   --1
41   -------------------------
42   -FAZER DESENHO AQUI
43   -
44   -
45   -border_init.txt - This file sets up the lenght of the border of each adjacent MU, each line should list the lenght of the borders of each adjacency separated by a comma.
46   -If the MU has no adjacent MUs the should just have a -1
47   - -----------------Example:
48   -259,151
49   -490
50   -102,653
51   --1
52   -------------------------
53   -If borders aren't a factor is your data just put use 0s in place of real border values
54   -
55   -
56   -ugs_init.txt - This file sets up the Prescriptions associated with each MU, each line should list the IDs of the Prescriptions associated with each MU
57   ------------------Example:
58   -1,2,3
59   -19
60   -19,20,21
61   -500,501,502,503,500600,500601
62   -------------------------
63   -
64   -years_init.txt - This file sets up the relation between Prescriptions and the years where those Prescriptions have Harvest actions.
65   -Each line lists the years where the corresponding Prescription has Harvest actions separated by commas, if the MU has more than one Prescription then a "/" is followed by the next Prescription's harvest years. If a Prescription has no years of Harvest there should be a -1
66   -
67   -Before listing the years the line should have the Internal ID of the MU followed by a "|"
68   -
69   - -----------------Example:
70   -0|2026,2056,2066/2027,2049,2060/2028,2040,2052,2064
71   -1|2022,2032,2042
72   -2|2026,2046/2060/-1
73   -3|2052/2057/-1/2067/2052/2052
74   -------------------------
75   -
76   -
77   -Step 2: Criteria Files
78   -
79   -There can be a maximum of 10 optimizable criteria in the program represented by these files, these files are crit_file0-10.txt and their format is the same.
80   -
81   -Each line corresponds to an MU similarly to previous files and the contents are separated by commas, the contents are the values of the objective criteria associated with each Prescription of the respective MU
82   ------------------Example:
83   -34,30.99,3.363
84   -1568.630
85   -565.79,146,1692
86   -4966,6310,7,87,49,496
87   -------------------------
88   -
89   -
90   -
91   -Step 3: Running the software
92   -
93   -Further instructions can be found in the HOWTORUN.txt file
94   -
95   -In summary the software is run by typing "make" in the cmd, but the configuration parameters should be modified in the make file.
96   -
97   -Open up the makefile and in the label "make" modify the parameters
98   -
99   -
  1 +In the README file
... ...
MODFIRE-Prototype/README.md
  1 +# Forest Management
1 2  
2   -# Input Files format
  3 +The purpose of this implementation is to use Constraint Programming to find valid solutions for problems of forest management.
  4 +Here, Management Units (MUs) are associated with possible prescriptions which define which years the MUs are to be harvested.
  5 +But in any given year only 50ha of contiguous forest area can be harvested at once.
3 6  
4   -In general for every line in one of the files we assume a new Management Unit, a file with 10 lines would imply that there are 10 MUs, and since this has to be consistent then that means all 4 input files should have 10 lines.
5 7  
6   -## ugs_init
7   -In every line there is a list of integers separated by commas, each integer is a possible Prescription Value for the Management Unit the index of the line represents. So the integers on the first line of the file are the possible Prescription Value ids for the Management Unit with the internal id "1", and in the Constraint Variable array of the code (IntVar [ ] ugs) it is represented in the index 0 (1 - 1). The same goes for the rest of the files.
  8 +Therefore the implementation needs input defining:
8 9  
9   -## area_init
10   -Every line contains a float value which represents the Area Value of the respective MU.
  10 +1-The existing MUs in the forest
  11 +2-The area of each MU
  12 +3-The MUs adjacent to each MU
  13 +4-The border lenght of each adjacency between MUs
  14 +5-The IDs of the Prescriptions of each MU
  15 +6-Relative to each Prescription, the years where the Prescription defines that the MU should be harvested.
  16 +7-Relative to each Prescription, the rewards each Prescription gives for being applied.
11 17  
  18 +# Step 1: Necessary Setup Files
12 19  
13   -## graph_init
  20 +In general for every line in one of the files we assume a new Management Unit, a file with 4 lines would imply that there are 4 MUs, and since this has to be consistent then that means all input files should have 4 lines.
14 21  
15   -Every line contains a list of integers (or a single integer) separated by commas which correspond to the internal Management Unit id of the MUs adjacent to the MU the line represents.
  22 +6 files need to be prepared in the following manner
16 23  
17 24  
18   -## period_init
  25 +## external_init.txt
  26 +###- This file serves to indicate how many Management Units exist in the forest, so each line should have a number to serve as an External identifier of each MU. There should be as many lines as there are MUs in the forest
19 27  
20   -Every line contains lists of integers separated by commas. These lists themselves are separated by slashes.
21   -Every set of integers separated by the slashes correspond to a possible prescription value for the MU represented by the line. Therefore there should be as many of these sets of integers separated by slashes as there are Prescription Values in the "ugs_init" file.
  28 +Each of these External IDs have an Internal ID which corresponds to the index of their row starting from 0
  29 +-----------------EXAMPLE:
  30 +30
  31 +201
  32 +333
  33 +335
  34 +-------------------------
  35 +
  36 +So they have the following Internal IDs
  37 +----------------
  38 +0
  39 +1
  40 +2
  41 +3
  42 +----------------
  43 +
  44 +
  45 +## area_init.txt
  46 +###- This file sets up the area of each MU.
  47 +
  48 +-----------------Example:
  49 +42.60178
  50 +8.26
  51 +6.0315
  52 +26.94
  53 +------------------------
  54 +
  55 +## adj_init.txt
  56 +###- This file sets up the adjacencies of each MU each line should list the Internal IDs of the MUs adjacent to the respective MU separated by a comma. If the MU has no adjacent MUs the line should just have a -1
  57 +
  58 +-----------------Example:
  59 +1,2
  60 +0
  61 +0
  62 +-1
  63 +------------------------
  64 +So this forest might look like this:
  65 +Internal Ids: External Ids:
  66 +|2| |2|
  67 +|0| |3| |0| |3|
  68 +|1| |1|
22 69  
23   -These sets of integers and the possible prescription values share indexes, meaning that the first set of integers separated by commas in a line of the "period_init" file is related to the first prescription value in the "ugs_file" and so on.
24 70  
25   -The integers themselves then represent the years when, if this prescription values is applied, the MU will have Harvest Actions
  71 +##border_init.txt
  72 +###- This file sets up the lenght of the border of each adjacent MU, each line should list the lenght of the borders of each adjacency separated by a comma. If the MU has no adjacent MUs the should just have a -1
26 73  
27   -For example with the following files
  74 +-----------------Example:
  75 +259,151
  76 +490
  77 +102,653
  78 +-1
  79 +------------------------
28 80  
29   -ugs_init
  81 +If borders aren't a factor is your data just put use 0s in place of real border values
30 82  
  83 +
  84 +##ugs_init.txt
  85 +###- This file sets up the Prescriptions associated with each MU, each line should list the IDs of the Prescriptions associated with each MU
  86 +
  87 +-----------------Example:
31 88 1,2,3
  89 +19
  90 +19,20,21
  91 +500,501,502,503,500600,500601
  92 +------------------------
32 93  
33   -67
  94 +##years_init.txt
  95 +###- This file sets up the relation between Prescriptions and the years where those Prescriptions have Harvest actions.
  96 +### Each line lists the years where the corresponding Prescription has Harvest actions separated by commas, if the MU has more than one Prescription then a "/" is followed by the next Prescription's harvest years. If a Prescription has no years of Harvest there should be a -1
34 97  
35   -++++++++++++++
  98 +Before listing the years the line should have the Internal ID of the MU followed by a "|"
36 99  
37   -period_init
  100 + -----------------Example:
  101 +0|2026,2056,2066/2027,2049,2060/2028,2040,2052,2064
  102 +1|2022,2032,2042
  103 +2|2026,2046/2060/-1
  104 +3|2052/2057/-1/2067/2052/2052
  105 +------------------------
38 106  
39   -10,20/1,2/0
  107 +#Step 2: Criteria Files
40 108  
41   -0
  109 +There can be a maximum of 10 optimizable criteria in the program represented by these files, these files are crit_file0-10.txt and their format is the same.
  110 +
  111 +Each line corresponds to an MU similarly to previous files and the contents are separated by commas, the contents are the values of the objective criteria associated with each Prescription of the respective MU
  112 +-----------------Example:
  113 +34,30.99,3.363
  114 +1568.630
  115 +565.79,146,1692
  116 +4966,6310,7,87,49,496
  117 +------------------------
  118 +
  119 +#Step 3: Running the software
  120 +
  121 +The program is run through the make file and requires Java 11.
  122 +Open up the Makefile in this folder and modify the parameters of the "make" label, then run the "make" command in the terminal.
  123 +
  124 +## MainWithSpecific
  125 +The MainWithSpecific command is what should be run and its parameters can be changed in the following manner.
  126 +
  127 +The examples shown are related to the Vale de Sousa forest which was used in the MODFIRE project.
  128 +
  129 +## MainWithSpecific parameters:
  130 +1st- Maximum Area Limit (50)
  131 +2nd- Directory with data about forest (res)
  132 +3rd- Minimum Border Lenght (50)
  133 +4th- Single or Multi Criteria
  134 +5th- Name of file with the UGs to be considered (in subregions folder)
  135 +6th and onward- Choose the criterias to be optimized, if the 4th parameter is Single only the first criteria will be optimized
  136 +
  137 +0-Criteria0 (Wood Yield)
  138 +1-Criteria1 (Soil Loss)
  139 +2-Criteria2 (Perc_r)
  140 +3-Criteria3 (Biodiversity)
  141 +4-Criteria4 (Cashflow)
  142 +5-Criteria5 (Carbon Stock)
  143 +6-Criteria6 (NPV)
  144 +7-Criteria7 (Perc_rait)
  145 +8-Criteria8 (R)
  146 +9-Criteria9 (Rait)
  147 +10-Criteria10(Sbiom)
  148 +
  149 +## Example to optimize Wood Yield and Soil Loss in Paredes-> MainWithSpecific 50 res 50 Multi Paredes 0 1
  150 +
  151 +The program will try to find valid solutions for 8 hours (28800000 miliseconds) or until there's a memory error.
  152 +
  153 +## MainTime Paremeters
  154 +Same as MainWithSpecific but the 4th parameter sets the time limit for finding solutions in miliseconds
  155 +
  156 +Example: MainTime 50 res 50 28800000 Paredes 0 1
42 157  
43   -This means that the MU represented by the first line has 3 possible Prescriptions (1,2,3).
44 158  
45   -And that the first possible Prescription of this MU has a harvest action in the years 10, 20. The second possible one in the year 1, 2. And the third has no harvest actions (year 0)
  159 +#Step 4: Output files
  160 +In Multi Criteria optimization the following files are written to the Results folder:
  161 +Output files Multi-Criteria:
46 162  
47   -The MU in the second line only has 1 possible prescription and that prescription has no harvest actions
48 163  
  164 +allSolutionPairs.csv:- MU/Presc pairs for every valid solution found
  165 +outputPairsMulti.csv:- MU/Presc pairs for every pareto solution (determined by choco solver)
  166 +nonPareto.csv:- Values of the optimizable criteria for every valid solution found
  167 +pareto.csv:- Values of the optimizable criteria for every pareto solution found
  168 +pairCriteria.csv:- MU/Presc pairs for every pareto solution along with associated values of objective criteria.
49 169  
50 170  
  171 +In Single Criteria optimization the following file is written to the Results folder:
51 172  
  173 +outputPairsSingle.csv:- MU/Presc pairs for the solution found
52 174  
... ...
README.md
... ... @@ -0,0 +1,174 @@
  1 +# Forest Management
  2 +
  3 +The purpose of this implementation is to use Constraint Programming to find valid solutions for problems of forest management.
  4 +Here, Management Units (MUs) are associated with possible prescriptions which define which years the MUs are to be harvested.
  5 +But in any given year only 50ha of contiguous forest area can be harvested at once.
  6 +
  7 +
  8 +Therefore the implementation needs input defining:
  9 +
  10 +1-The existing MUs in the forest
  11 +2-The area of each MU
  12 +3-The MUs adjacent to each MU
  13 +4-The border lenght of each adjacency between MUs
  14 +5-The IDs of the Prescriptions of each MU
  15 +6-Relative to each Prescription, the years where the Prescription defines that the MU should be harvested.
  16 +7-Relative to each Prescription, the rewards each Prescription gives for being applied.
  17 +
  18 +# Step 1: Necessary Setup Files
  19 +
  20 +In general for every line in one of the files we assume a new Management Unit, a file with 4 lines would imply that there are 4 MUs, and since this has to be consistent then that means all input files should have 4 lines.
  21 +
  22 +6 files need to be prepared in the following manner
  23 +
  24 +
  25 +## external_init.txt
  26 +###- This file serves to indicate how many Management Units exist in the forest, so each line should have a number to serve as an External identifier of each MU. There should be as many lines as there are MUs in the forest
  27 +
  28 +Each of these External IDs have an Internal ID which corresponds to the index of their row starting from 0
  29 +-----------------EXAMPLE:
  30 +30
  31 +201
  32 +333
  33 +335
  34 +-------------------------
  35 +
  36 +So they have the following Internal IDs
  37 +----------------
  38 +0
  39 +1
  40 +2
  41 +3
  42 +----------------
  43 +
  44 +
  45 +## area_init.txt
  46 +###- This file sets up the area of each MU.
  47 +
  48 +-----------------Example:
  49 +42.60178
  50 +8.26
  51 +6.0315
  52 +26.94
  53 +------------------------
  54 +
  55 +## adj_init.txt
  56 +###- This file sets up the adjacencies of each MU each line should list the Internal IDs of the MUs adjacent to the respective MU separated by a comma. If the MU has no adjacent MUs the line should just have a -1
  57 +
  58 +-----------------Example:
  59 +1,2
  60 +0
  61 +0
  62 +-1
  63 +------------------------
  64 +So this forest might look like this:
  65 +Internal Ids: External Ids:
  66 +|2| |2|
  67 +|0| |3| |0| |3|
  68 +|1| |1|
  69 +
  70 +
  71 +##border_init.txt
  72 +###- This file sets up the lenght of the border of each adjacent MU, each line should list the lenght of the borders of each adjacency separated by a comma. If the MU has no adjacent MUs the should just have a -1
  73 +
  74 +-----------------Example:
  75 +259,151
  76 +490
  77 +102,653
  78 +-1
  79 +------------------------
  80 +
  81 +If borders aren't a factor is your data just put use 0s in place of real border values
  82 +
  83 +
  84 +##ugs_init.txt
  85 +###- This file sets up the Prescriptions associated with each MU, each line should list the IDs of the Prescriptions associated with each MU
  86 +
  87 +-----------------Example:
  88 +1,2,3
  89 +19
  90 +19,20,21
  91 +500,501,502,503,500600,500601
  92 +------------------------
  93 +
  94 +##years_init.txt
  95 +###- This file sets up the relation between Prescriptions and the years where those Prescriptions have Harvest actions.
  96 +### Each line lists the years where the corresponding Prescription has Harvest actions separated by commas, if the MU has more than one Prescription then a "/" is followed by the next Prescription's harvest years. If a Prescription has no years of Harvest there should be a -1
  97 +
  98 +Before listing the years the line should have the Internal ID of the MU followed by a "|"
  99 +
  100 + -----------------Example:
  101 +0|2026,2056,2066/2027,2049,2060/2028,2040,2052,2064
  102 +1|2022,2032,2042
  103 +2|2026,2046/2060/-1
  104 +3|2052/2057/-1/2067/2052/2052
  105 +------------------------
  106 +
  107 +#Step 2: Criteria Files
  108 +
  109 +There can be a maximum of 10 optimizable criteria in the program represented by these files, these files are crit_file0-10.txt and their format is the same.
  110 +
  111 +Each line corresponds to an MU similarly to previous files and the contents are separated by commas, the contents are the values of the objective criteria associated with each Prescription of the respective MU
  112 +-----------------Example:
  113 +34,30.99,3.363
  114 +1568.630
  115 +565.79,146,1692
  116 +4966,6310,7,87,49,496
  117 +------------------------
  118 +
  119 +#Step 3: Running the software
  120 +
  121 +The program is run through the make file and requires Java 11.
  122 +Open up the Makefile in this folder and modify the parameters of the "make" label, then run the "make" command in the terminal.
  123 +
  124 +## MainWithSpecific
  125 +The MainWithSpecific command is what should be run and its parameters can be changed in the following manner.
  126 +
  127 +The examples shown are related to the Vale de Sousa forest which was used in the MODFIRE project.
  128 +
  129 +## MainWithSpecific parameters:
  130 +1st- Maximum Area Limit (50)
  131 +2nd- Directory with data about forest (res)
  132 +3rd- Minimum Border Lenght (50)
  133 +4th- Single or Multi Criteria
  134 +5th- Name of file with the UGs to be considered (in subregions folder)
  135 +6th and onward- Choose the criterias to be optimized, if the 4th parameter is Single only the first criteria will be optimized
  136 +
  137 +0-Criteria0 (Wood Yield)
  138 +1-Criteria1 (Soil Loss)
  139 +2-Criteria2 (Perc_r)
  140 +3-Criteria3 (Biodiversity)
  141 +4-Criteria4 (Cashflow)
  142 +5-Criteria5 (Carbon Stock)
  143 +6-Criteria6 (NPV)
  144 +7-Criteria7 (Perc_rait)
  145 +8-Criteria8 (R)
  146 +9-Criteria9 (Rait)
  147 +10-Criteria10(Sbiom)
  148 +
  149 +## Example to optimize Wood Yield and Soil Loss in Paredes-> MainWithSpecific 50 res 50 Multi Paredes 0 1
  150 +
  151 +The program will try to find valid solutions for 8 hours (28800000 miliseconds) or until there's a memory error.
  152 +
  153 +## MainTime Paremeters
  154 +Same as MainWithSpecific but the 4th parameter sets the time limit for finding solutions in miliseconds
  155 +
  156 +Example: MainTime 50 res 50 28800000 Paredes 0 1
  157 +
  158 +
  159 +#Step 4: Output files
  160 +In Multi Criteria optimization the following files are written to the Results folder:
  161 +Output files Multi-Criteria:
  162 +
  163 +
  164 +allSolutionPairs.csv:- MU/Presc pairs for every valid solution found
  165 +outputPairsMulti.csv:- MU/Presc pairs for every pareto solution (determined by choco solver)
  166 +nonPareto.csv:- Values of the optimizable criteria for every valid solution found
  167 +pareto.csv:- Values of the optimizable criteria for every pareto solution found
  168 +pairCriteria.csv:- MU/Presc pairs for every pareto solution along with associated values of objective criteria.
  169 +
  170 +
  171 +In Single Criteria optimization the following file is written to the Results folder:
  172 +
  173 +outputPairsSingle.csv:- MU/Presc pairs for the solution found
  174 +
... ...
islandAreas
... ... @@ -1,17 +0,0 @@
1   -EXT,INT,AR
2   -9,8,5.17.54
3   -10,9,15.59
4   -11,10,4.31
5   -12,11,1.91
6   -13,12,10.96
7   -14,13,10.29
8   -167,149,7.4
9   -451,404,2.32
10   -
11   -
12   -sELECT DISTINCT Id, PRESC, region from action_external INNER join region_ext where action_external.Id = region_ext.ug and region_ext.region = "Penafiel"
13   -
14   -northwest: , -828359,
15   -paivawest:2438170,-1722871,-16170
16   -paivaEast:413778, -288994, -2521
17   -paivaIslands:439988,-208956,-2070