Skip to content

Commit

Permalink
MultiStartAlgorithmBuilder: use internal algorithm name by default in…
Browse files Browse the repository at this point in the history
…stead of a random string
  • Loading branch information
rmartinsanta committed Jan 26, 2024
1 parent 328fa61 commit d05be32
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import es.urjc.etsii.grafo.algorithms.Algorithm;
import es.urjc.etsii.grafo.io.Instance;
import es.urjc.etsii.grafo.solution.Solution;
import es.urjc.etsii.grafo.util.StringUtil;

/**
* Multi-start algorithm builder based on Java Builder Pattern
Expand All @@ -16,7 +15,7 @@ public class MultiStartAlgorithmBuilder<S extends Solution<S, I>, I extends Inst
/**
* Name of the algorithm
*/
private String name = StringUtil.randomAlgorithmName();
private String name;

/**
* Maximum number of iterations, set by default to 1073741823
Expand Down Expand Up @@ -90,6 +89,12 @@ public MultiStartAlgorithmBuilder<S, I> withMaxIterationsWithoutImproving(int ma
* @return the multistart algorithm
*/
public MultiStartAlgorithm<S, I> build(Algorithm<S, I> algorithm) {
if(algorithm == null){
throw new IllegalArgumentException("Algorithm cannot be null");
}
if(name == null){
name = "MS" + algorithm.getName();
}
return new MultiStartAlgorithm<>(name, algorithm, maxIterations, minIterations, maxIterationsWithoutImproving);
}
}

0 comments on commit d05be32

Please sign in to comment.