From 69537d109c866c36ec920f65652150b6a264685e Mon Sep 17 00:00:00 2001 From: oblonski Date: Thu, 11 May 2017 16:42:48 +0200 Subject: [PATCH] add option to set abs. initial threshold --- .../jsprit/core/algorithm/box/Jsprit.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/box/Jsprit.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/box/Jsprit.java index 724c989b..14e33fd3 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/box/Jsprit.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/box/Jsprit.java @@ -112,6 +112,7 @@ public class Jsprit { WORST_MAX_SHARE("worst.max_share"), THRESHOLD_ALPHA("threshold.alpha"), THRESHOLD_INI("threshold.ini"), + THRESHOLD_INI_ABS("threshold.ini_abs"), INSERTION_NOISE_LEVEL("insertion.noise_level"), INSERTION_NOISE_PROB("insertion.noise_prob"), RUIN_WORST_NOISE_LEVEL("worst.noise_level"), @@ -602,15 +603,19 @@ public class Jsprit { IterationStartsListener schrimpfThreshold = null; if(acceptor == null) { final SchrimpfAcceptance schrimpfAcceptance = new SchrimpfAcceptance(1, toDouble(getProperty(Parameter.THRESHOLD_ALPHA.toString()))); - schrimpfThreshold = new IterationStartsListener() { - @Override - public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection solutions) { - if (i == 1) { - double initialThreshold = Solutions.bestOf(solutions).getCost() * toDouble(getProperty(Parameter.THRESHOLD_INI.toString())); - schrimpfAcceptance.setInitialThreshold(initialThreshold); + if (properties.containsKey(Parameter.THRESHOLD_INI_ABS.toString())) { + schrimpfAcceptance.setInitialThreshold(Double.valueOf(properties.getProperty(Parameter.THRESHOLD_INI_ABS.toString()))); + } else { + schrimpfThreshold = new IterationStartsListener() { + @Override + public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection solutions) { + if (i == 1) { + double initialThreshold = Solutions.bestOf(solutions).getCost() * toDouble(getProperty(Parameter.THRESHOLD_INI.toString())); + schrimpfAcceptance.setInitialThreshold(initialThreshold); + } } - } - }; + }; + } acceptor = schrimpfAcceptance; }