Commit f29f29eb authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

fix TargetChangerAlgorithm sanitiy checks

parent 9a321bd9
Pipeline #282459 passed with stages
in 127 minutes and 41 seconds
......@@ -140,7 +140,7 @@
"type" : "RECTANGLE"
},
"reachDistance" : 0.0,
"changeAlgorithmType" : "SORTED_SUB_LIST",
"changeAlgorithmType" : "SELECT_LIST",
"nextTarget" : [ 1 ],
"probabilityToChangeTarget" : [ 1.0 ]
} ],
......
......@@ -188,7 +188,7 @@
"type" : "RECTANGLE"
},
"reachDistance" : 0.0,
"changeAlgorithmType" : "SORTED_SUB_LIST",
"changeAlgorithmType" : "SELECT_LIST",
"nextTarget" : [ 3 ],
"probabilityToChangeTarget" : [ 0.0 ]
} ],
......
......@@ -188,7 +188,7 @@
"type" : "RECTANGLE"
},
"reachDistance" : 0.0,
"changeAlgorithmType" : "SORTED_SUB_LIST",
"changeAlgorithmType" : "SELECT_LIST",
"nextTarget" : [ 3 ],
"probabilityToChangeTarget" : [ 1.0 ]
} ],
......
......@@ -188,7 +188,7 @@
"type" : "RECTANGLE"
},
"reachDistance" : 0.0,
"changeAlgorithmType" : "SORTED_SUB_LIST",
"changeAlgorithmType" : "SELECT_LIST",
"nextTarget" : [ 3 ],
"probabilityToChangeTarget" : [ 0.5 ]
} ],
......
......@@ -26,7 +26,7 @@ public class SelectListTargetChanger extends BaseTargetChangerAlgorithm {
if (!inputIsValid) {
throw new IllegalArgumentException(String.format(
"The size of \"probabilitiesToChangeTarget\" must be 1 and totalTargets must be set. %s", TargetChangerAlgorithmType.SELECT_LIST) );
"The size of \"probabilitiesToChangeTarget\" must be 1 and nextTarget must be set. %s", TargetChangerAlgorithmType.SELECT_LIST) );
}
}
......
......@@ -27,7 +27,7 @@ public class SortedSubListTargetChanger extends BaseTargetChangerAlgorithm {
int totalProbabilities = targetChanger.getAttributes().getProbabilitiesToChangeTarget().size();
checkProbabilityIsNormalized();
boolean inputIsValid = (totalProbabilities > 1) && (totalProbabilities == totalTargets);
boolean inputIsValid = (totalProbabilities >= 1) && (totalProbabilities == totalTargets);
if (!inputIsValid) {
throw new IllegalArgumentException(String.format(
......
......@@ -42,6 +42,9 @@ public class TargetVersionV1_13 extends SimpleJsonTransformation {
if (probabilityToChangeTarget.size() < nextTarget.size()){
// use SELECT_LIST
changer.put("changeAlgorithmType", "SELECT_LIST");
} else if ((probabilityToChangeTarget.size() == nextTarget.size()) && (nextTarget.size() == 1)) {
// use SELECT_LIST
changer.put("changeAlgorithmType", "SELECT_LIST");
} else if (probabilityToChangeTarget.size() == nextTarget.size()){
// use SORTED_SUB_LIST
changer.put("changeAlgorithmType", "SORTED_SUB_LIST");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment