From b2a525ce5ab95afe763f3c0773b94e023ae4bd44 Mon Sep 17 00:00:00 2001 From: rschoene <rene.schoene@tu-dresden.de> Date: Tue, 19 Jun 2018 14:27:22 +0200 Subject: [PATCH] Recent update for ACO solver. - smaller default population and iteration size - obey to timeout --- .../src/main/java/ir/ac/ui/eng/ACOSolver.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/jastadd-mquat-solver-aco/src/main/java/ir/ac/ui/eng/ACOSolver.java b/jastadd-mquat-solver-aco/src/main/java/ir/ac/ui/eng/ACOSolver.java index 3df22f1..687bac3 100644 --- a/jastadd-mquat-solver-aco/src/main/java/ir/ac/ui/eng/ACOSolver.java +++ b/jastadd-mquat-solver-aco/src/main/java/ir/ac/ui/eng/ACOSolver.java @@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit; */ public class ACOSolver implements BenchmarkableSolver { - int population_size = 100000; - int iteration_size = 20; + int population_size = 5; + int iteration_size = 1; private static final Logger logger = LogManager.getLogger(ACOSolver.class); @@ -120,6 +120,11 @@ public class ACOSolver implements BenchmarkableSolver { for (int pop = 0; pop < population_size; pop++) { + if (stopWatch.time(TimeUnit.MILLISECONDS) > maxSolvingTime) { + timedOut = true; + break; + } + logger.trace("pop: {}", pop); Solution currentSolution = new Solution(); currentSolution.setModel(model); @@ -197,6 +202,11 @@ public class ACOSolver implements BenchmarkableSolver { } for (int iteration = 0; iteration < iteration_size; iteration++) { + if (stopWatch.time(TimeUnit.MILLISECONDS) > maxSolvingTime) { + timedOut = true; + break; + } + List<Ant> population = new ArrayList<>(); for (int i = 0; i < currentSolutions.size(); i++) { Ant ant = new Ant(i, currentSolutions.get(i), currentPossibleResources.get(i), currentEta.get(i), currentSort.get(i), numAssignments); @@ -227,11 +237,8 @@ public class ACOSolver implements BenchmarkableSolver { antSolution.computeObjective()); } } - ant = null; } }); - population = null; - System.gc(); } logger.info("Number of total software solutions: {}", numTotalSoftwareSolutions); -- GitLab