From 424c167575d6b22e3584d3092ce43a583a9d9d15 Mon Sep 17 00:00:00 2001 From: ednice Date: Sat, 21 Jan 2023 16:25:49 +0000 Subject: [PATCH] more standardization, doesn't require all the criteria files --- MODFIRE-Prototype/Maps/MapInputFile.txt | 20 +++++++++----------- MODFIRE-Prototype/Maps/MapOutput/Map_2022.png | Bin 393161 -> 0 bytes MODFIRE-Prototype/Maps/MapOutput/Map_2023.png | Bin 390130 -> 0 bytes MODFIRE-Prototype/Maps/MapOutput/Map_2024.png | Bin 388209 -> 0 bytes MODFIRE-Prototype/Maps/MapOutput/Map_2025.png | Bin 385631 -> 0 bytes MODFIRE-Prototype/Maps/MapOutput/Map_2026.png | Bin 383635 -> 0 bytes MODFIRE-Prototype/Maps/MapOutput/Map_2027.png | Bin 381736 -> 0 bytes MODFIRE-Prototype/Maps/MapOutput/Map_2028.png | Bin 0 -> 380234 bytes MODFIRE-Prototype/Results/outputPairsSingle.csv | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MODFIRE-Prototype/Results/pairCriteria.csv | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainTime.class | Bin 17077 -> 0 bytes MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainWithSpecific.class | Bin 18565 -> 0 bytes MODFIRE-Prototype/out/production/MODFIRE-Prototype/UG.class | Bin 6199 -> 0 bytes MODFIRE-Prototype/src/MainTime.java | 6 +++--- MODFIRE-Prototype/src/MainWithSpecific.java | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------- MODFIRE-Prototype/src/UG.java | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- 16 files changed, 653 insertions(+), 123 deletions(-) create mode 100644 MODFIRE-Prototype/Maps/MapOutput/Map_2028.png delete mode 100644 MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainTime.class diff --git a/MODFIRE-Prototype/Maps/MapInputFile.txt b/MODFIRE-Prototype/Maps/MapInputFile.txt index eb319c0..743eb85 100644 --- a/MODFIRE-Prototype/Maps/MapInputFile.txt +++ b/MODFIRE-Prototype/Maps/MapInputFile.txt @@ -7,21 +7,19 @@ 10,2067,Ec-h 11,2048,Pb-t 11,2063,Pb-h -12,2027,Ec-h -12,2057,Sb-t -12,2067,Sb-t +12,2025,Ec-h +12,2055,Sb-t +12,2065,Sb-t 13,2028,Pb-t 13,2038,Pb-t 13,2048,Pb-t 13,2063,Pb-h -14,2027,Ec-h -14,2057,Sb-t -14,2067,Sb-t -167,2023,Ec-h -167,2034,Ec-h -167,2045,Ec-h -167,2056,Ec-h -167,2067,Ec-h +14,2026,Ec-h +14,2056,Sb-t +14,2066,Sb-t +167,2022,Ec-h +167,2052,Sb-t +167,2062,Sb-t 451,2021,Pb-h 451,2051,Sb-t 451,2061,Sb-t diff --git a/MODFIRE-Prototype/Maps/MapOutput/Map_2022.png b/MODFIRE-Prototype/Maps/MapOutput/Map_2022.png index 1acc946..e6e9671 100644 Binary files a/MODFIRE-Prototype/Maps/MapOutput/Map_2022.png and b/MODFIRE-Prototype/Maps/MapOutput/Map_2022.png differ diff --git a/MODFIRE-Prototype/Maps/MapOutput/Map_2023.png b/MODFIRE-Prototype/Maps/MapOutput/Map_2023.png index bf6859e..705ea15 100644 Binary files a/MODFIRE-Prototype/Maps/MapOutput/Map_2023.png and b/MODFIRE-Prototype/Maps/MapOutput/Map_2023.png differ diff --git a/MODFIRE-Prototype/Maps/MapOutput/Map_2024.png b/MODFIRE-Prototype/Maps/MapOutput/Map_2024.png index dc0067b..d3d0b7e 100644 Binary files a/MODFIRE-Prototype/Maps/MapOutput/Map_2024.png and b/MODFIRE-Prototype/Maps/MapOutput/Map_2024.png differ diff --git a/MODFIRE-Prototype/Maps/MapOutput/Map_2025.png b/MODFIRE-Prototype/Maps/MapOutput/Map_2025.png index eff0ebd..e8f464a 100644 Binary files a/MODFIRE-Prototype/Maps/MapOutput/Map_2025.png and b/MODFIRE-Prototype/Maps/MapOutput/Map_2025.png differ diff --git a/MODFIRE-Prototype/Maps/MapOutput/Map_2026.png b/MODFIRE-Prototype/Maps/MapOutput/Map_2026.png index 0457950..1e81beb 100644 Binary files a/MODFIRE-Prototype/Maps/MapOutput/Map_2026.png and b/MODFIRE-Prototype/Maps/MapOutput/Map_2026.png differ diff --git a/MODFIRE-Prototype/Maps/MapOutput/Map_2027.png b/MODFIRE-Prototype/Maps/MapOutput/Map_2027.png index 2649003..d267e74 100644 Binary files a/MODFIRE-Prototype/Maps/MapOutput/Map_2027.png and b/MODFIRE-Prototype/Maps/MapOutput/Map_2027.png differ diff --git a/MODFIRE-Prototype/Maps/MapOutput/Map_2028.png b/MODFIRE-Prototype/Maps/MapOutput/Map_2028.png new file mode 100644 index 0000000..a583d28 Binary files /dev/null and b/MODFIRE-Prototype/Maps/MapOutput/Map_2028.png differ diff --git a/MODFIRE-Prototype/Results/outputPairsSingle.csv b/MODFIRE-Prototype/Results/outputPairsSingle.csv index e69de29..b268487 100644 --- a/MODFIRE-Prototype/Results/outputPairsSingle.csv +++ b/MODFIRE-Prototype/Results/outputPairsSingle.csv @@ -0,0 +1,203 @@ +3,19 +4,500 +5,500 +7,1 +19,1 +20,1 +21,1 +22,1 +23,1 +24,1 +29,1 +34,1 +39,1 +40,1 +41,3 +46,2 +59,500 +63,501 +64,1 +66,19 +90,304 +91,19 +92,3 +93,500 +95,1 +97,2 +98,2 +99,1 +100,1 +101,500 +102,500 +103,500 +104,500 +105,1 +106,1 +108,1 +109,500 +110,1 +135,308 +136,2 +138,1 +144,1 +153,304 +163,19 +164,1 +172,500 +173,308 +174,1 +177,1 +178,3 +180,1 +181,1 +184,1 +187,3 +194,500 +195,1 +196,1 +210,500 +218,1 +219,500 +225,500 +226,1 +227,1 +229,3 +230,1 +231,3 +233,500 +235,1 +236,1 +237,1 +246,3 +247,1 +248,1 +250,1 +251,3 +255,1 +256,19 +257,20 +258,1 +259,500 +260,1 +266,1 +267,1 +268,1 +269,1 +270,500 +271,312 +272,1 +274,500 +275,1 +276,1 +277,500 +278,4 +297,1 +307,316 +348,1 +363,3 +364,3 +368,1 +369,1 +370,3 +371,1 +372,1 +373,2 +374,500 +375,2 +376,1 +377,1 +378,1 +379,500 +380,1601 +381,1 +384,500 +385,500 +386,1 +387,3 +391,1 +408,3 +409,1 +410,1 +414,1 +427,501 +428,500 +429,500 +433,1 +458,500 +459,1 +460,3 +461,1 +464,1 +465,3 +470,500 +474,802 +483,500 +484,1 +501,1 +502,2 +503,1 +504,1 +505,1 +512,500 +533,500 +555,19 +556,1 +557,1 +558,1 +559,1 +560,1 +586,2 +587,1 +588,1 +589,13 +590,500 +591,19 +592,1 +605,2 +606,1 +611,500 +612,1 +614,1 +615,2 +616,1 +618,1 +619,1 +642,3 +655,800 +675,1 +678,1 +679,1 +682,1 +712,28 +713,2 +730,34 +731,1 +736,501 +737,308 +742,2 +743,1 +746,801 +748,801 +749,500 +755,3 +756,1 +757,1 +762,1 +763,1 +764,1 +767,1 +773,500 +774,1 +775,304 +776,801 +777,801 +782,1 +828,19 +832,19 +941,35 +952,34 +1427,1 +1468,19 +1571,800 +1622,1 +1623,20 diff --git a/MODFIRE-Prototype/Results/pairCriteria.csv b/MODFIRE-Prototype/Results/pairCriteria.csv index e69de29..f81ce44 100644 --- a/MODFIRE-Prototype/Results/pairCriteria.csv +++ b/MODFIRE-Prototype/Results/pairCriteria.csv @@ -0,0 +1,204 @@ +UG_2 = 19, Crit0_2 = 1565,end +UG_3 = 500, Crit0_3 = 4966,end +UG_4 = 500, Crit0_4 = 1481,end +UG_6 = 1, Crit0_6 = 15522,end +UG_15 = 1, Crit0_15 = 2505,end +UG_16 = 1, Crit0_16 = 2479,end +UG_17 = 1, Crit0_17 = 6239,end +UG_18 = 1, Crit0_18 = 3524,end +UG_19 = 1, Crit0_19 = 7002,end +UG_20 = 1, Crit0_20 = 10215,end +UG_24 = 1, Crit0_24 = 6103,end +UG_29 = 1, Crit0_29 = 18458,end +UG_33 = 1, Crit0_33 = 5713,end +UG_34 = 1, Crit0_34 = 5519,end +UG_35 = 3, Crit0_35 = 4356,end +UG_39 = 2, Crit0_39 = 183,end +UG_51 = 500, Crit0_51 = 747,end +UG_55 = 501, Crit0_55 = 3420,end +UG_56 = 1, Crit0_56 = 7184,end +UG_57 = 19, Crit0_57 = 2332,end +UG_78 = 304, Crit0_78 = 1075,end +UG_79 = 19, Crit0_79 = 1436,end +UG_80 = 3, Crit0_80 = 1005,end +UG_81 = 500, Crit0_81 = 1775,end +UG_83 = 1, Crit0_83 = 6375,end +UG_85 = 2, Crit0_85 = 3885,end +UG_86 = 2, Crit0_86 = 4966,end +UG_87 = 1, Crit0_87 = 4394,end +UG_88 = 1, Crit0_88 = 5433,end +UG_89 = 500, Crit0_89 = 2221,end +UG_90 = 500, Crit0_90 = 1596,end +UG_91 = 500, Crit0_91 = 2079,end +UG_92 = 500, Crit0_92 = 1950,end +UG_93 = 1, Crit0_93 = 3041,end +UG_94 = 1, Crit0_94 = 3896,end +UG_96 = 1, Crit0_96 = 2236,end +UG_97 = 500, Crit0_97 = 1002,end +UG_98 = 1, Crit0_98 = 7881,end +UG_122 = 308, Crit0_122 = 1025,end +UG_123 = 2, Crit0_123 = 4441,end +UG_124 = 1, Crit0_124 = 10646,end +UG_129 = 1, Crit0_129 = 1633,end +UG_135 = 304, Crit0_135 = 1817,end +UG_145 = 19, Crit0_145 = 1783,end +UG_146 = 1, Crit0_146 = 4550,end +UG_154 = 500, Crit0_154 = 3036,end +UG_155 = 308, Crit0_155 = 1855,end +UG_156 = 1, Crit0_156 = 1600,end +UG_159 = 1, Crit0_159 = 5964,end +UG_160 = 3, Crit0_160 = 10948,end +UG_162 = 1, Crit0_162 = 1372,end +UG_163 = 1, Crit0_163 = 4658,end +UG_166 = 1, Crit0_166 = 11543,end +UG_169 = 3, Crit0_169 = 4910,end +UG_176 = 500, Crit0_176 = 3174,end +UG_177 = 1, Crit0_177 = 3381,end +UG_178 = 1, Crit0_178 = 1010,end +UG_190 = 500, Crit0_190 = 448,end +UG_197 = 1, Crit0_197 = 4742,end +UG_198 = 500, Crit0_198 = 611,end +UG_203 = 500, Crit0_203 = 5864,end +UG_204 = 1, Crit0_204 = 2926,end +UG_205 = 1, Crit0_205 = 3182,end +UG_206 = 3, Crit0_206 = 2128,end +UG_207 = 1, Crit0_207 = 728,end +UG_208 = 3, Crit0_208 = 4225,end +UG_209 = 500, Crit0_209 = 145,end +UG_210 = 1, Crit0_210 = 7248,end +UG_211 = 1, Crit0_211 = 4052,end +UG_212 = 1, Crit0_212 = 1797,end +UG_219 = 3, Crit0_219 = 3921,end +UG_220 = 1, Crit0_220 = 860,end +UG_221 = 1, Crit0_221 = 934,end +UG_223 = 1, Crit0_223 = 1434,end +UG_224 = 3, Crit0_224 = 2031,end +UG_228 = 1, Crit0_228 = 10211,end +UG_229 = 19, Crit0_229 = 8193,end +UG_230 = 20, Crit0_230 = 8686,end +UG_231 = 1, Crit0_231 = 6994,end +UG_232 = 500, Crit0_232 = 1923,end +UG_233 = 1, Crit0_233 = 4555,end +UG_236 = 1, Crit0_236 = 1372,end +UG_237 = 1, Crit0_237 = 3314,end +UG_238 = 1, Crit0_238 = 4889,end +UG_239 = 1, Crit0_239 = 11071,end +UG_240 = 500, Crit0_240 = 1578,end +UG_241 = 312, Crit0_241 = 4140,end +UG_242 = 1, Crit0_242 = 1885,end +UG_244 = 500, Crit0_244 = 1431,end +UG_245 = 1, Crit0_245 = 6146,end +UG_246 = 1, Crit0_246 = 590,end +UG_247 = 500, Crit0_247 = 2186,end +UG_248 = 4, Crit0_248 = 2056,end +UG_266 = 1, Crit0_266 = 8471,end +UG_275 = 316, Crit0_275 = 5909,end +UG_312 = 1, Crit0_312 = 2676,end +UG_324 = 3, Crit0_324 = 3736,end +UG_325 = 3, Crit0_325 = 3665,end +UG_327 = 1, Crit0_327 = 3023,end +UG_328 = 1, Crit0_328 = 4418,end +UG_329 = 3, Crit0_329 = 4808,end +UG_330 = 1, Crit0_330 = 7342,end +UG_331 = 1, Crit0_331 = 3277,end +UG_332 = 2, Crit0_332 = 1702,end +UG_333 = 500, Crit0_333 = 947,end +UG_334 = 2, Crit0_334 = 4719,end +UG_335 = 1, Crit0_335 = 1917,end +UG_336 = 1, Crit0_336 = 11583,end +UG_337 = 1, Crit0_337 = 2108,end +UG_338 = 500, Crit0_338 = 2272,end +UG_339 = 1601, Crit0_339 = 210,end +UG_340 = 1, Crit0_340 = 204,end +UG_343 = 500, Crit0_343 = 549,end +UG_344 = 500, Crit0_344 = 1345,end +UG_345 = 1, Crit0_345 = 1348,end +UG_346 = 3, Crit0_346 = 6395,end +UG_350 = 1, Crit0_350 = 4219,end +UG_366 = 3, Crit0_366 = 9817,end +UG_367 = 1, Crit0_367 = 7741,end +UG_368 = 1, Crit0_368 = 4946,end +UG_372 = 1, Crit0_372 = 2714,end +UG_383 = 501, Crit0_383 = 1632,end +UG_384 = 500, Crit0_384 = 859,end +UG_385 = 500, Crit0_385 = 1095,end +UG_388 = 1, Crit0_388 = 6357,end +UG_410 = 500, Crit0_410 = 3069,end +UG_411 = 1, Crit0_411 = 1689,end +UG_412 = 3, Crit0_412 = 1279,end +UG_413 = 1, Crit0_413 = 2443,end +UG_416 = 1, Crit0_416 = 1204,end +UG_417 = 3, Crit0_417 = 2147,end +UG_422 = 500, Crit0_422 = 239,end +UG_426 = 802, Crit0_426 = 0,end +UG_435 = 500, Crit0_435 = 1426,end +UG_436 = 1, Crit0_436 = 1045,end +UG_452 = 1, Crit0_452 = 12250,end +UG_453 = 2, Crit0_453 = 3940,end +UG_454 = 1, Crit0_454 = 2526,end +UG_455 = 1, Crit0_455 = 2241,end +UG_456 = 1, Crit0_456 = 5184,end +UG_463 = 500, Crit0_463 = 2257,end +UG_482 = 500, Crit0_482 = 124,end +UG_501 = 19, Crit0_501 = 16074,end +UG_502 = 1, Crit0_502 = 2019,end +UG_503 = 1, Crit0_503 = 1951,end +UG_504 = 1, Crit0_504 = 4891,end +UG_505 = 1, Crit0_505 = 6115,end +UG_506 = 1, Crit0_506 = 1076,end +UG_530 = 2, Crit0_530 = 5750,end +UG_531 = 1, Crit0_531 = 2560,end +UG_532 = 1, Crit0_532 = 5920,end +UG_533 = 13, Crit0_533 = 3993,end +UG_534 = 500, Crit0_534 = 7716,end +UG_535 = 19, Crit0_535 = 6966,end +UG_536 = 1, Crit0_536 = 11568,end +UG_549 = 2, Crit0_549 = 9581,end +UG_550 = 1, Crit0_550 = 4005,end +UG_555 = 500, Crit0_555 = 650,end +UG_556 = 1, Crit0_556 = 5364,end +UG_558 = 1, Crit0_558 = 1488,end +UG_559 = 2, Crit0_559 = 4807,end +UG_560 = 1, Crit0_560 = 3181,end +UG_561 = 1, Crit0_561 = 932,end +UG_562 = 1, Crit0_562 = 4306,end +UG_585 = 3, Crit0_585 = 344,end +UG_597 = 800, Crit0_597 = 0,end +UG_616 = 1, Crit0_616 = 7393,end +UG_619 = 1, Crit0_619 = 3075,end +UG_620 = 1, Crit0_620 = 19353,end +UG_623 = 1, Crit0_623 = 10531,end +UG_653 = 28, Crit0_653 = 2509,end +UG_654 = 2, Crit0_654 = 3381,end +UG_669 = 34, Crit0_669 = 2771,end +UG_670 = 1, Crit0_670 = 1128,end +UG_674 = 501, Crit0_674 = 2182,end +UG_675 = 308, Crit0_675 = 1760,end +UG_680 = 2, Crit0_680 = 1783,end +UG_681 = 1, Crit0_681 = 3511,end +UG_684 = 801, Crit0_684 = 0,end +UG_685 = 801, Crit0_685 = 0,end +UG_686 = 500, Crit0_686 = 1012,end +UG_691 = 3, Crit0_691 = 6719,end +UG_692 = 1, Crit0_692 = 6028,end +UG_693 = 1, Crit0_693 = 5366,end +UG_698 = 1, Crit0_698 = 7466,end +UG_699 = 1, Crit0_699 = 7031,end +UG_700 = 1, Crit0_700 = 12622,end +UG_703 = 1, Crit0_703 = 4814,end +UG_707 = 500, Crit0_707 = 2504,end +UG_708 = 1, Crit0_708 = 2610,end +UG_709 = 304, Crit0_709 = 384,end +UG_710 = 801, Crit0_710 = 0,end +UG_711 = 801, Crit0_711 = 0,end +UG_716 = 1, Crit0_716 = 5087,end +UG_740 = 19, Crit0_740 = 2677,end +UG_743 = 19, Crit0_743 = 1061,end +UG_848 = 35, Crit0_848 = 5109,end +UG_859 = 34, Crit0_859 = 3010,end +UG_1264 = 1, Crit0_1264 = 1050,end +UG_1293 = 19, Crit0_1293 = 4128,end +UG_1369 = 800, Crit0_1369 = 0,end +UG_1403 = 1, Crit0_1403 = 300,end +UG_1404 = 20, Crit0_1404 = 138,end +CRIT0_SUM = 788418 diff --git a/MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainTime.class b/MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainTime.class deleted file mode 100644 index 311cca6..0000000 Binary files a/MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainTime.class and /dev/null differ diff --git a/MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainWithSpecific.class b/MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainWithSpecific.class index 8f539b9..7e4b920 100644 Binary files a/MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainWithSpecific.class and b/MODFIRE-Prototype/out/production/MODFIRE-Prototype/MainWithSpecific.class differ diff --git a/MODFIRE-Prototype/out/production/MODFIRE-Prototype/UG.class b/MODFIRE-Prototype/out/production/MODFIRE-Prototype/UG.class index 8d29415..7a45fe0 100644 Binary files a/MODFIRE-Prototype/out/production/MODFIRE-Prototype/UG.class and b/MODFIRE-Prototype/out/production/MODFIRE-Prototype/UG.class differ diff --git a/MODFIRE-Prototype/src/MainTime.java b/MODFIRE-Prototype/src/MainTime.java index 5933caa..01ac7af 100644 --- a/MODFIRE-Prototype/src/MainTime.java +++ b/MODFIRE-Prototype/src/MainTime.java @@ -9,7 +9,7 @@ import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.Scanner; - +/* public class MainTime { public static void giveDomains (Model model, IntVar[] ugs, String dir, IntVar[] crit0, IntVar[] crit1, @@ -210,7 +210,7 @@ public class MainTime { 8-R 9-Rait 10-Sbiom - */ + String[] varNames = new String[]{"Crit0","Crit1","Crit2","Crit3","Crit4","Crit5","Crit6","Crit7","Crit8","Crit9","Crit10"}; ArrayList flags = new ArrayList<>(); @@ -507,4 +507,4 @@ public class MainTime { System.out.println(l + " solutions"); } -} +} */ diff --git a/MODFIRE-Prototype/src/MainWithSpecific.java b/MODFIRE-Prototype/src/MainWithSpecific.java index 15addde..f97282f 100644 --- a/MODFIRE-Prototype/src/MainWithSpecific.java +++ b/MODFIRE-Prototype/src/MainWithSpecific.java @@ -14,77 +14,143 @@ public class MainWithSpecific { public static void giveDomains (Model model, IntVar[] ugs, String dir, IntVar[] crit0, IntVar[] crit1, IntVar[] crit2, IntVar[] crit3, IntVar[] crit4, IntVar[] crit5, - IntVar[] crit6, IntVar[] crit7, IntVar[] crit8,IntVar[] crit9,IntVar[] crit10, UG[] nodes){ + IntVar[] crit6, IntVar[] crit7, IntVar[] crit8,IntVar[] crit9,IntVar[] crit10, UG[] nodes, ArrayList flags){ int index = 0; try { File allUg = new File(dir + "/ugs_init.txt"); Scanner readerUg = new Scanner(allUg); File critFile0 = new File(dir + "/crit_file0.txt"); - Scanner reader0 = new Scanner(critFile0); + Scanner reader0 = null; + if(flags.get(0)) + reader0 = new Scanner(critFile0); File critFile1 = new File(dir + "/crit_file1.txt"); - Scanner reader1 = new Scanner(critFile1); + Scanner reader1 = null; + if(flags.get(1)) + reader1 = new Scanner(critFile1); File critFile2 = new File(dir + "/crit_file2.txt"); - Scanner reader2 = new Scanner(critFile2); + Scanner reader2 = null; + if(flags.get(2)) + new Scanner(critFile2); File critFile3 = new File(dir + "/crit_file3.txt"); - Scanner reader3 = new Scanner(critFile3); + Scanner reader3 = null; + if(flags.get(3)) + reader3 = new Scanner(critFile3); File critFile4 = new File(dir + "/crit_file4.txt"); - Scanner reader4 = new Scanner(critFile4); + Scanner reader4 = null; + if(flags.get(4)) + reader4 = new Scanner(critFile4); File critFile5 = new File(dir + "/crit_file5.txt"); - Scanner reader5 = new Scanner(critFile5); + Scanner reader5 = null; + if(flags.get(5)) + reader5 = new Scanner(critFile5); File critFile6 = new File(dir + "/crit_file6.txt"); - Scanner reader6 = new Scanner(critFile6); + Scanner reader6 = null; + if(flags.get(6)) + reader6 = new Scanner(critFile6); File critFile7 = new File(dir + "/crit_file7.txt"); - Scanner reader7 = new Scanner(critFile7); + Scanner reader7 = null; + if(flags.get(7)) + reader7 = new Scanner(critFile7); File critFile8 = new File(dir + "/crit_file8.txt"); - Scanner reader8 = new Scanner(critFile8); + Scanner reader8 = null; + if(flags.get(8)) + reader8 = new Scanner(critFile8); File critFile9 = new File(dir + "/crit_file9.txt"); - Scanner reader9 = new Scanner(critFile9); + Scanner reader9 = null; + if(flags.get(9)) + reader9 = new Scanner(critFile9); File critFile10 = new File(dir + "/crit_file10.txt"); - Scanner reader10 = new Scanner(critFile10); + Scanner reader10 = null; + if(flags.get(10)) + reader10 = new Scanner(critFile10); while (readerUg.hasNextLine()) { String dataUg = readerUg.nextLine(); - String data0 = reader0.nextLine(); - String data1 = reader1.nextLine(); - String data2 = reader2.nextLine(); - String data3 = reader3.nextLine(); - String data4 = reader4.nextLine(); - String data5 = reader5.nextLine(); - String data6 = reader6.nextLine(); - String data7 = reader7.nextLine(); - String data8 = reader8.nextLine(); - String data9 = reader9.nextLine(); - String data10 = reader10.nextLine(); + String data0 = null; + if(flags.get(0)) + data0 = reader0.nextLine(); + String data1 = null; + if(flags.get(1)) + data1 = reader1.nextLine(); + String data2 = null; + if(flags.get(2)) + data2 = reader2.nextLine(); + String data3 = null; + if(flags.get(3)) + data3 = reader3.nextLine(); + String data4 = null; + if(flags.get(4)) + data4 = reader4.nextLine(); + String data5 = null; + if(flags.get(5)) + data5 = reader5.nextLine(); + String data6 = null; + if(flags.get(6)) + data6 = reader6.nextLine(); + String data7 = null; + if(flags.get(7)) + data7 = reader7.nextLine(); + String data8 = null; + if(flags.get(8)) + data8 = reader8.nextLine(); + String data9 = null; + if(flags.get(9)) + data9 = reader9.nextLine(); + String data10 = null; + if(flags.get(10)) + data10 = reader10.nextLine(); - if(nodes[index].valid) { + if(nodes[index].valid || nodes[index].noAdjacencies) { String[] str_split = dataUg.split(",", 0); - String[] str_split0 = data0.split(",", 0); - String[] str_split1 = data1.split(",", 0); - String[] str_split2 = data2.split(",", 0); - String[] str_split3 = data3.split(",", 0); - String[] str_split4 = data4.split(",", 0); - String[] str_split5 = data5.split(",", 0); - String[] str_split6 = data6.split(",", 0); - String[] str_split7 = data7.split(",", 0); - String[] str_split8 = data8.split(",", 0); - String[] str_split9 = data9.split(",", 0); - String[] str_split10 = data10.split(",", 0); + String[] str_split0 = null; + if(flags.get(0)) + str_split0 = data0.split(",", 0); + String[] str_split1 = null; + if(flags.get(1)) + str_split1 = data1.split(",", 0); + String[] str_split2 = null; + if(flags.get(2)) + str_split2 = data2.split(",", 0); + String[] str_split3 = null; + if(flags.get(3)) + str_split3 = data3.split(",", 0); + String[] str_split4 = null; + if(flags.get(4)) + str_split4 = data4.split(",", 0); + String[] str_split5 = null; + if(flags.get(5)) + str_split5 = data5.split(",", 0); + String[] str_split6 = null; + if(flags.get(6)) + str_split6 = data6.split(",", 0); + String[] str_split7 = null; + if(flags.get(7)) + str_split7 = data7.split(",", 0); + String[] str_split8 = null; + if(flags.get(8)) + str_split8 = data8.split(",", 0); + String[] str_split9 = null; + if(flags.get(9)) + str_split9 = data9.split(",", 0); + String[] str_split10 = null; + if(flags.get(10)) + str_split10 = data10.split(",", 0); @@ -105,19 +171,38 @@ public class MainWithSpecific { for (int i = 0; i < size; i++) { toInsert[i] = Integer.parseInt(str_split[i]); - toInsert0[i] = (int) Float.parseFloat(str_split0[i]); - toInsert1[i] = (int) Float.parseFloat(str_split1[i]); + if(flags.get(0)) toInsert0[i] = (int) Float.parseFloat(str_split0[i]); + else toInsert0[i] = 0; + + if(flags.get(1)) toInsert1[i] = (int) Float.parseFloat(str_split1[i]); + else toInsert1[i] = 0; + + if(flags.get(2)) toInsert2[i] = (int) Float.parseFloat(str_split2[i]); + else toInsert2[i] = 0; + + if(flags.get(3)) toInsert3[i] = (int) Float.parseFloat(str_split3[i]); + else toInsert3[i] = 0; - toInsert2[i] = (int) Float.parseFloat(str_split2[i]); - toInsert3[i] = (int) Float.parseFloat(str_split3[i]); - toInsert4[i] = (int) Float.parseFloat(str_split4[i]); - toInsert5[i] = (int) Float.parseFloat(str_split5[i]); - toInsert6[i] = (int) Float.parseFloat(str_split6[i]); - toInsert7[i] = (int) Float.parseFloat(str_split7[i]); - toInsert8[i] = (int) Float.parseFloat(str_split8[i]); - toInsert9[i] = (int) Float.parseFloat(str_split9[i]); - toInsert10[i] = (int) Float.parseFloat(str_split10[i]); + if(flags.get(4)) toInsert4[i] = (int) Float.parseFloat(str_split4[i]); + else toInsert4[i] = 0; + if(flags.get(5)) toInsert5[i] = (int) Float.parseFloat(str_split5[i]); + else toInsert5[i] = 0; + + if(flags.get(6)) toInsert6[i] = (int) Float.parseFloat(str_split6[i]); + else toInsert6[i] = 0; + + if(flags.get(7)) toInsert7[i] = (int) Float.parseFloat(str_split7[i]); + else toInsert7[i] = 0; + + if(flags.get(8)) toInsert8[i] = (int) Float.parseFloat(str_split8[i]); + else toInsert8[i] = 0; + + if(flags.get(9)) toInsert9[i] = (int) Float.parseFloat(str_split9[i]); + else toInsert9[i] = 0; + + if(flags.get(10)) toInsert10[i] = (int) Float.parseFloat(str_split10[i]); + else toInsert10[i] = 0; } @@ -161,17 +246,17 @@ public class MainWithSpecific { } readerUg.close(); - reader0.close(); - reader1.close(); - reader2.close(); - reader3.close(); - reader4.close(); - reader5.close(); - reader6.close(); - reader7.close(); - reader8.close(); - reader9.close(); - reader10.close(); + if(flags.get(0)) reader0.close(); + if(flags.get(1)) reader1.close(); + if(flags.get(2)) reader2.close(); + if(flags.get(3)) reader3.close(); + if(flags.get(4)) reader4.close(); + if(flags.get(5)) reader5.close(); + if(flags.get(6)) reader6.close(); + if(flags.get(7)) reader7.close(); + if(flags.get(8)) reader8.close(); + if(flags.get(9)) reader9.close(); + if(flags.get(10)) reader10.close(); } catch (FileNotFoundException e) { @@ -197,7 +282,6 @@ public class MainWithSpecific { String criterion = args[3]; - /*Set Flags 0-woodYield 1-Soil Loss @@ -227,6 +311,7 @@ public class MainWithSpecific { Model m = new Model("Forest Management"); + System.out.println("Reading Input Files"); BufferedReader reader = new BufferedReader(new FileReader(fileDirectory + "/ugs_init.txt")); int nUgs = 0; @@ -237,9 +322,9 @@ public class MainWithSpecific { //if 0 ignore int minBorder = Integer.parseInt(args[2]); if(minBorder <= 0) - UG.fillArray(nodes, fileDirectory, 0); + UG.fillArray(nodes, fileDirectory, 0, flags); else - UG.fillArray(nodes, fileDirectory, minBorder); + UG.fillArray(nodes, fileDirectory, minBorder, flags); for(int i = 0; i < nodes.length; i++){ if(!islandUGs.contains(nodes[i].externalId)){ @@ -266,10 +351,10 @@ public class MainWithSpecific { IntVar[] crit10 = new IntVar[nUgs]; giveDomains(m, ugs, fileDirectory, crit0, crit1, crit2, crit3, crit4, crit5, crit6, - crit7, crit8, crit9, crit10, nodes); // reads the ugs_init file and initializes each variable with its possible prescription values as domain + crit7, crit8, crit9, crit10, nodes, flags); // reads the ugs_init file and initializes each variable with its possible prescription values as domain - System.out.println("running"); + System.out.println("Setting up Constraints"); for(int ugIndex = 0; ugIndex < nodes.length; ugIndex++) { //loops through every UG @@ -290,7 +375,7 @@ public class MainWithSpecific { for(int i = 0; i < nodes.length; i++){ - if(nodes[i].valid) { + if(nodes[i].valid || nodes[i].noAdjacencies) { IntVar prescIndex = m.intVar(0, 255); m.element(ugs[i], nodes[i].presc, prescIndex).post(); @@ -379,7 +464,7 @@ public class MainWithSpecific { switch(singleFlag) { case 0: - m.setObjective(Model.MAXIMIZE, sum0); + //m.setObjective(Model.MAXIMIZE, sum0); break; case 1: m.setObjective(Model.MAXIMIZE, sum1); @@ -416,21 +501,26 @@ public class MainWithSpecific { Solver s = m.getSolver(); - if (s.solve()) { + System.out.println("Running Solver"); + if (s.solve()) { + System.out.println("FOUND OPTIMAL SOLUTION!"); FileWriter outputPairs = new FileWriter("Results/outputPairsSingle.csv"); for (int i = 0; i < ugs.length; i++) { - if (nodes[i].valid) { + if (nodes[i].valid || nodes[i].noAdjacencies) { pairCrits.write(ugs[i] + ", "); for (int j = 0; j < flags.size(); j++) { - if (flags.get(j)) - pairCrits.write(allTotals[j][i] +","); + if (flags.get(j)) { + pairCrits.write(allTotals[j][i] + ","); + } } pairCrits.write("end\n"); outputPairs.write(nodes[i].externalId + "," + ugs[i].getValue() + "\n"); + //System.out.print(nodes[i].externalId + "," + ugs[i].getValue() + "\n"); + } } outputPairs.close(); @@ -508,7 +598,7 @@ public class MainWithSpecific { allSolutionPairs.write("end\n"); for(int i = 0; i < nodes.length; i++){ - if(nodes[i].valid){ + if(nodes[i].valid || nodes[i].noAdjacencies){ allSolutionPairs.write(nodes[i].externalId+","+ugs[i].getValue()+"\n"); } } @@ -568,7 +658,7 @@ public class MainWithSpecific { outputPairs.write("end\n"); for (int i = 0; i < ugs.length; i++) { - if (nodes[i].valid) { + if (nodes[i].valid || nodes[i].noAdjacencies) { pairCrits.write("UG_"+i+"="+so.getIntVal(ugs[i])+", "); diff --git a/MODFIRE-Prototype/src/UG.java b/MODFIRE-Prototype/src/UG.java index eb0cfef..fa6f3e2 100644 --- a/MODFIRE-Prototype/src/UG.java +++ b/MODFIRE-Prototype/src/UG.java @@ -1,5 +1,6 @@ import java.io.File; import java.io.FileNotFoundException; +import java.util.ArrayList; import java.util.Scanner; public class UG { @@ -27,6 +28,7 @@ public class UG { int time; boolean valid; boolean treated; + boolean noAdjacencies = false; static public int[] returnInsertable(Scanner myReader){ String data = myReader.nextLine(); @@ -50,6 +52,14 @@ public class UG { return toInsert; } + static public int[] returnZeroes(int size){ + int[] toInsert = new int[size]; + for(int i=0; i flags) { int index = 0; - try { // idea: pass a directory, which should contain files called - // graph_init, ugs_init, ... - File adj_init = new File(dir + "/adj_init.txt"); + try { + File adj_init = new File(dir + "/adj_init.txt"); //Adjacency input file Scanner readerAdj = new Scanner(adj_init); - File borders_init = new File(dir + "/border_init.txt"); + File borders_init = new File(dir + "/border_init.txt"); //Borders input file Scanner readerBorders = new Scanner(borders_init); File ext_init = new File(dir + "/external_init.txt"); @@ -110,38 +119,49 @@ public class UG { Scanner readerArea = new Scanner(area_init); File critFile0 = new File(dir + "/crit_file0.txt"); - Scanner reader0 = new Scanner(critFile0); + Scanner reader0 = null; + if(flags.get(0)) reader0 = new Scanner(critFile0); File critFile1 = new File(dir + "/crit_file1.txt"); - Scanner reader1 = new Scanner(critFile1); + Scanner reader1 = null; + if(flags.get(1)) reader1 = new Scanner(critFile1); File critFile2 = new File(dir + "/crit_file2.txt"); - Scanner reader2 = new Scanner(critFile2); + Scanner reader2 = null; + if(flags.get(2)) reader2 = new Scanner(critFile2); File critFile3 = new File(dir + "/crit_file3.txt"); - Scanner reader3 = new Scanner(critFile3); + Scanner reader3 = null; + if(flags.get(3)) reader3 = new Scanner(critFile3); File critFile4 = new File(dir + "/crit_file4.txt"); - Scanner reader4 = new Scanner(critFile4); + Scanner reader4 = null; + if(flags.get(4)) reader4 = new Scanner(critFile4); File critFile5 = new File(dir + "/crit_file5.txt"); - Scanner reader5 = new Scanner(critFile5); + Scanner reader5 = null; + if(flags.get(5)) reader5 = new Scanner(critFile5); File critFile6 = new File(dir + "/crit_file6.txt"); - Scanner reader6 = new Scanner(critFile6); + Scanner reader6 = null; + if(flags.get(6)) reader6 = new Scanner(critFile6); File critFile7 = new File(dir + "/crit_file7.txt"); - Scanner reader7 = new Scanner(critFile7); + Scanner reader7 = null; + if(flags.get(7)) reader7 = new Scanner(critFile7); File critFile8 = new File(dir + "/crit_file8.txt"); - Scanner reader8 = new Scanner(critFile8); + Scanner reader8 = null; + if(flags.get(8)) reader8 = new Scanner(critFile8); File critFile9 = new File(dir + "/crit_file9.txt"); - Scanner reader9 = new Scanner(critFile9); + Scanner reader9 = null; + if(flags.get(9)) reader9 = new Scanner(critFile9); File critFile10 = new File(dir + "/crit_file10.txt"); - Scanner reader10 = new Scanner(critFile10); + Scanner reader10 = null; + if(flags.get(10)) reader10 = new Scanner(critFile10); while (readerAdj.hasNextLine()) { UG toInsert = new UG(); @@ -165,28 +185,44 @@ public class UG { toInsert.years[i] = returnPeriods(str_split[i]); } - toInsert.crit0 = returnInsertable2(reader0); - toInsert.crit1 = returnInsertable2(reader1); - toInsert.crit2 = returnInsertable2(reader2); + int[] zeroArray = returnZeroes(toInsert.presc.length); + + if(flags.get(0)) toInsert.crit0 = returnInsertable2(reader0); + else toInsert.crit0 = zeroArray; + + if(flags.get(1)) toInsert.crit1 = returnInsertable2(reader1); + else toInsert.crit1 = zeroArray; - toInsert.crit3 = returnInsertable2(reader3); + if(flags.get(2)) toInsert.crit2 = returnInsertable2(reader2); + else toInsert.crit2 = zeroArray; - toInsert.crit4 = returnInsertable2(reader4); + if(flags.get(3)) toInsert.crit3 = returnInsertable2(reader3); + else toInsert.crit3 = zeroArray; - toInsert.crit5 = returnInsertable2(reader5); + if(flags.get(4)) toInsert.crit4 = returnInsertable2(reader4); + else toInsert.crit4 = zeroArray; - toInsert.crit6 = returnInsertable2(reader6); + if(flags.get(5)) toInsert.crit5 = returnInsertable2(reader5); + else toInsert.crit5 = zeroArray; - toInsert.crit7 = returnInsertable2(reader7); + if(flags.get(6)) toInsert.crit6 = returnInsertable2(reader6); + else toInsert.crit6 = zeroArray; - toInsert.crit8 = returnInsertable2(reader8); + if(flags.get(7)) toInsert.crit7 = returnInsertable2(reader7); + else toInsert.crit7 = zeroArray; - toInsert.crit9 = returnInsertable2(reader9); + if(flags.get(8)) toInsert.crit8 = returnInsertable2(reader8); + else toInsert.crit8 = zeroArray; - toInsert.crit10 = returnInsertable2(reader10); + if(flags.get(9)) toInsert.crit9 = returnInsertable2(reader9); + else toInsert.crit9 = zeroArray; + + if(flags.get(10)) toInsert.crit10 = returnInsertable2(reader10); + else toInsert.crit10 = zeroArray; if(toInsert.adj[0] == -1){ toInsert.valid = false; + toInsert.noAdjacencies = true; //If unit has no adjacencies it's still used but not in the main loop } array[index] = toInsert; @@ -202,18 +238,17 @@ public class UG { readerArea.close(); readerYears.close(); - - reader0.close(); - reader1.close(); - reader2.close(); - reader3.close(); - reader4.close(); - reader5.close(); - reader6.close(); - reader7.close(); - reader8.close(); - reader9.close(); - reader10.close(); + if(flags.get(0)) reader0.close(); + if(flags.get(1)) reader1.close(); + if(flags.get(2)) reader2.close(); + if(flags.get(3)) reader3.close(); + if(flags.get(4)) reader4.close(); + if(flags.get(5)) reader5.close(); + if(flags.get(6)) reader6.close(); + if(flags.get(7)) reader7.close(); + if(flags.get(8)) reader8.close(); + if(flags.get(9)) reader9.close(); + if(flags.get(10)) reader10.close(); -- libgit2 0.21.2