From 9f49b96fa4da274b3f17ed3095dea9302746b28c Mon Sep 17 00:00:00 2001 From: oblonski Date: Wed, 22 Apr 2015 11:21:43 +0200 Subject: [PATCH] remove tests based on probabilities --- .../jsprit/core/algorithm/box/JspritTest.java | 144 +++++++++--------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/box/JspritTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/box/JspritTest.java index d81c866b..17bf10c1 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/box/JspritTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/box/JspritTest.java @@ -51,78 +51,78 @@ public class JspritTest { } - @Test - public void defaultStrategyProbabilitiesShouldWork_(){ - Service s = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1,1)).build(); - Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(1,2)).build(); - VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0,0)).build(); - VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(v).addJob(s2).addJob(s).build(); - VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); - vra.setMaxIterations(5000); - final Map counts = new HashMap(); - vra.addListener(new StrategySelectedListener() { - - @Override - public void informSelectedStrategy(SearchStrategy.DiscoveredSolution discoveredSolution, VehicleRoutingProblem vehicleRoutingProblem, Collection vehicleRoutingProblemSolutions) { - count(discoveredSolution.getStrategyId()); - } - - private void count(String strategyId) { - if(!counts.containsKey(strategyId)) counts.put(strategyId,1); - Integer integer = counts.get(strategyId); - counts.put(strategyId, integer +1); - } - - }); - vra.searchSolutions(); - Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.RADIAL_BEST.toString())); - Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.WORST_BEST.toString())); - Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.CLUSTER_BEST.toString())); - Integer randomBestCounts = counts.get(Jsprit.Strategy.RANDOM_BEST.toString()); - Assert.assertEquals(5000.*0.5/3.5,(double) randomBestCounts,100); - Assert.assertEquals(5000.*0.5/3.5,(double) counts.get(Jsprit.Strategy.RANDOM_REGRET.toString()),100); - Assert.assertEquals(5000.*0.5/3.5,(double) counts.get(Jsprit.Strategy.RADIAL_REGRET.toString()),100); - Assert.assertEquals(5000.*1./3.5,(double) counts.get(Jsprit.Strategy.WORST_REGRET.toString()),100); - Assert.assertEquals(5000.*1./3.5,(double) counts.get(Jsprit.Strategy.CLUSTER_REGRET.toString()),100); - - } - - @Test - public void whenChangingStratProb_itShouldBeReflected(){ - Service s = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1,1)).build(); - Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(1,2)).build(); - VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0,0)).build(); - VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(v).addJob(s2).addJob(s).build(); - VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp) - .setProperty(Jsprit.Strategy.RANDOM_BEST,"100.").buildAlgorithm(); - vra.setMaxIterations(5000); - final Map counts = new HashMap(); - vra.addListener(new StrategySelectedListener() { - - @Override - public void informSelectedStrategy(SearchStrategy.DiscoveredSolution discoveredSolution, VehicleRoutingProblem vehicleRoutingProblem, Collection vehicleRoutingProblemSolutions) { - count(discoveredSolution.getStrategyId()); - } - - private void count(String strategyId) { - if(!counts.containsKey(strategyId)) counts.put(strategyId,1); - Integer integer = counts.get(strategyId); - counts.put(strategyId, integer +1); - } - - }); - vra.searchSolutions(); - Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.RADIAL_BEST.toString())); - Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.WORST_BEST.toString())); - Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.CLUSTER_BEST.toString())); - Integer randomBestCounts = counts.get(Jsprit.Strategy.RANDOM_BEST.toString()); - Assert.assertEquals(5000.*100./103.,(double) randomBestCounts,100); - Assert.assertEquals(5000.*0.5/103.,(double) counts.get(Jsprit.Strategy.RANDOM_REGRET.toString()),100); - Assert.assertEquals(5000.*0.5/103.,(double) counts.get(Jsprit.Strategy.RADIAL_REGRET.toString()),100); - Assert.assertEquals(5000.*1./103.,(double) counts.get(Jsprit.Strategy.WORST_REGRET.toString()),100); - Assert.assertEquals(5000.*1./103.,(double) counts.get(Jsprit.Strategy.CLUSTER_REGRET.toString()),100); - - } +// @Test +// public void defaultStrategyProbabilitiesShouldWork_(){ +// Service s = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1,1)).build(); +// Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(1,2)).build(); +// VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0,0)).build(); +// VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(v).addJob(s2).addJob(s).build(); +// VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); +// vra.setMaxIterations(5000); +// final Map counts = new HashMap(); +// vra.addListener(new StrategySelectedListener() { +// +// @Override +// public void informSelectedStrategy(SearchStrategy.DiscoveredSolution discoveredSolution, VehicleRoutingProblem vehicleRoutingProblem, Collection vehicleRoutingProblemSolutions) { +// count(discoveredSolution.getStrategyId()); +// } +// +// private void count(String strategyId) { +// if(!counts.containsKey(strategyId)) counts.put(strategyId,1); +// Integer integer = counts.get(strategyId); +// counts.put(strategyId, integer +1); +// } +// +// }); +// vra.searchSolutions(); +// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.RADIAL_BEST.toString())); +// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.WORST_BEST.toString())); +// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.CLUSTER_BEST.toString())); +// Integer randomBestCounts = counts.get(Jsprit.Strategy.RANDOM_BEST.toString()); +// Assert.assertEquals(5000.*0.5/3.5,(double) randomBestCounts,100); +// Assert.assertEquals(5000.*0.5/3.5,(double) counts.get(Jsprit.Strategy.RANDOM_REGRET.toString()),100); +// Assert.assertEquals(5000.*0.5/3.5,(double) counts.get(Jsprit.Strategy.RADIAL_REGRET.toString()),100); +// Assert.assertEquals(5000.*1./3.5,(double) counts.get(Jsprit.Strategy.WORST_REGRET.toString()),100); +// Assert.assertEquals(5000.*1./3.5,(double) counts.get(Jsprit.Strategy.CLUSTER_REGRET.toString()),100); +// +// } +// +// @Test +// public void whenChangingStratProb_itShouldBeReflected(){ +// Service s = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1,1)).build(); +// Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(1,2)).build(); +// VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0,0)).build(); +// VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(v).addJob(s2).addJob(s).build(); +// VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp) +// .setProperty(Jsprit.Strategy.RANDOM_BEST,"100.").buildAlgorithm(); +// vra.setMaxIterations(5000); +// final Map counts = new HashMap(); +// vra.addListener(new StrategySelectedListener() { +// +// @Override +// public void informSelectedStrategy(SearchStrategy.DiscoveredSolution discoveredSolution, VehicleRoutingProblem vehicleRoutingProblem, Collection vehicleRoutingProblemSolutions) { +// count(discoveredSolution.getStrategyId()); +// } +// +// private void count(String strategyId) { +// if(!counts.containsKey(strategyId)) counts.put(strategyId,1); +// Integer integer = counts.get(strategyId); +// counts.put(strategyId, integer +1); +// } +// +// }); +// vra.searchSolutions(); +// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.RADIAL_BEST.toString())); +// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.WORST_BEST.toString())); +// Assert.assertTrue(!counts.containsKey(Jsprit.Strategy.CLUSTER_BEST.toString())); +// Integer randomBestCounts = counts.get(Jsprit.Strategy.RANDOM_BEST.toString()); +// Assert.assertEquals(5000.*100./103.,(double) randomBestCounts,100); +// Assert.assertEquals(5000.*0.5/103.,(double) counts.get(Jsprit.Strategy.RANDOM_REGRET.toString()),100); +// Assert.assertEquals(5000.*0.5/103.,(double) counts.get(Jsprit.Strategy.RADIAL_REGRET.toString()),100); +// Assert.assertEquals(5000.*1./103.,(double) counts.get(Jsprit.Strategy.WORST_REGRET.toString()),100); +// Assert.assertEquals(5000.*1./103.,(double) counts.get(Jsprit.Strategy.CLUSTER_REGRET.toString()),100); +// +// } @Test public void whenActivatingStrat_itShouldBeReflected(){