From fa807a38f175751a986338a9111046ded5c31610 Mon Sep 17 00:00:00 2001 From: Kevin Keller Date: Tue, 2 Oct 2018 12:38:29 +0200 Subject: [PATCH] added exit activity to swissland and checks on input data for sanity --- ABM.log.1 | 8 + data-swissland/Grossmargin_P4,00.csv | 378 ------------------ {projdir/DataBaseIn => data}/data_FARMIND.gms | 8 +- .../data_FARMINDLandData.gms | 19 +- projdir/DataModelIn/data_FARMIND.gms | 71 ++++ projdir/DataModelIn/data_FARMINDLandData.gms | 313 +++++++++++++++ .../{DataBaseIn => DataModelIn}/output.csv | 0 run_gams.bat | 8 +- run_java_ABM.bat | 3 - src/agent/Farm.java | 65 ++- src/main/Consumat.java | 37 +- .../MP_Interface.java | 1 - src/mathematical_programming/SwissLand.java | 28 +- src/mathematical_programming/WeedControl.java | 3 +- src/reader/FarmDataMatrix.java | 18 + src/reader/ReadData.java | 24 +- 16 files changed, 502 insertions(+), 482 deletions(-) create mode 100644 ABM.log.1 delete mode 100644 data-swissland/Grossmargin_P4,00.csv rename {projdir/DataBaseIn => data}/data_FARMIND.gms (94%) rename {projdir/DataBaseIn => data}/data_FARMINDLandData.gms (94%) create mode 100644 projdir/DataModelIn/data_FARMIND.gms create mode 100644 projdir/DataModelIn/data_FARMINDLandData.gms rename projdir/{DataBaseIn => DataModelIn}/output.csv (100%) diff --git a/ABM.log.1 b/ABM.log.1 new file mode 100644 index 00000000..639c5c10 --- /dev/null +++ b/ABM.log.1 @@ -0,0 +1,8 @@ +Oct 02, 2018 12:36:05 PM main.Consumat main +INFO: Starting FARMIND: version number: 0.8.6 +Oct 02, 2018 12:36:05 PM main.Consumat main +INFO: Year 1 simulation started +Oct 02, 2018 12:36:05 PM mathematical_programming.SwissLand runModel +INFO: Starting MP model +Oct 02, 2018 12:36:05 PM mathematical_programming.SwissLand runModel +INFO: Waiting for output generated by MP model diff --git a/data-swissland/Grossmargin_P4,00.csv b/data-swissland/Grossmargin_P4,00.csv deleted file mode 100644 index 875e02b6..00000000 --- a/data-swissland/Grossmargin_P4,00.csv +++ /dev/null @@ -1,378 +0,0 @@ -Municipality,GMAverage,Pre-Sow-Herbicide,Post-Sow-Herbicide -Ahaus , 857.18,spre5 ,spost1 -Beckum , 583.95,spre3 ,spost18 -Bruehl , 479.99,spre5 ,spost1 -Hoevelhof , 814.49,spre5 ,spost1 -Hopsten , 944.85,spre5 ,spost1 -Lippetal , 653.86,spre3 ,spost53 -Nottuln , 815.18,spre3 ,spost1 -Ostbevern , 940.93,spre5 ,spost1 -Greven , 961.16,spre5 ,spost18 -Hamm , 757.22,spre3 ,spost1 -Hamminkeln , 860.85,spre5 ,spost1 -Mechernich , 691.43,spre5 ,spost1 -Moenchenglad, 955.14,spre5 ,spost5 -Salzkotten , 829.75,spre3 ,spost1 -Selm , 909.61,spre3 ,spost52 -Lotte , 861.66,spre5 ,spost1 -Holzwickede , 945.21,spre5 ,spost5 -Juechen , 906.13,spre5 ,spost1 -Luedinghause, 803.47,spre3 ,spost1 -Hilden , 918.59,spre3 ,spost39 -Borgholzhaus, 782.25,spre5 ,spost1 -Kirchlengern, 863.99,spre3 ,spost33 -Marienmuenst, 821.73,spre5 ,spost1 -Sonsbeck , 931.69,spre5 ,spost14 -Straelen , 836.29,spre3 ,spost1 -Wuppertal , 905.24,spre5 ,spost1 -Suedlohn , 820.01,spre5 ,spost1 -Leverkusen , 852.57,spre5 ,spost1 -Schwerte , 877.60,spre5 ,spost1 -Engelskirche, 714.33,spre5 ,spost1 -Werl , 947.87,spre5 ,spost36 -Wesseling , 765.96,spre3 ,spost1 -Tecklenburg , 868.64,spre5 ,spost1 -Mettmann , 1016.04,spre3 ,spost1 -Bocholt , 955.29,spre5 ,spost14 -Schleiden , 568.85,spre5 ,spost1 -Ratingen , 930.28,spre3 ,spost1 -Meerbusch , 854.95,spre3 ,spost1 -Hellenthal , 533.47,spre5 ,spost1 -UebachPalenb, 887.72,spre5 ,spost22 -Bestwig , 720.73,spre5 ,spost1 -Lengerich , 832.38,spre5 ,spost1 -Radevormwald, 607.07,spre5 ,spost1 -Siegen , 868.38,spre5 ,spost16 -Soest , 979.33,spre5 ,spost13 -Issum , 807.04,spre3 ,spost1 -Waltrop , 921.19,spre5 ,spost37 -CastropRauxe, 847.17,spre3 ,spost1 -Nettetal , 813.75,spre3 ,spost1 -BadSalzuflen, 837.29,spre1 ,spost1 -Rahden , 744.24,spre5 ,spost1 -Steinfurt , 941.46,spre5 ,spost22 -Lemgo , 871.07,spre5 ,spost1 -Hoerstel , 882.12,spre5 ,spost1 -Nieheim , 807.50,spre5 ,spost1 -Steinheim , 832.91,spre5 ,spost1 -Ruethen , 676.54,spre5 ,spost1 -BadWuennenbe, 633.89,spre5 ,spost1 -Vettweiss , 798.06,spre5 ,spost1 -Luenen , 822.43,spre3 ,spost1 -Bochum , 885.50,spre3 ,spost1 -Delbrueck , 946.39,spre3 ,spost7 -Gangelt , 795.03,spre5 ,spost21 -Kerken , 792.11,spre3 ,spost1 -Horstmar , 820.97,spre5 ,spost1 -Barntrup , 849.23,spre5 ,spost7 -Ascheberg , 702.10,spre3 ,spost1 -Wenden , 786.90,spre5 ,spost1 -Drolshagen , 782.97,spre5 ,spost1 -Geseke , 736.47,spre3 ,spost1 -Kevelaer , 901.53,spre3 ,spost23 -Hille , 817.76,spre5 ,spost1 -Heinsberg , 771.47,spre5 ,spost1 -Goch , 883.99,spre3 ,spost1 -Neuenrade , 776.85,spre5 ,spost1 -Loehne , 934.36,spre3 ,spost28 -Windeck , 825.45,spre5 ,spost1 -Mettingen , 910.34,spre5 ,spost1 -Muenster , 761.22,spre5 ,spost1 -Alfter , 790.46,spre5 ,spost1 -Rheurdt , 825.25,spre3 ,spost1 -Rheine , 920.05,spre5 ,spost16 -Augustdorf , 683.89,spre5 ,spost1 -Stemwede , 779.39,spre5 ,spost39 -Troisdorf , 875.84,spre3 ,spost52 -LangenfeldRh, 799.66,spre3 ,spost1 -Extertal , 785.93,spre5 ,spost1 -Metelen , 891.87,spre5 ,spost1 -Wipperfuerth, 514.94,spre5 ,spost1 -Schoeppingen, 801.75,spre5 ,spost1 -Uedem , 993.72,spre3 ,spost53 -Froendenberg, 841.66,spre5 ,spost1 -Coesfeld , 871.60,spre5 ,spost37 -Kalkar , 863.05,spre3 ,spost1 -Sassenberg , 817.81,spre5 ,spost1 -Viersen , 879.74,spre5 ,spost22 -Buende , 798.52,spre3 ,spost1 -Oelde , 748.69,spre5 ,spost14 -SchiederSchw, 889.16,spre5 ,spost1 -Spenge , 903.12,spre3 ,spost7 -Wesel , 933.20,spre5 ,spost3 -WickedeRuhr , 1000.75,spre3 ,spost5 -Steinhagen , 764.27,spre5 ,spost1 -Bielefeld , 814.48,spre5 ,spost1 -Olpe , 767.35,spre5 ,spost1 -Werdohl , 832.58,spre5 ,spost1 -Kamen , 827.07,spre3 ,spost1 -Emsdetten , 842.21,spre5 ,spost1 -Brakel , 928.77,spre5 ,spost37 -Roedinghause, 979.84,spre3 ,spost12 -Xanten , 927.45,spre5 ,spost37 -Haan , 923.38,spre3 ,spost1 -HalleWestf , 899.03,spre5 ,spost5 -Gladbeck , 845.76,spre3 ,spost1 -Heimbach , 709.73,spre5 ,spost1 -Beelen , 779.77,spre5 ,spost1 -Medebach , 643.70,spre5 ,spost1 -NachrodtWibl, 824.75,spre5 ,spost1 -HornBadMeinb, 798.60,spre5 ,spost1 -Warstein , 752.20,spre5 ,spost1 -Luegde , 907.75,spre5 ,spost5 -Luedenscheid, 826.93,spre5 ,spost37 -Schwalmtal , 860.59,spre5 ,spost21 -Gummersbach , 498.52,spre5 ,spost1 -Ahlen , 605.15,spre3 ,spost1 -Senden , 745.54,spre3 ,spost1 -Werne , 785.89,spre3 ,spost1 -Iserlohn , 837.28,spre5 ,spost1 -Titz , 894.61,spre5 ,spost1 -Enger , 826.75,spre3 ,spost1 -Herford , 917.71,spre3 ,spost54 -Recke , 858.51,spre5 ,spost1 -Finnentrop , 734.89,spre5 ,spost1 -Waldfeucht , 807.24,spre5 ,spost37 -RhedaWiedenb, 759.94,spre5 ,spost1 -Brueggen , 816.19,spre5 ,spost1 -Erkelenz , 914.05,spre5 ,spost1 -Weeze , 914.35,spre3 ,spost23 -Wilnsdorf , 763.06,spre5 ,spost1 -Datteln , 929.08,spre3 ,spost51 -Borken , 843.22,spre5 ,spost1 -Bergkamen , 803.49,spre3 ,spost1 -Oberhausen , 841.24,spre5 ,spost1 -Wettringen , 865.26,spre5 ,spost1 -Attendorn , 770.24,spre5 ,spost1 -Herdecke , 856.83,spre3 ,spost1 -Bergheim , 809.45,spre5 ,spost1 -Much , 882.79,spre5 ,spost1 -Eitorf , 822.36,spre5 ,spost1 -Neuss , 972.06,spre5 ,spost18 -MendenSauerl, 855.70,spre5 ,spost1 -Wuelfrath , 944.85,spre5 ,spost1 -Lippstadt , 873.83,spre3 ,spost1 -Lichtenau , 621.89,spre5 ,spost1 -Hallenberg , 687.54,spre5 ,spost3 -Gevelsberg , 851.92,spre5 ,spost1 -Havixbeck , 936.71,spre5 ,spost14 -Petershagen , 624.61,spre5 ,spost1 -WertherWestf, 875.44,spre3 ,spost1 -Kleve , 896.42,spre3 ,spost23 -Verl , 815.40,spre5 ,spost1 -HerzebrockCl, 736.92,spre5 ,spost1 -Ibbenbueren , 849.97,spre5 ,spost1 -Erkrath , 1028.74,spre5 ,spost36 -Lennestadt , 709.33,spre5 ,spost1 -OerErkenschw, 798.82,spre3 ,spost1 -Huenxe , 873.79,spre3 ,spost1 -Lienen , 833.03,spre5 ,spost1 -Noervenich , 827.94,spre5 ,spost1 -Erndtebrueck, 652.57,spre5 ,spost1 -Marsberg , 787.83,spre5 ,spost3 -Everswinkel , 696.57,spre5 ,spost1 -Euskirchen , 749.07,spre5 ,spost1 -BadLippsprin, 644.54,spre5 ,spost1 -Huertgenwald, 640.90,spre5 ,spost1 -Plettenberg , 783.23,spre5 ,spost1 -Kalletal , 867.99,spre5 ,spost13 -GronauWestf , 898.84,spre5 ,spost1 -Herten , 844.05,spre3 ,spost1 -Doerentrup , 809.36,spre5 ,spost1 -Welver , 818.77,spre3 ,spost1 -Nideggen , 757.34,spre5 ,spost1 -Geilenkirche, 806.21,spre5 ,spost1 -Raesfeld , 823.57,spre3 ,spost1 -Versmold , 831.48,spre5 ,spost1 -Pulheim , 780.04,spre5 ,spost1 -Laer , 813.69,spre5 ,spost1 -Breckerfeld , 848.06,spre5 ,spost14 -Westerkappel, 1008.48,spre5 ,spost37 -Velbert , 929.75,spre5 ,spost1 -SundernSauer, 749.97,spre5 ,spost1 -Linnich , 868.44,spre5 ,spost1 -Detmold , 792.00,spre5 ,spost1 -Rosendahl , 735.86,spre5 ,spost1 -Espelkamp , 698.58,spre5 ,spost1 -BedburgHau , 863.97,spre3 ,spost1 -Paderborn , 710.98,spre5 ,spost21 -Beverungen , 804.39,spre5 ,spost1 -SanktAugusti, 896.70,spre5 ,spost36 -Niederzier , 949.76,spre3 ,spost3 -Elsdorf , 902.69,spre5 ,spost36 -Isselburg , 861.65,spre5 ,spost1 -EmmerichamRh, 800.87,spre3 ,spost1 -Wachtberg , 855.82,spre5 ,spost1 -BadMuenstere, 720.15,spre5 ,spost1 -Heiden , 912.93,spre5 ,spost12 -Wiehl , 769.50,spre5 ,spost1 -Netphen , 744.48,spre5 ,spost1 -Huellhorst , 891.60,spre3 ,spost1 -Bedburg , 864.16,spre5 ,spost1 -Huerth , 816.07,spre5 ,spost14 -Hilchenbach , 683.72,spre5 ,spost1 -Inden , 875.25,spre5 ,spost1 -Schmallenber, 618.71,spre5 ,spost1 -Hueckelhoven, 928.83,spre5 ,spost22 -Ennigerloh , 596.49,spre5 ,spost37 -Zuelpich , 723.84,spre5 ,spost1 -Olfen , 827.62,spre3 ,spost1 -Ense , 833.11,spre5 ,spost1 -Nordwalde , 835.46,spre5 ,spost1 -Warendorf , 717.18,spre5 ,spost1 -Sendenhorst , 660.87,spre3 ,spost1 -Witten , 914.47,spre5 ,spost16 -Willebadesse, 783.82,spre5 ,spost1 -Grevenbroich, 891.61,spre5 ,spost1 -Freudenberg , 796.93,spre5 ,spost1 -Stadtlohn , 870.62,spre5 ,spost14 -Bueren , 537.63,spre5 ,spost1 -Duelmen , 798.41,spre3 ,spost1 -Rheinberg , 901.07,spre3 ,spost21 -Morsbach , 832.36,spre5 ,spost1 -BadSassendor, 868.92,spre3 ,spost1 -Geldern , 796.93,spre3 ,spost1 -Lage , 821.60,spre5 ,spost1 -Burbach , 675.71,spre5 ,spost1 -Guetersloh , 767.87,spre5 ,spost1 -Schwelm , 899.55,spre5 ,spost1 -Frechen , 806.56,spre3 ,spost23 -Unna , 955.54,spre5 ,spost5 -PreussischOl, 852.00,spre5 ,spost1 -Anroechte , 684.24,spre5 ,spost1 -BadOeynhause, 883.96,spre3 ,spost1 -Saerbeck , 860.31,spre5 ,spost1 -Blankenheim , 625.31,spre5 ,spost1 -Korschenbroi, 897.19,spre5 ,spost1 -Kreuzau , 826.43,spre5 ,spost1 -Bergneustadt, 650.73,spre5 ,spost39 -Kirchhundem , 664.75,spre5 ,spost1 -Halver , 666.71,spre5 ,spost1 -Arnsberg , 855.23,spre5 ,spost22 -VoerdeNieder, 871.19,spre5 ,spost1 -Langenberg , 873.60,spre5 ,spost1 -Alpen , 927.18,spre3 ,spost12 -Warburg , 751.75,spre5 ,spost7 -Niederkruech, 798.60,spre5 ,spost1 -Langerwehe , 805.30,spre5 ,spost1 -Recklinghaus, 826.76,spre3 ,spost1 -SchlossHolte, 790.25,spre5 ,spost18 -Kreuztal , 765.95,spre5 ,spost1 -Ennepetal , 751.77,spre5 ,spost1 -Erwitte , 769.48,spre3 ,spost1 -Selfkant , 818.00,spre5 ,spost1 -BadBerleburg, 656.34,spre5 ,spost1 -Schermbeck , 823.42,spre3 ,spost1 -Luebbecke , 938.08,spre5 ,spost3 -Sprockhoevel, 901.21,spre5 ,spost1 -Meinerzhagen, 722.22,spre5 ,spost18 -Hattingen , 927.03,spre5 ,spost1 -Olsberg , 690.31,spre5 ,spost1 -Kall , 598.36,spre5 ,spost1 -Blomberg , 865.92,spre5 ,spost1 -BadLaasphe , 715.25,spre5 ,spost1 -NeunkirchenS, 929.25,spre5 ,spost14 -Schalksmuehl, 822.84,spre5 ,spost1 -Dortmund , 835.41,spre3 ,spost1 -Neunkirchen , 786.87,spre5 ,spost1 -Boenen , 822.11,spre3 ,spost1 -Rietberg , 862.02,spre5 ,spost1 -KampLintfort, 875.00,spre3 ,spost36 -Kranenburg , 811.98,spre3 ,spost1 -Willich , 942.30,spre5 ,spost12 -Drensteinfur, 688.78,spre3 ,spost7 -Minden , 820.08,spre5 ,spost1 -Moehnesee , 775.67,spre5 ,spost1 -Hemer , 797.24,spre5 ,spost1 -BadHonnef , 846.44,spre5 ,spost37 -Reichshof , 727.28,spre5 ,spost1 -Juelich , 834.64,spre5 ,spost1 -Borchen , 532.97,spre5 ,spost1 -Hiddenhausen, 775.48,spre3 ,spost1 -Nuembrecht , 880.14,spre5 ,spost1 -MonheimamRhe, 737.26,spre1 ,spost1 -NeukirchenVl, 812.28,spre3 ,spost1 -Rheinbach , 772.98,spre5 ,spost1 -HennefSieg , 828.33,spre5 ,spost1 -Swisttal , 745.46,spre5 ,spost1 -Lohmar , 801.47,spre5 ,spost1 -Weilerswist , 713.38,spre5 ,spost1 -Borgentreich, 675.71,spre5 ,spost1 -PortaWestfal, 838.16,spre3 ,spost1 -Merzenich , 886.51,spre5 ,spost1 -Brilon , 738.57,spre5 ,spost1 -Kaarst , 896.23,spre5 ,spost1 -Marl , 840.77,spre3 ,spost1 -Dorsten , 839.78,spre3 ,spost1 -Oerlinghause, 849.08,spre5 ,spost14 -Grefrath , 949.93,spre3 ,spost3 -Nettersheim , 600.17,spre5 ,spost1 -Rhede , 822.56,spre5 ,spost1 -Altena , 829.53,spre5 ,spost1 -WetterRuhr , 763.58,spre3 ,spost1 -BadDriburg , 832.24,spre5 ,spost5 -Ruppichterot, 875.24,spre5 ,spost1 -Siegburg , 809.20,spre3 ,spost1 -Hagen , 873.91,spre5 ,spost1 -Herscheid , 768.49,spre5 ,spost39 -Altenbeken , 617.28,spre5 ,spost1 -Meckenheim , 898.08,spre5 ,spost18 -Reken , 817.65,spre3 ,spost1 -Leopoldshoeh, 936.78,spre5 ,spost22 -Wegberg , 827.20,spre5 ,spost1 -Dueren , 899.39,spre5 ,spost1 -Ladbergen , 838.45,spre5 ,spost1 -Neuenkirchen, 842.31,spre5 ,spost21 -Lindlar , 634.33,spre5 ,spost1 -Kempen , 925.90,spre3 ,spost54 -Legden , 804.94,spre5 ,spost1 -Rommerskirch, 866.65,spre5 ,spost1 -Hueckeswagen, 665.54,spre5 ,spost1 -Wadersloh , 814.61,spre5 ,spost21 -Bornheim , 766.70,spre5 ,spost1 -Waldbroel , 856.61,spre5 ,spost1 -Telgte , 802.41,spre5 ,spost1 -Dormagen , 791.98,spre3 ,spost1 -Nordkirchen , 812.26,spre3 ,spost39 -Niederkassel, 896.99,spre5 ,spost13 -Balve , 789.91,spre5 ,spost1 -Billerbeck , 762.78,spre3 ,spost1 -Altenberge , 774.76,spre5 ,spost1 -Heiligenhaus, 961.18,spre5 ,spost1 -Ochtrup , 863.14,spre5 ,spost1 -Velen , 826.21,spre5 ,spost1 -Wassenberg , 847.14,spre5 ,spost13 -Harsewinkel , 806.21,spre5 ,spost1 -Erftstadt , 794.11,spre5 ,spost16 -Rees , 844.83,spre3 ,spost1 -Heek , 900.36,spre5 ,spost1 -Hoexter , 818.47,spre5 ,spost1 -Vlotho , 946.54,spre5 ,spost36 -Aldenhoven , 855.24,spre5 ,spost1 -EsloheSauerl, 664.60,spre5 ,spost1 -Dahlem , 551.77,spre5 ,spost14 -Gescher , 817.97,spre5 ,spost1 -Wachtendonk , 829.55,spre3 ,spost1 -Herne , 902.11,spre3 ,spost1 -HalternamSee, 899.18,spre3 ,spost18 -Toenisvorst , 853.36,spre3 ,spost1 -Moers , 832.52,spre3 ,spost1 -Schlangen , 657.38,spre5 ,spost1 -Meschede , 741.94,spre5 ,spost1 -Dinslaken , 985.71,spre5 ,spost22 -Kerpen , 823.87,spre5 ,spost36 -Koenigswinte, 836.97,spre5 ,spost1 -Kierspe , 622.68,spre5 ,spost1 -Marienheide , 394.87,spre5 ,spost1 -Winterberg , 597.09,spre5 ,spost14 -Aachen , 842.36,spre5 ,spost1 -Alsdorf , 903.65,spre5 ,spost21 -Baesweiler , 871.62,spre5 ,spost1 -Eschweiler , 920.34,spre5 ,spost1 -Herzogenrath, 829.97,spre5 ,spost1 -Monschau , 656.65,spre5 ,spost1 -Roetgen , 795.26,spre5 ,spost1 -Simmerath , 630.13,spre5 ,spost1 -StolbergRhld, 758.93,spre5 ,spost1 -Vreden , 817.29,spre5 ,spost1 -Wuerselen , 827.06,spre5 ,spost1 diff --git a/projdir/DataBaseIn/data_FARMIND.gms b/data/data_FARMIND.gms similarity index 94% rename from projdir/DataBaseIn/data_FARMIND.gms rename to data/data_FARMIND.gms index 85e00336..38beb460 100644 --- a/projdir/DataBaseIn/data_FARMIND.gms +++ b/data/data_FARMIND.gms @@ -1,9 +1,9 @@ Parameter FARMIND (s_agentenID) / -10110,215209.69 -10290,455089.50 -10310,97245.41 -11730,63013.96 +10110,-102123.48 +10290,-60104.62 +10310,-73750.52 +11730,-24276.86 11740,83810.94 11800,80311.90 11870,42466.04 diff --git a/projdir/DataBaseIn/data_FARMINDLandData.gms b/data/data_FARMINDLandData.gms similarity index 94% rename from projdir/DataBaseIn/data_FARMINDLandData.gms rename to data/data_FARMINDLandData.gms index dd0bd010..e9b99cee 100644 --- a/projdir/DataBaseIn/data_FARMINDLandData.gms +++ b/data/data_FARMINDLandData.gms @@ -1,27 +1,10 @@ Parameter data_FARMINDLandData(s_agentenID,s_pflanzen) / -10110,silomais, 9.56 -10110,andKulturen, 5.62 10110,andDauerkulturen, 1.10 -10110,wenigIntWiese, 0.45 -10110,naturWiese, 1.60 -10110,naturWeide, 0.70 -10110,forst, 3.74 -10110,hochstamm, 70.00 -10290,silomais, 10.74 -10290,futterrueben, 1.23 -10290,andKulturen, 12.37 -10290,naturWiese, 3.39 +10110,naturWeide, -0.14 10290,forst, 7.00 -10290,hochstamm, 150.07 -10310,wenigIntWiese, 12.99 -10310,naturWiese, 11.17 10310,soemmerung, 7.00 10310,forst, 5.84 -11730,wenigIntWiese, 2.01 -11730,naturWiese, 9.44 -11730,forst, 0.57 -11730,hochstamm, 35.00 11740,wenigIntWiese, 0.90 11740,naturWiese, 12.39 11740,forst, 1.17 diff --git a/projdir/DataModelIn/data_FARMIND.gms b/projdir/DataModelIn/data_FARMIND.gms new file mode 100644 index 00000000..38beb460 --- /dev/null +++ b/projdir/DataModelIn/data_FARMIND.gms @@ -0,0 +1,71 @@ +Parameter FARMIND (s_agentenID) / + +10110,-102123.48 +10290,-60104.62 +10310,-73750.52 +11730,-24276.86 +11740,83810.94 +11800,80311.90 +11870,42466.04 +12650,115583.89 +12691,14230.53 +13110,71308.12 +13220,30261.63 +14430,43845.31 +14990,139898.32 +15530,133785.53 +15730,121855.45 +15850,70226.87 +16450,253956.35 +16620,136864.77 +16850,72971.63 +17482,207109.82 +17723,48158.35 +18020,65773.43 +19970,120718.53 +20110,5198.30 +21160,36248.88 +21370,100607.38 +21820,64404.50 +22040,78216.60 +22650,182468.79 +22742,-8945.54 +23142,354009.56 +24410,146381.48 +24620,38946.72 +25190,481626.20 +25211,117910.17 +25330,62889.50 +25703,80831.47 +28320,59346.84 +28330,78502.27 +28760,450855.56 +29133,6785.91 +29372,-126940.79 +29490,174771.47 +29500,87691.98 +30080,255981.38 +30200,16249.41 +30470,46268.69 +30760,121861.76 +30790,954929.04 +31830,342518.33 +32051,47230.19 +32191,58506.64 +32933,20903.38 +32970,59066.61 +33270,77219.05 +33550,198079.32 +33790,56970.60 +33811,42523.34 +34590,91101.72 +35090,278949.31 +35352,17961.60 +35403,-11851.99 +35540,88672.80 +36473,64727.08 +36493,178211.76 +36570,133926.82 +36722,7220.49 +36970,-17994.37 +/; diff --git a/projdir/DataModelIn/data_FARMINDLandData.gms b/projdir/DataModelIn/data_FARMINDLandData.gms new file mode 100644 index 00000000..e9b99cee --- /dev/null +++ b/projdir/DataModelIn/data_FARMINDLandData.gms @@ -0,0 +1,313 @@ +Parameter data_FARMINDLandData(s_agentenID,s_pflanzen) / + +10110,andDauerkulturen, 1.10 +10110,naturWeide, -0.14 +10290,forst, 7.00 +10310,soemmerung, 7.00 +10310,forst, 5.84 +11740,wenigIntWiese, 0.90 +11740,naturWiese, 12.39 +11740,forst, 1.17 +11800,wenigIntWiese, 5.05 +11800,naturWiese, 15.90 +11800,soemmerung, 6.71 +11800,forst, 20.60 +11870,extWiese, 1.48 +11870,wenigIntWiese, 3.70 +11870,naturWiese, 18.13 +11870,soemmerung, 26.48 +11870,forst, 18.00 +12650,wenigIntWiese, 3.96 +12650,naturWiese, 27.23 +12650,soemmerung, 4.00 +12650,forst, 7.83 +12691,kunstwiese, 3.64 +12691,wenigIntWiese, 0.56 +12691,naturWiese, 3.81 +12691,forst, 1.47 +13110,silomais, 4.77 +13110,andKulturen, 0.02 +13110,wenigIntWiese, 0.74 +13110,naturWiese, 8.46 +13110,forst, 1.48 +13110,hochstamm, 56.00 +13110,gemuese, 4.73 +13220,extWiese, 0.60 +13220,hecken, 3.61 +13220,naturWiese, 10.67 +13220,forst, 14.61 +14430,wenigIntWiese, 1.05 +14430,naturWiese, 15.75 +14430,forst, 13.27 +14990,silomais, 5.32 +14990,andKulturen, 3.10 +14990,wenigIntWiese, 0.23 +14990,naturWiese, 2.94 +14990,forst, 2.44 +14990,hochstamm, 58.32 +15530,koernermais, 3.85 +15530,silomais, 5.69 +15530,andKulturen, 4.79 +15530,extWiese, 3.63 +15530,naturWiese, 0.22 +15730,silomais, 7.93 +15730,soja, 0.59 +15730,andKulturen, 2.67 +15730,extWiese, 7.78 +15730,hecken, 0.07 +15730,forst, 1.08 +15850,koernermais, 5.75 +15850,silomais, 4.74 +15850,hecken, 0.25 +15850,wenigIntWiese, 1.38 +15850,naturWiese, 10.14 +15850,forst, 0.42 +15850,gemuese, 1.06 +16450,silomais, 6.56 +16450,futterrueben, 0.04 +16450,andKulturen, 6.23 +16450,wenigIntWiese, 1.03 +16450,naturWiese, 6.17 +16450,naturWeide, 0.40 +16450,forst, 3.07 +16450,hochstamm, 40.00 +16620,silomais, 3.20 +16620,andKulturen, 2.99 +16620,naturWiese, 6.86 +16620,forst, 2.22 +16620,hochstamm, 60.03 +16850,obst, 0.29 +16850,beeren, 1.41 +16850,wenigIntWiese, 0.62 +16850,naturWiese, 1.26 +16850,naturWeide, 6.23 +16850,forst, 1.52 +17482,silomais, 3.26 +17482,sonnenblumen, 3.39 +17482,andKulturen, 5.67 +17482,extWiese, 3.21 +17482,naturWiese, 0.18 +17482,forst, 2.04 +17723,soja, 1.79 +17723,andKulturen, 3.60 +17723,extWiese, 0.63 +17723,naturWiese, 0.26 +17723,forst, 1.42 +18020,streueTorf, 0.15 +18020,hecken, 0.10 +18020,wenigIntWiese, 0.46 +18020,naturWiese, 15.33 +18020,forst, 6.50 +18020,hochstamm, 41.62 +19970,zuckerrueben, 4.65 +19970,sonnenblumen, 10.07 +19970,andKulturen, 1.47 +19970,extWiese, 1.14 +19970,hecken, 0.14 +19970,forst, 0.30 +20110,wenigIntWiese, 1.38 +20110,naturWiese, 10.19 +21160,wenigIntWiese, 0.28 +21160,naturWiese, 14.03 +21160,soemmerung, 5.40 +21160,forst, 5.48 +21370,wenigIntWiese, 8.11 +21370,naturWiese, 16.15 +21370,forst, 2.01 +21820,extWiese, 0.97 +21820,streueTorf, 1.10 +21820,hecken, 0.45 +21820,naturWiese, 10.21 +21820,forst, 0.23 +22040,silomais, 4.42 +22040,andKulturen, 0.88 +22040,wenigIntWiese, 0.53 +22040,naturWiese, 4.94 +22040,forst, 2.12 +22650,silomais, 6.57 +22650,andKulturen, 5.81 +22650,wenigIntWiese, 0.75 +22650,naturWiese, 7.02 +22650,forst, 0.25 +22650,hochstamm, 65.04 +22742,hecken, 0.55 +22742,naturWiese, 7.57 +22742,forst, 0.71 +22742,hochstamm, 17.99 +23142,silomais, 1.68 +23142,soja, 0.15 +23142,andKulturen, 3.87 +23142,wenigIntWiese, 4.51 +23142,naturWiese, 0.01 +23142,extWeide, 0.47 +23142,forst, 2.67 +24410,silomais, 1.82 +24410,andKulturen, 1.58 +24410,wenigIntWiese, 0.65 +24410,naturWiese, 14.27 +24410,hochstamm, 63.63 +24620,wenigIntWiese, 0.25 +24620,naturWiese, 19.85 +24620,hochstamm, 116.07 +25190,soja, 6.36 +25190,andKulturen, 11.04 +25190,reben, 4.66 +25190,extWiese, 3.91 +25190,forst, 1.67 +25211,reben, 15.10 +25211,extWiese, 3.06 +25211,forst, 1.80 +25330,reben, 9.06 +25330,extWiese, 0.36 +25330,forst, 0.91 +25703,reben, 4.84 +25703,hecken, 0.88 +25703,forst, 0.61 +28320,wenigIntWiese, 9.07 +28320,naturWiese, 10.63 +28320,forst, 1.84 +28330,zuckerrueben, 10.15 +28330,andKulturen, 0.40 +28330,tabak, 2.21 +28330,extWiese, 2.78 +28330,streueTorf, 0.09 +28330,hecken, 0.24 +28330,forst, 1.00 +28330,gemuese, 2.26 +28760,silomais, 6.16 +28760,andKulturen, 13.65 +28760,hecken, 0.02 +28760,wenigIntWiese, 1.10 +28760,naturWiese, 6.84 +28760,forst, 1.44 +28760,hochstamm, 82.00 +29133,hecken, 0.24 +29133,wenigIntWiese, 6.51 +29133,naturWiese, 3.56 +29372,hecken, 0.05 +29372,naturWiese, 1.35 +29372,naturWeide, 4.13 +29372,hochstamm, 135.00 +29490,silomais, 8.15 +29490,andKulturen, 5.57 +29490,naturWiese, 7.17 +29490,forst, 0.42 +29490,hochstamm, 146.23 +29500,silomais, 9.05 +29500,kunstwiese, 2.76 +29500,extWiese, 7.23 +29500,hecken, 0.05 +29500,naturWiese, 10.48 +29500,forst, 14.98 +30080,silomais, 4.32 +30080,andKulturen, 5.75 +30080,wenigIntWiese, 0.61 +30080,naturWiese, 5.96 +30080,hochstamm, 55.30 +30200,wenigIntWiese, 16.39 +30200,naturWiese, 1.90 +30200,forst, 12.65 +30470,hecken, 0.03 +30470,wenigIntWiese, 0.91 +30470,naturWiese, 12.55 +30470,forst, 1.71 +30760,silomais, 5.30 +30760,soja, 1.96 +30760,andKulturen, 2.49 +30760,extWiese, 3.25 +30760,forst, 1.85 +30790,andKulturen, 23.10 +30790,ackerbrache, 0.84 +30790,extWiese, 0.25 +30790,extWeide, 0.05 +30790,forst, 0.18 +30790,hochstamm, 5.00 +31830,silomais, 3.71 +31830,soja, 2.24 +31830,andKulturen, 4.07 +31830,wenigIntWiese, 4.90 +31830,forst, 3.36 +32051,silomais, 0.15 +32051,futterrueben, 0.15 +32051,andKulturen, 0.46 +32051,hecken, 0.09 +32051,naturWiese, 8.14 +32051,forst, 1.37 +32051,hochstamm, 36.04 +32191,silomais, 2.45 +32191,zuckerrueben, 0.55 +32191,andKulturen, 0.20 +32191,extWiese, 2.15 +32191,naturWiese, 3.62 +32191,forst, 1.58 +32933,wenigIntWiese, 0.36 +32933,naturWiese, 7.13 +32933,soemmerung, 2.49 +32933,forst, 3.00 +32933,hochstamm, 16.23 +32970,wenigIntWiese, 1.01 +32970,naturWiese, 13.18 +33270,extWiese, 0.73 +33270,naturWiese, 11.36 +33270,forst, 1.12 +33270,hochstamm, 90.00 +33550,silomais, 18.43 +33550,andKulturen, 4.41 +33550,extWiese, 5.48 +33550,streueTorf, 1.33 +33550,wenigIntWiese, 12.12 +33550,forst, 2.23 +33790,wenigIntWiese, 6.85 +33790,naturWiese, 10.37 +33811,extWiese, 1.19 +33811,naturWiese, 7.03 +34590,naturWiese, 14.51 +34590,forst, 1.23 +34590,hochstamm, 139.09 +35090,silomais, 6.08 +35090,andKulturen, 6.47 +35090,wenigIntWiese, 0.67 +35090,naturWiese, 15.17 +35090,hochstamm, 131.34 +35352,silomais, 2.89 +35352,andKulturen, 0.65 +35352,andDauerkulturen, 4.63 +35352,wenigIntWiese, 0.16 +35352,naturWiese, 1.47 +35352,hochstamm, 36.00 +35403,silomais, 1.41 +35403,andKulturen, 0.23 +35403,hecken, 0.08 +35403,naturWiese, 3.87 +35403,forst, 0.29 +35403,hochstamm, 49.00 +35540,silomais, 7.15 +35540,andKulturen, 3.18 +35540,hecken, 0.11 +35540,naturWiese, 5.96 +35540,forst, 0.88 +35540,hochstamm, 356.41 +36473,extWiese, 1.15 +36473,naturWeide, 3.94 +36473,forst, 2.55 +36493,andKulturen, 4.33 +36493,extWiese, 5.15 +36493,hecken, 0.12 +36493,naturWeide, 0.63 +36493,forst, 3.21 +36493,hochstamm, 19.93 +36570,silomais, 7.66 +36570,soja, 0.54 +36570,andKulturen, 3.93 +36570,extWiese, 2.16 +36570,forst, 1.25 +36722,extWiese, 5.27 +36722,streueTorf, 1.36 +36722,hecken, 0.19 +36722,naturWiese, 5.06 +36970,streueTorf, 0.86 +36970,hecken, 0.07 +36970,wenigIntWiese, 0.72 +36970,naturWiese, 21.93 +36970,forst, 0.34 +/; diff --git a/projdir/DataBaseIn/output.csv b/projdir/DataModelIn/output.csv similarity index 100% rename from projdir/DataBaseIn/output.csv rename to projdir/DataModelIn/output.csv diff --git a/run_gams.bat b/run_gams.bat index 0e14ed6b..fbf0b375 100644 --- a/run_gams.bat +++ b/run_gams.bat @@ -1,2 +1,8 @@ :: This command copies a gams results file so we can fake the resuls to allow program testing. -copy ".\data\Grossmargin_P4,00.csv" .\projdir \ No newline at end of file +copy ".\data\Grossmargin_P4,00.csv" .\projdir + +copy ".\data\data_FARMIND.gms" .\projdir\DataModelIn +copy ".\data\data_FARMINDLandData.gms" .\projdir\DataModelIn + +:: cd projdir +:: gams Fit_StratABM_Cal \ No newline at end of file diff --git a/run_java_ABM.bat b/run_java_ABM.bat index 69e176d5..81cd2cd2 100644 --- a/run_java_ABM.bat +++ b/run_java_ABM.bat @@ -1,9 +1,6 @@ :: This command calls a java jar file :: optional commands are :: -uncertainty :: if set to 0, then ABM will not use the dissimilarity calculations during simulations -:: -individual_learning :: if set to 0, then the ABM will not use individual learning for activities during simulation -:: -social_learning :: if set to 0, then the ABM will not use social learning for activities during simulation -:: -activity_preference :: if set to 0, then the ABM will not use activity preference during simulation java -jar ABM.jar -year 5 -modelName WEEDCONTROL -uncertainty 1 pause \ No newline at end of file diff --git a/src/agent/Farm.java b/src/agent/Farm.java index 2826205d..befb8757 100644 --- a/src/agent/Farm.java +++ b/src/agent/Farm.java @@ -30,7 +30,6 @@ public class Farm { private Location location; // geographic location of farm private double Satisfaction; // Satisfaction level of farm private List IncomeHistory; // list of previous income values - //private double Aspiration; // Aspiration level of the farm private double Activity_Dissimilarity; // Dissimilarity of this farm with respect to network for each Activity private double Income_Dissimilarity; // Dissimilarity of this farm with respect to network for each Income @@ -58,34 +57,33 @@ public class Farm { private double p_phi_plus ; // Parameter for the Phi Plus used for the Satisfaction Calculation private double p_phi_minus; // Parameter for the Phi Minus used for the Satisfaction Calculation private double p_fuzzy_size; // Parameter to control fuzzy logic size - - private static final Logger LOGGER = Logger.getLogger("FARMIND_LOGGING"); + private static final Logger LOGGER = Logger.getLogger("FARMIND_LOGGING"); // logger for system /** * This constructor sets up the parameters associated with a farm. * - * @param name: name of the farm agent - * @param location: location of the farm agent - * @param socialNetwork: social network of the agent shared among the population - * @param incomeHistory: income history for each agent - * @param farmingExperience: matrix of farming experience for each activity - * @param preferences: agent preference matrix for activities - * @param activities: list of all activities - * @param activity_tolerance: tolerance for activity differences - * @param income_tolerance: tolerance for income differences - * @param currentActivity: current activity for agent - * @param farmHead: person object to represent main farmer - * @param beta_l: parameter for fuzzy logic - * @param beta_s: parameter for fuzzy logic - * @param beta_p: parameter for fuzzy logic - * @param reference_income: parameter for agent to select high or low income levels - * @param aspiration_coef: aspiration value - * @param lambda: value for lambda for satisfaction - * @param alpha_plus: for satisfaction calculation - * @param alpha_minus: for satisfaction calculation - * @param phi_plus: for satisfaction calculation - * @param phi_minus: for satisfaction calculation - * @param fuzzy_size: how large of a fuzzy set to return + * @param name :: name of the farm agent + * @param location :: location of the farm agent + * @param socialNetwork :: social network of the agent shared among the population + * @param incomeHistory :: income history for each agent + * @param farmingExperience :: matrix of farming experience for each activity + * @param preferences :: agent preference matrix for activities + * @param activities :: list of all activities + * @param activity_tolerance :: tolerance for activity differences + * @param income_tolerance :: tolerance for income differences + * @param currentActivity :: current activity for agent + * @param farmHead :: person object to represent main farmer + * @param beta_l :: parameter for fuzzy logic + * @param beta_s :: parameter for fuzzy logic + * @param beta_p :: parameter for fuzzy logic + * @param reference_income :: parameter for agent to select high or low income levels + * @param aspiration_coef :: aspiration value + * @param lambda :: value for lambda for satisfaction + * @param alpha_plus :: for satisfaction calculation + * @param alpha_minus :: for satisfaction calculation + * @param phi_plus :: for satisfaction calculation + * @param phi_minus :: for satisfaction calculation + * @param fuzzy_size :: how large of a fuzzy set to return */ public Farm(String name, Location location, Graph socialNetwork, List incomeHistory, FarmDataMatrix farmingExperience, FarmDataMatrix preferences, List activities, double activity_tolerance, double income_tolerance, @@ -96,17 +94,14 @@ public Farm(String name, Location location, Graph socialNet this.setLocation(location); this.setNetwork(socialNetwork); this.setIncomeHistory(incomeHistory); - this.setExperience(farmingExperience); this.setPreferences(preferences); this.setActivities(activities); this.setCurrentActivity(currentActivity); this.setHead(farmHead); - this.setP_beta_l(beta_l); this.setP_beta_s(beta_s); this.setP_beta_p(beta_p); - this.setP_reference_income(reference_income); this.setP_aspiration_coef(aspiration_coef); this.setP_lambda(lambda); @@ -114,7 +109,6 @@ public Farm(String name, Location location, Graph socialNet this.setP_alpha_minus(alpha_minus); this.setP_phi_plus(phi_plus); this.setP_phi_minus(phi_minus); - this.setP_activity_tolerance_coef(activity_tolerance); this.setP_income_tolerance_coef(income_tolerance); this.setP_fuzzy_size(fuzzy_size); @@ -363,7 +357,6 @@ private void updateIncomeHistoryList (double income) { setIncomeHistory(income_hist); } - /** * Update personal income change rate over the previous time periods and include the current year. * Income is an array of [year1_income, year2_income, year3_income, ... yearN_income] @@ -512,9 +505,7 @@ public double init_learning_rate() { double delta = 0.005; double k_upper = 1; double k_lower = 0.1; - double ln_ratio = 0; - double memory_limit = this.getMemory(); while (k_upper > k_lower) { @@ -561,9 +552,6 @@ public List calc_q_set() { } // getters and setters for all fields -// public void setAspiration(double aspiration) { -// this.Aspiration = aspiration; -// } public void setActivity_Dissimilarity(double activity_dissimilarity) { this.Activity_Dissimilarity = activity_dissimilarity; } @@ -609,9 +597,6 @@ public void setNetwork(Graph network) { public double getActivity_Dissimilarity() { return this.Activity_Dissimilarity; } -// public double getAspiration() { -// return this.Aspiration; -// } public double getSatisfaction() { return this.Satisfaction; } @@ -747,19 +732,15 @@ public double getP_beta_p() { public void setP_beta_p(double p_beta_p) { this.p_beta_p = p_beta_p; } - public double getP_reference_income() { return p_reference_income; } - public void setP_reference_income(double p_reference_income) { this.p_reference_income = p_reference_income; } - public double getP_fuzzy_size() { return p_fuzzy_size; } - public void setP_fuzzy_size(double p_fuzzy_size) { this.p_fuzzy_size = p_fuzzy_size; } diff --git a/src/main/Consumat.java b/src/main/Consumat.java index d9a40b09..5cd20b1c 100644 --- a/src/main/Consumat.java +++ b/src/main/Consumat.java @@ -8,9 +8,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; - import org.apache.commons.cli.*; - import logging.ABMActivityLog; import logging.ABMTimeStepLog; import mathematical_programming.MP_Interface; @@ -23,7 +21,7 @@ /** * This class contains the main() method of this program. * Full simulation runs inside of the main() method by creating farm objects and making decisions for each farm. - * + * Each time period, update the farm and run the linear optimization model. */ public class Consumat { static long line_counter = 0; @@ -38,7 +36,6 @@ public static void main(String[] args) { LOGGER.info("Starting FARMIND: version number: 0.8.6"); CommandLine cmd = parseInput(args); // parse input arguments - ReadData reader = new ReadData(); // read all input data files List allFarms = reader.getFarms(); // build set of farms @@ -53,7 +50,7 @@ public static void main(String[] args) { initializePopulationIncomeChangeRate(allFarms); // initialize the farms with the input values before starting the full ABM simulation - for (int year = 1; year <= simYear; year++) { // run simulation for a set of years, getting updated income and activities from the MP model each iteration + for (int year = 1; year <= simYear; year++) { // run simulation for a set of years, getting updated income and activities from the MP model each iteration LOGGER.info(String.format("Year %d simulation started", year)); MP_Interface MP; @@ -150,6 +147,9 @@ public static void main(String[] args) { LOGGER.info("ABM Operation Complete."); } + /** + * Setup logging for system to allow easier debugging of issues caused by runtime decisions + */ private static void initializeLogging() { try { fh = new FileHandler("ABM.log"); @@ -169,6 +169,12 @@ private static void initializeLogging() { } } + /** + * Calculate average memory length for all agents in system. + * This is used to set an average crop price during simulation years. + * @param allFarms :: list of all farms in system + * @return memoryLength :: length of average memory in system for all farms + */ private static int averageMemoryLength(List allFarms) { int memoryLength = 0; @@ -177,7 +183,6 @@ private static int averageMemoryLength(List allFarms) { } memoryLength = memoryLength / allFarms.size(); - return memoryLength; } @@ -186,8 +191,8 @@ private static int averageMemoryLength(List allFarms) { * -year :: number of years of simulation * -modelName :: which specific optimization model to use * -uncertainty :: if set to 0, then ABM will not use the dissimilarity calculations during simulations - * @param args: command line arguments to control the system - * @return cmd: return the parsed command line as an object we can use later in the model + * @param args :: command line arguments to control the system + * @return cmd :: return the parsed command line as an object we can use later in the model */ public static CommandLine parseInput(String[] args) { @@ -229,9 +234,9 @@ public static CommandLine parseInput(String[] args) { return cmd; } - /** - * For the output log file, we update the name after 1 million lines. Excel is not able to parse CSV files with more than 1 Million lines of data + * For the output log file, we update the name after 1 million lines. + * Since Excel is not able to parse CSV files with more than 1 Million lines of data we need to add to the file name */ private static void updateLogFileName() { line_counter++; @@ -244,7 +249,7 @@ private static void updateLogFileName() { /** * This function initializes the income growth rate of the population (in a region) for all farms. - * @param allFarms: list of all farms in region + * @param allFarms :: list of all farms in region */ public static void initializePopulationIncomeChangeRate(List allFarms) { List differenceIncomeYears = new ArrayList(); @@ -275,8 +280,8 @@ public static void initializePopulationIncomeChangeRate(List allFarms) { /** * This function updates the income growth rates based on new income for farms. - * @param allFarms: list of all farms in region - * @param thisYearIncome: list of income values for all farms + * @param allFarms :: list of all farms in region + * @param thisYearIncome :: list of income values for all farms */ public static void updatePopulationIncomeChangeRate(List allFarms, List thisYearIncome) { List differenceIncomeYears = new ArrayList(); @@ -311,8 +316,8 @@ public static void updatePopulationIncomeChangeRate(List allFarms, List list) { double mean = 0; // mean value to return @@ -326,7 +331,7 @@ private static double mean(List list) { /** * This function creates generic file name so that version number can be appended to end. - * @return fileName + * @return fileName :: base name of output logging file */ public static String createFileName() { Calendar now = Calendar.getInstance(); // Gets the current date and time diff --git a/src/mathematical_programming/MP_Interface.java b/src/mathematical_programming/MP_Interface.java index 8e5c3eaa..b0e01cbc 100644 --- a/src/mathematical_programming/MP_Interface.java +++ b/src/mathematical_programming/MP_Interface.java @@ -23,5 +23,4 @@ public interface MP_Interface { public List> readMPActivities(List allFarms); public ArrayList getExitActivity(); - } diff --git a/src/mathematical_programming/SwissLand.java b/src/mathematical_programming/SwissLand.java index d246db63..a9724a65 100644 --- a/src/mathematical_programming/SwissLand.java +++ b/src/mathematical_programming/SwissLand.java @@ -101,7 +101,9 @@ public void runModel(int nFarm, int year, boolean pricingAverage, int memoryLeng this.editMPscript(nFarm, year); // edit the gams script with updated pricing information - File f = new File("projdir\\Grossmargin_P4,00.csv"); + File f = new File("projdir\\DataModelIn\\data_FARMIND.gms"); + f.delete(); + f = new File("projdir\\DataModelIn\\data_FARMINDLandData.gms"); f.delete(); LOGGER.info("Starting MP model"); @@ -129,7 +131,7 @@ public List readMPIncomes(List allFarms) { String Line; // read each line of the file individually ArrayList dataArray; // separate data line - File f = new File("projdir\\DatabaseIn\\data_FARMIND.GMS"); // actual results file + File f = new File("projdir\\DataModelIn\\data_FARMIND.gms"); // actual results file while (!f.exists()) {try { Thread.sleep(1000); // wait until the MP finishes running } catch (InterruptedException e) { @@ -137,7 +139,7 @@ public List readMPIncomes(List allFarms) { }} try { - Buffer = new BufferedReader(new FileReader("projdir\\DatabaseIn\\data_FARMIND.GMS")); + Buffer = new BufferedReader(new FileReader("projdir\\DataModelIn\\data_FARMIND.gms")); Line = Buffer.readLine(); Line = Buffer.readLine(); @@ -169,7 +171,7 @@ public List> readMPActivities(List allFarms) { List allPossibleActivities = reader.getActivityList(); // generated activity list with ID and name HashMap> map = new HashMap>(); - File f = new File("projdir\\DatabaseIn\\data_FARMINDLandData.gms"); // actual results file + File f = new File("projdir\\DataModelIn\\data_FARMINDLandData.gms"); // actual results file while (!f.exists()) {try { Thread.sleep(1000); // wait until the MP finishes running } catch (InterruptedException e) { @@ -177,7 +179,7 @@ public List> readMPActivities(List allFarms) { }} try { - Buffer = new BufferedReader(new FileReader("projdir\\DatabaseIn\\data_FARMINDLandData.gms")); + Buffer = new BufferedReader(new FileReader("projdir\\DataModelIn\\data_FARMINDLandData.gms")); Line = Buffer.readLine(); Line = Buffer.readLine(); @@ -191,7 +193,6 @@ public List> readMPActivities(List allFarms) { for(int i = 0; i < allPossibleActivities.size(); i++) { String name = dataArray.get(1); - if (allPossibleActivities.get(i).getName().equals(name) ) { int ID = allPossibleActivities.get(i).getID(); Activity p = new Activity(ID, name); @@ -213,8 +214,12 @@ public List> readMPActivities(List allFarms) { } // convert map to ordered list - for (Farm farm:allFarms) { - activitiesFromMP.add(map.get(farm.getFarmName())); + for (Farm farm:allFarms) { + if (map.get(farm.getFarmName()) != null) { + activitiesFromMP.add(map.get(farm.getFarmName())); + } else { + activitiesFromMP.add( getExitActivity() ); + } } return activitiesFromMP; @@ -222,8 +227,11 @@ public List> readMPActivities(List allFarms) { @Override public ArrayList getExitActivity() { - // TODO Auto-generated method stub - return null; + ArrayList activities = new ArrayList(); // list of all farm activities selected by MP model + Activity exit = new Activity(0,"exit_activity"); + activities.add(exit); + + return activities; } /** diff --git a/src/mathematical_programming/WeedControl.java b/src/mathematical_programming/WeedControl.java index 5acf5256..7cd61209 100644 --- a/src/mathematical_programming/WeedControl.java +++ b/src/mathematical_programming/WeedControl.java @@ -96,7 +96,7 @@ public List> readMPActivities(List allFarms) { public void inputsforMP(Farm farm, List possibleActivity) { int[][] output = new int[55][6]; - for (int i = 0; i<6; i++) { // set all the first row, except the last column, to 1 as the initialization strategies. + for (int i = 0; i<6; i++) { // set all the first row, except the last column, to 1 as the initialization strategies. output[0][i] = 1; } @@ -139,7 +139,6 @@ public void inputsforMP(Farm farm, List possibleActivity) { public ArrayList getExitActivity() { ArrayList activities = new ArrayList(); // list of all farm activities selected by MP model Activity exit = new Activity(0,"activity01"); - activities.add(exit); return activities; diff --git a/src/reader/FarmDataMatrix.java b/src/reader/FarmDataMatrix.java index f72c4500..eb3f291c 100644 --- a/src/reader/FarmDataMatrix.java +++ b/src/reader/FarmDataMatrix.java @@ -32,6 +32,24 @@ public double getFarmDataElementValue(String FarmID, String name) { return val; } + /** + * Number of farms in matrix + * @return count of farms in matrix + */ + public int sizeFarms() { + int size = elementFarmMap.size(); + return size; + } + + /** + * Number of activities in matrix + * @return count of activities in matrix + */ + public int sizeData() { + int size = dataElementNames.size(); + return size; + } + /** * Given a farmID and a name, set the value of that cell in the matrix. * diff --git a/src/reader/ReadData.java b/src/reader/ReadData.java index 384c6895..feed3e72 100644 --- a/src/reader/ReadData.java +++ b/src/reader/ReadData.java @@ -87,6 +87,21 @@ public List getFarms() { FarmDataMatrix preference = getPreferences(); FarmDataMatrix experience = getExperience(); + if( experience.sizeFarms() != preference.sizeFarms() ) { + LOGGER.severe("Exiting Farmind. Experience and preference list do not match in size. Please confirm input data."); + System.exit(0); + } + + if( activities.size() != preference.sizeData() ) { + LOGGER.severe("Exiting Farmind. Preference file and activity list do not match. Please confirm input data."); + System.exit(0); + } + + if( network.size() != preference.sizeFarms() ) { + LOGGER.severe("Exiting Farmind. Social network size and preferences do not match. Please confirm input data."); + System.exit(0); + } + // Read data files and create list of farms try { Calendar now = Calendar.getInstance(); // Gets the current date and time @@ -190,7 +205,7 @@ private boolean initializeFarmActivities(List farms) { farm_count_index = 0; while ((Line = Buffer.readLine()) != null) { farmParameters = CSVtoArrayList(Line); // Read farm's parameters line by line - List currentActivity = new ArrayList(); // each farm has list of activities + List currentActivity = new ArrayList(); // each farm has list of activities currentActivity.clear(); for (int k = 0; k < farmParameters.size(); k++) { @@ -336,7 +351,6 @@ private FarmDataMatrix getExperience() { } return experience; - } /** @@ -347,7 +361,6 @@ private FarmDataMatrix getExperience() { */ private List> getSocialNetworks(){ List> NetworkList = new ArrayList>(); - BufferedReader Buffer = null; String Line; ArrayList data; @@ -407,7 +420,7 @@ public List getActivityList() { Buffer = new BufferedReader(new FileReader(InitialPerformingYears)); Line = Buffer.readLine(); // first line to be deleted activityRow = CSVtoArrayList(Line); - int ID = 100; + int ID = 100; // initial ID value of 100 activityRow.remove(0); for (String act: activityRow) { ID = ID + 100; @@ -446,7 +459,4 @@ private static ArrayList CSVtoArrayList(String CSV) { } return Result; } - - - }