diff --git a/control.properties b/control.properties index 274397f..b614683 100644 --- a/control.properties +++ b/control.properties @@ -4,4 +4,5 @@ precalc_MPdata_folder = data/data-precalculated-test/MPdata uncertainty = 1 year = 2 project_folder = projdir +noOptOut = 0 debug = 0 diff --git a/src/main/java/farmind/agent/Farm.java b/src/main/java/farmind/agent/Farm.java index e85ea3d..b313a79 100644 --- a/src/main/java/farmind/agent/Farm.java +++ b/src/main/java/farmind/agent/Farm.java @@ -150,7 +150,7 @@ public List decideActivitySet(List allFarms, Properties cmd) { FuzzyLogicCalculator fuzzyLogicCalc = new FuzzyLogicCalculator(this, allFarms); // calculator for the activity selection // modified simulation using only satisfaction - if ( Integer.parseInt(cmd.getProperty("uncertainty")) == 0) { + if (cmd.getProperty("uncertainty").equals("0")) { if (this.Satisfaction >= this.getP_aspiration_coef() ) { this.strategy = 4; //REPETITION for (int i = 0; i < this.getCurrentActivity().size(); i++) { @@ -173,8 +173,10 @@ public List decideActivitySet(List allFarms, Properties cmd) { // Full simulation using dissimilarity and satisfaction else { - if ( (this.Activity_Dissimilarity >= this.p_activity_tolerance_coef) || (this.Income_Dissimilarity >= this.p_income_tolerance_coef) ) { - if (cmd.getProperty("noOptOut") == "true" || this.Satisfaction >= this.getP_aspiration_coef()) { + if (this.Activity_Dissimilarity >= this.p_activity_tolerance_coef + || this.Income_Dissimilarity >= this.p_income_tolerance_coef) { + if (cmd.getProperty("noOptOut").equals("1") + || this.Satisfaction >= this.getP_aspiration_coef()) { this.strategy = 2; //IMITATION ActivitySet = fuzzyLogicCalc.getImitationActivities(); } diff --git a/src/test/java/farmind/testing/FarmTests.java b/src/test/java/farmind/testing/FarmTests.java index 9bd190a..6c220e1 100644 --- a/src/test/java/farmind/testing/FarmTests.java +++ b/src/test/java/farmind/testing/FarmTests.java @@ -190,6 +190,21 @@ public void testOptOutDecision() { assertEquals(strat, 1); } + @Test + public void testNoOptOutDecision() { + Farm farm = allFarms.get(0); + + farm.setSatisfaction(-1); + farm.setActivity_Dissimilarity(10); + farm.setIncome_Dissimilarity(0); + + cmd.setProperty("noOptOut", "1"); + + farm.decideActivitySet(allFarms,cmd); + int strat = farm.getStrategy(); + assertEquals(strat, 2); + } + @Test public void testRepetionDecisionNoUncertainty() throws FileNotFoundException, IOException { Farm farm = allFarms.get(0); diff --git a/test_data/control.properties b/test_data/control.properties index fcd559c..10f7bba 100644 --- a/test_data/control.properties +++ b/test_data/control.properties @@ -4,4 +4,5 @@ uncertainty = 1 year = 5 start_year_simulation = 2019 project_folder = projdir -debug = 1 \ No newline at end of file +noOptOut = 0 +debug = 1