Commit e146ab4e6bd169fdbbabf00005479e799bdc66f0
1 parent
67b613e8
Exists in
Standardized
and in
1 other branch
selecttable criteria
Showing
19 changed files
with
339 additions
and
79 deletions
Show diff stats
MODFIRE-Prototype/out/production/MODFIRE-Prototype/CustomPropagator2.class
No preview for this file type
MODFIRE-Prototype/out/production/MODFIRE-Prototype/GetInput.class
No preview for this file type
MODFIRE-Prototype/out/production/MODFIRE-Prototype/Main5Criteria.class
No preview for this file type
MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainDistance.class
No preview for this file type
MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainLimit.class
No preview for this file type
MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainRegion.class
No preview for this file type
MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainWithSpecific.class
No preview for this file type
MODFIRE-Prototype/out/production/MODFIRE-Prototype/MultiOutput.class
No preview for this file type
| @@ -0,0 +1,193 @@ | @@ -0,0 +1,193 @@ | ||
| 1 | +3,20 | ||
| 2 | +4,500 | ||
| 3 | +5,500 | ||
| 4 | +7,1 | ||
| 5 | +19,2 | ||
| 6 | +20,1 | ||
| 7 | +21,1 | ||
| 8 | +22,1 | ||
| 9 | +23,1 | ||
| 10 | +24,1 | ||
| 11 | +29,1 | ||
| 12 | +34,1 | ||
| 13 | +39,1 | ||
| 14 | +40,1 | ||
| 15 | +41,3 | ||
| 16 | +46,1 | ||
| 17 | +59,500 | ||
| 18 | +63,500 | ||
| 19 | +64,1 | ||
| 20 | +66,500 | ||
| 21 | +90,500 | ||
| 22 | +91,20 | ||
| 23 | +92,3 | ||
| 24 | +93,500 | ||
| 25 | +95,1 | ||
| 26 | +97,1 | ||
| 27 | +98,2 | ||
| 28 | +99,2 | ||
| 29 | +100,2 | ||
| 30 | +101,501 | ||
| 31 | +102,500 | ||
| 32 | +103,501 | ||
| 33 | +104,500 | ||
| 34 | +105,3 | ||
| 35 | +106,3 | ||
| 36 | +108,2 | ||
| 37 | +109,500 | ||
| 38 | +110,1 | ||
| 39 | +135,308 | ||
| 40 | +136,2 | ||
| 41 | +138,1 | ||
| 42 | +144,1 | ||
| 43 | +153,304 | ||
| 44 | +163,500 | ||
| 45 | +164,1 | ||
| 46 | +172,500 | ||
| 47 | +173,500 | ||
| 48 | +174,1 | ||
| 49 | +177,1 | ||
| 50 | +178,3 | ||
| 51 | +180,1 | ||
| 52 | +181,3 | ||
| 53 | +184,1 | ||
| 54 | +187,1 | ||
| 55 | +194,500 | ||
| 56 | +195,1 | ||
| 57 | +196,2 | ||
| 58 | +210,500 | ||
| 59 | +218,1 | ||
| 60 | +219,500 | ||
| 61 | +225,500 | ||
| 62 | +226,3 | ||
| 63 | +227,3 | ||
| 64 | +229,2 | ||
| 65 | +230,1 | ||
| 66 | +231,3 | ||
| 67 | +235,1 | ||
| 68 | +236,3 | ||
| 69 | +237,3 | ||
| 70 | +246,2 | ||
| 71 | +247,1 | ||
| 72 | +248,3 | ||
| 73 | +250,1 | ||
| 74 | +251,2 | ||
| 75 | +255,3 | ||
| 76 | +256,19 | ||
| 77 | +257,19 | ||
| 78 | +258,2 | ||
| 79 | +259,500 | ||
| 80 | +260,1 | ||
| 81 | +266,1 | ||
| 82 | +267,1 | ||
| 83 | +268,1 | ||
| 84 | +269,3 | ||
| 85 | +270,501 | ||
| 86 | +271,312 | ||
| 87 | +272,1 | ||
| 88 | +274,500 | ||
| 89 | +275,1 | ||
| 90 | +276,1 | ||
| 91 | +277,500 | ||
| 92 | +278,2 | ||
| 93 | +297,1 | ||
| 94 | +307,316 | ||
| 95 | +348,1 | ||
| 96 | +363,3 | ||
| 97 | +364,1 | ||
| 98 | +368,1 | ||
| 99 | +369,3 | ||
| 100 | +370,1 | ||
| 101 | +371,500 | ||
| 102 | +372,2 | ||
| 103 | +373,3 | ||
| 104 | +374,500 | ||
| 105 | +375,3 | ||
| 106 | +376,1 | ||
| 107 | +377,1 | ||
| 108 | +378,1 | ||
| 109 | +379,500 | ||
| 110 | +380,1 | ||
| 111 | +381,1 | ||
| 112 | +384,500 | ||
| 113 | +385,500 | ||
| 114 | +386,1 | ||
| 115 | +387,1 | ||
| 116 | +391,3 | ||
| 117 | +408,1 | ||
| 118 | +409,1 | ||
| 119 | +410,3 | ||
| 120 | +414,1 | ||
| 121 | +427,500 | ||
| 122 | +428,500 | ||
| 123 | +429,500 | ||
| 124 | +433,1 | ||
| 125 | +458,500 | ||
| 126 | +459,1 | ||
| 127 | +460,3 | ||
| 128 | +461,3 | ||
| 129 | +464,3 | ||
| 130 | +465,2 | ||
| 131 | +470,502 | ||
| 132 | +474,802 | ||
| 133 | +483,500 | ||
| 134 | +484,1 | ||
| 135 | +501,2 | ||
| 136 | +502,2 | ||
| 137 | +503,1 | ||
| 138 | +504,1 | ||
| 139 | +505,2 | ||
| 140 | +512,500 | ||
| 141 | +533,500 | ||
| 142 | +555,19 | ||
| 143 | +556,3 | ||
| 144 | +557,2 | ||
| 145 | +558,2 | ||
| 146 | +559,3 | ||
| 147 | +560,1 | ||
| 148 | +586,1 | ||
| 149 | +587,1 | ||
| 150 | +588,3 | ||
| 151 | +589,15 | ||
| 152 | +590,500 | ||
| 153 | +591,19 | ||
| 154 | +592,3 | ||
| 155 | +605,3 | ||
| 156 | +606,2 | ||
| 157 | +611,500 | ||
| 158 | +612,3 | ||
| 159 | +614,1 | ||
| 160 | +615,1 | ||
| 161 | +616,1 | ||
| 162 | +618,2 | ||
| 163 | +619,2 | ||
| 164 | +642,3 | ||
| 165 | +655,800 | ||
| 166 | +675,1 | ||
| 167 | +678,3 | ||
| 168 | +679,1 | ||
| 169 | +682,2 | ||
| 170 | +712,29 | ||
| 171 | +713,2 | ||
| 172 | +730,34 | ||
| 173 | +731,1 | ||
| 174 | +736,500 | ||
| 175 | +737,308 | ||
| 176 | +742,2 | ||
| 177 | +743,2 | ||
| 178 | +746,801 | ||
| 179 | +748,801 | ||
| 180 | +749,500 | ||
| 181 | +755,1 | ||
| 182 | +756,1 | ||
| 183 | +757,1 | ||
| 184 | +762,3 | ||
| 185 | +763,1 | ||
| 186 | +764,1 | ||
| 187 | +767,1 | ||
| 188 | +773,500 | ||
| 189 | +774,3600 | ||
| 190 | +775,304 | ||
| 191 | +776,801 | ||
| 192 | +777,801 | ||
| 193 | +782,1 |
MODFIRE-Prototype/src/CustomPropagator2.java
| @@ -16,7 +16,7 @@ public class CustomPropagator2 extends org.chocosolver.solver.constraints.Propag | @@ -16,7 +16,7 @@ public class CustomPropagator2 extends org.chocosolver.solver.constraints.Propag | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | - public CustomPropagator2(int ugIndex, UG[] nodes, IntVar[] ugs, int sum, IntVar[] woodYield) { | 19 | + public CustomPropagator2(int ugIndex, UG[] nodes, IntVar[] ugs, int sum ) { |
| 20 | super(ugs, PropagatorPriority.LINEAR, false); | 20 | super(ugs, PropagatorPriority.LINEAR, false); |
| 21 | this.ugIndex = ugIndex; | 21 | this.ugIndex = ugIndex; |
| 22 | this.nodes = nodes; | 22 | this.nodes = nodes; |
MODFIRE-Prototype/src/GetInput.java
| @@ -170,7 +170,7 @@ public class GetInput { | @@ -170,7 +170,7 @@ public class GetInput { | ||
| 170 | //the propagator takes as parameters the index of the UG we are starting out from | 170 | //the propagator takes as parameters the index of the UG we are starting out from |
| 171 | //the nodes with all the info, the constraint variable array and the area limit | 171 | //the nodes with all the info, the constraint variable array and the area limit |
| 172 | if(nodes[ugIndex].valid) { | 172 | if(nodes[ugIndex].valid) { |
| 173 | - new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit, woodYield)).post(); | 173 | + new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit)).post(); |
| 174 | } | 174 | } |
| 175 | } | 175 | } |
| 176 | 176 |
MODFIRE-Prototype/src/Main5Criteria.java
| @@ -311,7 +311,7 @@ public class Main5Criteria { | @@ -311,7 +311,7 @@ public class Main5Criteria { | ||
| 311 | //the propagator takes as parameters the index of the UG we are starting out from | 311 | //the propagator takes as parameters the index of the UG we are starting out from |
| 312 | //the nodes with all the info, the constraint variable array and the area limit | 312 | //the nodes with all the info, the constraint variable array and the area limit |
| 313 | if(nodes[ugIndex].valid) { | 313 | if(nodes[ugIndex].valid) { |
| 314 | - new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit, woodYield)).post(); | 314 | + new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit)).post(); |
| 315 | } | 315 | } |
| 316 | } | 316 | } |
| 317 | 317 |
MODFIRE-Prototype/src/MainDistance.java
| @@ -295,7 +295,7 @@ public class MainDistance { | @@ -295,7 +295,7 @@ public class MainDistance { | ||
| 295 | //the propagator takes as parameters the index of the UG we are starting out from | 295 | //the propagator takes as parameters the index of the UG we are starting out from |
| 296 | //the nodes with all the info, the constraint variable array and the area limit | 296 | //the nodes with all the info, the constraint variable array and the area limit |
| 297 | if(nodes[ugIndex].valid) { | 297 | if(nodes[ugIndex].valid) { |
| 298 | - new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit, woodYield)).post(); | 298 | + new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit)).post(); |
| 299 | } | 299 | } |
| 300 | } | 300 | } |
| 301 | 301 |
MODFIRE-Prototype/src/MainLimit.java
| @@ -278,7 +278,7 @@ public class MainLimit { | @@ -278,7 +278,7 @@ public class MainLimit { | ||
| 278 | //the propagator takes as parameters the index of the UG we are starting out from | 278 | //the propagator takes as parameters the index of the UG we are starting out from |
| 279 | //the nodes with all the info, the constraint variable array and the area limit | 279 | //the nodes with all the info, the constraint variable array and the area limit |
| 280 | if(nodes[ugIndex].valid) { | 280 | if(nodes[ugIndex].valid) { |
| 281 | - new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit, woodYield)).post(); | 281 | + new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit)).post(); |
| 282 | } | 282 | } |
| 283 | } | 283 | } |
| 284 | 284 |
MODFIRE-Prototype/src/MainRegion.java
| @@ -281,7 +281,7 @@ public class MainRegion { | @@ -281,7 +281,7 @@ public class MainRegion { | ||
| 281 | //the propagator takes as parameters the index of the UG we are starting out from | 281 | //the propagator takes as parameters the index of the UG we are starting out from |
| 282 | //the nodes with all the info, the constraint variable array and the area limit | 282 | //the nodes with all the info, the constraint variable array and the area limit |
| 283 | if(nodes[ugIndex].valid) { | 283 | if(nodes[ugIndex].valid) { |
| 284 | - new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit, woodYield)).post(); | 284 | + new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit)).post(); |
| 285 | } | 285 | } |
| 286 | } | 286 | } |
| 287 | 287 |
MODFIRE-Prototype/src/MainWithSpecific.java
| @@ -228,21 +228,8 @@ public class MainWithSpecific { | @@ -228,21 +228,8 @@ public class MainWithSpecific { | ||
| 228 | String fileDirectory = args[1]; | 228 | String fileDirectory = args[1]; |
| 229 | 229 | ||
| 230 | ArrayList<Integer> islandUGs = new ArrayList<>(); | 230 | ArrayList<Integer> islandUGs = new ArrayList<>(); |
| 231 | - /*File island = new File("i_east"); | ||
| 232 | - Scanner islandReader = new Scanner(island); | ||
| 233 | - while (islandReader.hasNextLine()) { | ||
| 234 | - islandUGs.add(Integer.parseInt(islandReader.nextLine())); | ||
| 235 | - | ||
| 236 | - } | ||
| 237 | - | ||
| 238 | - island = new File("i_eastop"); | ||
| 239 | - islandReader = new Scanner(island); | ||
| 240 | - while (islandReader.hasNextLine()) { | ||
| 241 | - islandUGs.add(Integer.parseInt(islandReader.nextLine())); | ||
| 242 | 231 | ||
| 243 | - }*/ | ||
| 244 | - | ||
| 245 | - File island = new File("subregions/ip_continent"); | 232 | + File island = new File("subregions/i_top"); |
| 246 | Scanner islandReader = new Scanner(island); | 233 | Scanner islandReader = new Scanner(island); |
| 247 | while (islandReader.hasNextLine()) { | 234 | while (islandReader.hasNextLine()) { |
| 248 | islandUGs.add(Integer.parseInt(islandReader.nextLine())); | 235 | islandUGs.add(Integer.parseInt(islandReader.nextLine())); |
| @@ -265,6 +252,31 @@ public class MainWithSpecific { | @@ -265,6 +252,31 @@ public class MainWithSpecific { | ||
| 265 | default: | 252 | default: |
| 266 | R = 0;} | 253 | R = 0;} |
| 267 | 254 | ||
| 255 | + | ||
| 256 | + | ||
| 257 | + /*Set Flags | ||
| 258 | + 0-woodYield | ||
| 259 | + 1-Soil Loss | ||
| 260 | + 2-Perc_r | ||
| 261 | + 3-Biodiversity | ||
| 262 | + 4-Cashflow | ||
| 263 | + 5-Carbon Stock | ||
| 264 | + 6-NPV | ||
| 265 | + 7-Perc_rait | ||
| 266 | + 8-R | ||
| 267 | + 9-Rait | ||
| 268 | + 10-Sbiom | ||
| 269 | + */ | ||
| 270 | + String[] varNames = new String[]{"WoodYield","SoilLoss","Perc_r","Biodiversity","Cashflow","CarbonStock","NPV","Perc_rait","R","Rait","Sbiom"}; | ||
| 271 | + ArrayList<Boolean> flags = new ArrayList<Boolean>(); | ||
| 272 | + for(int i = 0; i < 11; i++) { | ||
| 273 | + flags.add(false); | ||
| 274 | + } | ||
| 275 | + for(int i = 4; i < args.length; i++) { | ||
| 276 | + flags.set(Integer.parseInt(args[i]), true); | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + | ||
| 268 | Model m = new Model("Forest Management"); | 280 | Model m = new Model("Forest Management"); |
| 269 | 281 | ||
| 270 | BufferedReader reader = new BufferedReader(new FileReader(fileDirectory + "/ugs_init.txt")); | 282 | BufferedReader reader = new BufferedReader(new FileReader(fileDirectory + "/ugs_init.txt")); |
| @@ -283,6 +295,7 @@ public class MainWithSpecific { | @@ -283,6 +295,7 @@ public class MainWithSpecific { | ||
| 283 | 295 | ||
| 284 | IntVar[] ugs = new IntVar[nUgs]; // same for the constraint variable array | 296 | IntVar[] ugs = new IntVar[nUgs]; // same for the constraint variable array |
| 285 | 297 | ||
| 298 | + | ||
| 286 | IntVar[] woodYield = new IntVar[nUgs]; | 299 | IntVar[] woodYield = new IntVar[nUgs]; |
| 287 | 300 | ||
| 288 | IntVar[] soillossTotal = new IntVar[nUgs]; | 301 | IntVar[] soillossTotal = new IntVar[nUgs]; |
| @@ -298,7 +311,6 @@ public class MainWithSpecific { | @@ -298,7 +311,6 @@ public class MainWithSpecific { | ||
| 298 | IntVar[] rait_total = new IntVar[nUgs]; | 311 | IntVar[] rait_total = new IntVar[nUgs]; |
| 299 | IntVar[] sbiom_total = new IntVar[nUgs]; | 312 | IntVar[] sbiom_total = new IntVar[nUgs]; |
| 300 | 313 | ||
| 301 | - | ||
| 302 | giveDomains(m, ugs, fileDirectory, woodYield, soillossTotal, perc_r_Total, biodiversity_total, cashflow_total, cstock_total, | 314 | giveDomains(m, ugs, fileDirectory, woodYield, soillossTotal, perc_r_Total, biodiversity_total, cashflow_total, cstock_total, |
| 303 | npv_total, perc_rait_total, r_total, rait_total, sbiom_total, nodes, R_option); // reads the ugs_init file and initializes each variable with its possible prescription values as domain | 315 | npv_total, perc_rait_total, r_total, rait_total, sbiom_total, nodes, R_option); // reads the ugs_init file and initializes each variable with its possible prescription values as domain |
| 304 | 316 | ||
| @@ -310,7 +322,7 @@ public class MainWithSpecific { | @@ -310,7 +322,7 @@ public class MainWithSpecific { | ||
| 310 | //the propagator takes as parameters the index of the UG we are starting out from | 322 | //the propagator takes as parameters the index of the UG we are starting out from |
| 311 | //the nodes with all the info, the constraint variable array and the area limit | 323 | //the nodes with all the info, the constraint variable array and the area limit |
| 312 | if(nodes[ugIndex].valid) { | 324 | if(nodes[ugIndex].valid) { |
| 313 | - new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit, woodYield)).post(); | 325 | + new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit)).post(); |
| 314 | } | 326 | } |
| 315 | } | 327 | } |
| 316 | 328 | ||
| @@ -401,23 +413,41 @@ public class MainWithSpecific { | @@ -401,23 +413,41 @@ public class MainWithSpecific { | ||
| 401 | IntVar raitSum = m.intVar("RaitR"+R,0, 99999999); | 413 | IntVar raitSum = m.intVar("RaitR"+R,0, 99999999); |
| 402 | IntVar sbiomSum = m.intVar("SbiomR"+R,0, 99999999); | 414 | IntVar sbiomSum = m.intVar("SbiomR"+R,0, 99999999); |
| 403 | 415 | ||
| 404 | - | ||
| 405 | - m.sum(woodYield,"=", woodSum).post(); | ||
| 406 | - m.sum(soillossTotal,"=", soilSum).post(); | ||
| 407 | - m.sum(perc_r_Total,"=", percRSum).post(); | ||
| 408 | - | ||
| 409 | - m.sum(biodiversity_total, "=", bioSum).post(); | ||
| 410 | - m.sum(cashflow_total, "=", cashSum).post(); | ||
| 411 | - //m.sum(cstock_total, "=", cstockSum).post(); | ||
| 412 | - //m.sum(npv_total, "=", npvSum).post(); | ||
| 413 | - //m.sum(perc_rait_total, "=", percRaitSum).post(); | ||
| 414 | - //m.sum(r_total, "=", rSum).post(); | ||
| 415 | - //m.sum(rait_total, "=", raitSum).post(); | ||
| 416 | - // m.sum(sbiom_total, "=", sbiomSum).post(); | 416 | + System.out.println(flags.get(0)); |
| 417 | + System.out.println(flags.get(1)); | ||
| 418 | + System.out.println(flags.get(2)); | ||
| 419 | + | ||
| 420 | + if(flags.get(0)) | ||
| 421 | + m.sum(woodYield,"=", woodSum).post(); | ||
| 422 | + if(flags.get(1)) | ||
| 423 | + m.sum(soillossTotal,"=", soilSum).post(); | ||
| 424 | + if(flags.get(2)) | ||
| 425 | + m.sum(perc_r_Total,"=", percRSum).post(); | ||
| 426 | + if(flags.get(3)) | ||
| 427 | + m.sum(biodiversity_total, "=", bioSum).post(); | ||
| 428 | + if(flags.get(4)) | ||
| 429 | + m.sum(cashflow_total, "=", cashSum).post(); | ||
| 430 | + if(flags.get(5)) | ||
| 431 | + m.sum(cstock_total, "=", cstockSum).post(); | ||
| 432 | + if(flags.get(6)) | ||
| 433 | + m.sum(npv_total, "=", npvSum).post(); | ||
| 434 | + if(flags.get(7)) | ||
| 435 | + m.sum(perc_rait_total, "=", percRaitSum).post(); | ||
| 436 | + if(flags.get(8)) | ||
| 437 | + m.sum(r_total, "=", rSum).post(); | ||
| 438 | + if(flags.get(9)) | ||
| 439 | + m.sum(rait_total, "=", raitSum).post(); | ||
| 440 | + if(flags.get(10)) | ||
| 441 | + m.sum(sbiom_total, "=", sbiomSum).post(); | ||
| 442 | + | ||
| 443 | + | ||
| 444 | + IntVar[] toOptimize = new IntVar[10]; | ||
| 445 | + IntVar[] allSums = new IntVar[]{woodSum, soilSum, percRSum, bioSum,cashSum,cstockSum,npvSum,percRaitSum,rSum,raitSum,sbiomSum}; | ||
| 446 | + IntVar[][] allTotals = new IntVar[][]{woodYield, soillossTotal,perc_r_Total,biodiversity_total,cashflow_total,cstock_total,npv_total,perc_rait_total,r_total,rait_total,sbiom_total}; | ||
| 417 | 447 | ||
| 418 | // Single Criterion Optimization | 448 | // Single Criterion Optimization |
| 419 | if(criterion.equalsIgnoreCase("single")) { | 449 | if(criterion.equalsIgnoreCase("single")) { |
| 420 | - m.setObjective(Model.MAXIMIZE, woodSum); | 450 | + //m.setObjective(Model.MAXIMIZE, woodSum); |
| 421 | //m.setObjective(Model.MAXIMIZE, soilSum); | 451 | //m.setObjective(Model.MAXIMIZE, soilSum); |
| 422 | //m.setObjective(Model.MAXIMIZE, percRSum); | 452 | //m.setObjective(Model.MAXIMIZE, percRSum); |
| 423 | 453 | ||
| @@ -428,7 +458,14 @@ public class MainWithSpecific { | @@ -428,7 +458,14 @@ public class MainWithSpecific { | ||
| 428 | FileWriter outputPairs = new FileWriter("outputPairs.csv"); | 458 | FileWriter outputPairs = new FileWriter("outputPairs.csv"); |
| 429 | for (int i = 0; i < ugs.length; i++) { | 459 | for (int i = 0; i < ugs.length; i++) { |
| 430 | if (nodes[i].valid) { | 460 | if (nodes[i].valid) { |
| 431 | - System.out.println(ugs[i] + ", wy:" + woodYield[i] + ", sl:" + soillossTotal[i] + ", R" + R + ":" + perc_r_Total[i]); | 461 | + System.out.print(ugs[i] + ", "); |
| 462 | + | ||
| 463 | + for (int j = 0; j < flags.size(); j++) { | ||
| 464 | + if (flags.get(j)) | ||
| 465 | + System.out.print(varNames[j]+":"+ allTotals[j][i] +","); | ||
| 466 | + } | ||
| 467 | + System.out.println("end"); | ||
| 468 | + | ||
| 432 | outputPairs.write(nodes[i].externalId + "," + ugs[i].getValue() + "\n"); | 469 | outputPairs.write(nodes[i].externalId + "," + ugs[i].getValue() + "\n"); |
| 433 | } | 470 | } |
| 434 | } | 471 | } |
| @@ -442,17 +479,29 @@ public class MainWithSpecific { | @@ -442,17 +479,29 @@ public class MainWithSpecific { | ||
| 442 | else { | 479 | else { |
| 443 | //Multi Criterion with Pareto | 480 | //Multi Criterion with Pareto |
| 444 | 481 | ||
| 482 | + int index = 0; | ||
| 483 | + for(int i = 1; i<flags.toArray().length; i++){ | ||
| 484 | + if(flags.get(i)){ | ||
| 485 | + toOptimize[index] = allSums[i]; | ||
| 486 | + } | ||
| 487 | + } | ||
| 488 | + | ||
| 489 | + | ||
| 445 | //ParetoOptimizer po = new ParetoOptimizer(Model.MAXIMIZE, new IntVar[]{woodSum, soilToMaximize, percToMaximize}); | 490 | //ParetoOptimizer po = new ParetoOptimizer(Model.MAXIMIZE, new IntVar[]{woodSum, soilToMaximize, percToMaximize}); |
| 446 | - ParetoOptimizer po = new ParetoOptimizer(Model.MAXIMIZE, new IntVar[]{woodSum,soilSum,percRSum}); | 491 | + ParetoOptimizer po = new ParetoOptimizer(Model.MAXIMIZE, toOptimize); |
| 447 | 492 | ||
| 448 | Solver solver = m.getSolver(); | 493 | Solver solver = m.getSolver(); |
| 449 | solver.plugMonitor(po); | 494 | solver.plugMonitor(po); |
| 450 | 495 | ||
| 451 | 496 | ||
| 452 | - FileWriter nonParetoWS = new FileWriter("nonParetoWS.csv"); | ||
| 453 | - FileWriter nonParetoWR = new FileWriter("nonParetoWR.csv"); | ||
| 454 | - FileWriter nonParetoSR = new FileWriter("nonParetoSR.csv"); | ||
| 455 | - FileWriter nonParetoWSR = new FileWriter("nonParetoWSR.csv"); | 497 | + FileWriter nonPareto = new FileWriter("nonPareto.csv"); |
| 498 | + for (int i = 0; i < flags.size(); i++) { | ||
| 499 | + if (flags.get(i)) { | ||
| 500 | + nonPareto.write(varNames[i]+","); | ||
| 501 | + } | ||
| 502 | + } | ||
| 503 | + nonPareto.write("end\n"); | ||
| 504 | + | ||
| 456 | FileWriter allSolutionPairs = new FileWriter("allSolutionPairs.csv"); | 505 | FileWriter allSolutionPairs = new FileWriter("allSolutionPairs.csv"); |
| 457 | 506 | ||
| 458 | // optimization | 507 | // optimization |
| @@ -463,18 +512,33 @@ public class MainWithSpecific { | @@ -463,18 +512,33 @@ public class MainWithSpecific { | ||
| 463 | while(solver.solve() & (System.currentTimeMillis()-startTime)<32400000) | 512 | while(solver.solve() & (System.currentTimeMillis()-startTime)<32400000) |
| 464 | { | 513 | { |
| 465 | //System.out.println(l); | 514 | //System.out.println(l); |
| 466 | - nonParetoWSR.write(woodSum.getValue()+","+soilSum.getValue()+","+percRSum.getValue()+"\n"); | ||
| 467 | - allSolutionPairs.write(l+", Wood: "+ woodSum.getValue()+", Soil:"+soilSum.getValue()+ | ||
| 468 | - ", Perc_R"+R+":"+percRSum.getValue()+"\n"); | 515 | + for (int i = 0; i < flags.size(); i++) { |
| 516 | + if(flags.get(i)) | ||
| 517 | + nonPareto.write(allSums[i].getValue()+","); | ||
| 518 | + } | ||
| 519 | + nonPareto.write("end\n"); | ||
| 520 | + | ||
| 521 | + allSolutionPairs.write(l+", "); | ||
| 522 | + for (int i = 0; i < flags.size(); i++) { | ||
| 523 | + if(flags.get(i)) | ||
| 524 | + allSolutionPairs.write(varNames[i] +":"+ allSums[i].getValue()+","); | ||
| 525 | + } | ||
| 526 | + allSolutionPairs.write("end\n"); | ||
| 527 | + | ||
| 528 | + | ||
| 469 | for(int i = 0; i < nodes.length; i++){ | 529 | for(int i = 0; i < nodes.length; i++){ |
| 470 | if(nodes[i].valid){ | 530 | if(nodes[i].valid){ |
| 471 | - allSolutionPairs.write(nodes[i].externalId+","+ugs[i].getValue()+"\n"); | ||
| 472 | - //System.out.println(ugs[i] + ", wy:" + woodYield[i] + ", sl:" + soillossTotal[i] + ", R" + R + ":" + perc_r_Total[i]); | 531 | + |
| 532 | + System.out.print(ugs[i] + ", "); | ||
| 533 | + | ||
| 534 | + for (int j = 0; j < flags.size(); j++) { | ||
| 535 | + if(flags.get(j)) | ||
| 536 | + System.out.print(varNames[j] +":"+ allTotals[j][i].getValue()+","); | ||
| 537 | + } | ||
| 538 | + System.out.println("end"); | ||
| 473 | } | 539 | } |
| 474 | } | 540 | } |
| 475 | - nonParetoWS.write(woodSum.getValue()+","+soilSum.getValue()+"\n"); | ||
| 476 | - nonParetoWR.write(woodSum.getValue()+","+percRSum.getValue()+"\n"); | ||
| 477 | - nonParetoSR.write(soilSum.getValue()+","+percRSum.getValue()+"\n"); | 541 | + |
| 478 | l++; | 542 | l++; |
| 479 | } | 543 | } |
| 480 | } | 544 | } |
| @@ -482,53 +546,56 @@ public class MainWithSpecific { | @@ -482,53 +546,56 @@ public class MainWithSpecific { | ||
| 482 | System.out.println("Reached Exception"); | 546 | System.out.println("Reached Exception"); |
| 483 | } | 547 | } |
| 484 | 548 | ||
| 485 | - nonParetoWS.close(); | ||
| 486 | - nonParetoWR.close(); | ||
| 487 | - nonParetoSR.close(); | ||
| 488 | - nonParetoWSR.close(); | ||
| 489 | - allSolutionPairs.close(); | 549 | + nonPareto.close(); |
| 550 | + //allSolutionPairs.close(); | ||
| 490 | 551 | ||
| 491 | List<Solution> paretoFront = po.getParetoFront(); | 552 | List<Solution> paretoFront = po.getParetoFront(); |
| 492 | 553 | ||
| 493 | System.out.println("The pareto front has " + paretoFront.size() + " solutions : "); | 554 | System.out.println("The pareto front has " + paretoFront.size() + " solutions : "); |
| 494 | - FileWriter outputPairs = new FileWriter("outputPairsTopIslandWSR0.csv"); | 555 | + FileWriter outputPairs = new FileWriter("outputPairsSpecif.csv"); |
| 495 | 556 | ||
| 496 | - FileWriter paretoWS = new FileWriter("paretoWS.csv"); | ||
| 497 | - FileWriter paretoWR = new FileWriter("paretoWR.csv"); | ||
| 498 | - FileWriter paretoSR = new FileWriter("paretoSR.csv"); | ||
| 499 | - FileWriter paretoWSR = new FileWriter("paretoWSR.csv"); | 557 | + FileWriter pareto = new FileWriter("pareto.csv"); |
| 500 | 558 | ||
| 501 | 559 | ||
| 502 | int l2 = 0; | 560 | int l2 = 0; |
| 503 | for (Solution so : paretoFront) { | 561 | for (Solution so : paretoFront) { |
| 504 | - System.out.println("Wood = " + so.getIntVal(woodSum) + ", Soil = " + so.getIntVal(soilSum)+ | ||
| 505 | - ", Perc_R"+R+":"+so.getIntVal(percRSum)); | ||
| 506 | - outputPairs.write("Pareto Solution: " + l2 + ", Wood: "+so.getIntVal(woodSum)+", Soil:"+so.getIntVal(soilSum)+ | ||
| 507 | - ", Perc_R"+R+":"+so.getIntVal(percRSum)+"\n"); | 562 | + |
| 563 | + for (int i = 0; i < flags.size(); i++) { | ||
| 564 | + if (flags.get(i)) | ||
| 565 | + System.out.print(varNames[i]+"="+so.getIntVal(allSums[i])+","); | ||
| 566 | + } | ||
| 567 | + System.out.println("end"); | ||
| 568 | + | ||
| 569 | + outputPairs.write("Pareto Solution: " + l2+","); | ||
| 570 | + for (int i = 0; i < flags.size(); i++) { | ||
| 571 | + if (flags.get(i)) | ||
| 572 | + outputPairs.write(varNames[i]+":"+so.getIntVal(allSums[i])+","); | ||
| 573 | + } | ||
| 574 | + | ||
| 575 | + outputPairs.write("end+\n"); | ||
| 576 | + | ||
| 508 | for (int i = 0; i < ugs.length; i++) { | 577 | for (int i = 0; i < ugs.length; i++) { |
| 509 | if (nodes[i].valid) { | 578 | if (nodes[i].valid) { |
| 510 | - System.out.println(i+"_"+so.getIntVal(ugs[i]) + ", wy:" + so.getIntVal(woodYield[i]) + ", sl:" + | ||
| 511 | - so.getIntVal(soillossTotal[i]) + ", R" + R + ":" + so.getIntVal(perc_r_Total[i])); | ||
| 512 | - outputPairs.write(nodes[i].externalId + "," +so.getIntVal(ugs[i]) + "\n"); | ||
| 513 | - } | ||
| 514 | 579 | ||
| 515 | - } | 580 | + System.out.print(i+"_"+so.getIntVal(ugs[i])+", "); |
| 516 | 581 | ||
| 517 | - //PARETO POINTS | ||
| 518 | - paretoWS.write(so.getIntVal(woodSum)+","+so.getIntVal(soilSum)+"\n"); | ||
| 519 | - paretoWR.write(so.getIntVal(woodSum)+","+so.getIntVal(percRSum)+"\n"); | ||
| 520 | - paretoSR.write(so.getIntVal(soilSum)+","+so.getIntVal(percRSum)+"\n"); | ||
| 521 | - paretoWSR.write(so.getIntVal(woodSum)+","+so.getIntVal(soilSum)+","+so.getIntVal(percRSum)+"\n"); | 582 | + for (int j = 0; j < flags.size(); j++) { |
| 583 | + if (flags.get(j)) | ||
| 584 | + System.out.print(varNames[j]+":"+so.getIntVal(allTotals[j][i])+","); | ||
| 585 | + } | ||
| 586 | + System.out.println("end"); | ||
| 522 | 587 | ||
| 588 | + outputPairs.write(nodes[i].externalId + "," +so.getIntVal(ugs[i]) + "\n"); | ||
| 589 | + } | ||
| 590 | + } | ||
| 523 | 591 | ||
| 592 | + pareto.write(so.getIntVal(woodSum)+","+so.getIntVal(soilSum)+","+so.getIntVal(percRSum)+"\n"); | ||
| 524 | 593 | ||
| 525 | l2++; | 594 | l2++; |
| 526 | } | 595 | } |
| 527 | outputPairs.close(); | 596 | outputPairs.close(); |
| 528 | - paretoWS.close(); | ||
| 529 | - paretoWR.close(); | ||
| 530 | - paretoSR.close(); | ||
| 531 | - paretoWSR.close(); | 597 | + |
| 598 | + pareto.close(); | ||
| 532 | System.out.println(l + " solutions"); | 599 | System.out.println(l + " solutions"); |
| 533 | } | 600 | } |
| 534 | } | 601 | } |
MODFIRE-Prototype/src/MultiOutput.java
| @@ -163,7 +163,7 @@ public class MultiOutput { | @@ -163,7 +163,7 @@ public class MultiOutput { | ||
| 163 | //the propagator takes as parameters the index of the UG we are starting out from | 163 | //the propagator takes as parameters the index of the UG we are starting out from |
| 164 | //the nodes with all the info, the constraint variable array and the area limit | 164 | //the nodes with all the info, the constraint variable array and the area limit |
| 165 | if(nodes[ugIndex].valid) { | 165 | if(nodes[ugIndex].valid) { |
| 166 | - new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit, woodYield)).post(); | 166 | + new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit)).post(); |
| 167 | } | 167 | } |
| 168 | } | 168 | } |
| 169 | 169 |