Skip to content

Commit

Permalink
Gracefully handle experiment declaration with 0 algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartinsanta committed Nov 21, 2024
1 parent e158ebd commit 6921f89
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ExperimentManager<S extends Solution<S, I>, I extends Instance> {

private static final int MAX_SHORTNAME_LENGTH = 30;

private static final Logger log = LoggerFactory.getLogger(DefaultOrchestrator.class);
private static final Logger log = LoggerFactory.getLogger(ExperimentManager.class);

/**
* List of experiments
Expand Down Expand Up @@ -66,6 +66,10 @@ public void runValidations() {
var matcher = Pattern.compile(experimentPattern).matcher(experimentName);
if (matcher.matches()) {
var algorithms = experiment.getAlgorithms();
if(algorithms.isEmpty()){
log.warn("Experiment {} declared in {} has no algorithms defined, ignoring", experimentName, experimentClass);
continue;
}
fillSolutionBuilder(algorithms, solutionBuilder);
validateAlgorithmNames(experiment.getName(), algorithms);
this.experiments.put(experimentName, new Experiment<>(experimentName, experimentClass, algorithms));
Expand All @@ -79,7 +83,7 @@ public void runValidations() {
if (experimentImplementations.isEmpty()) {
log.error("No experiment definitions found. Experiments are defined by extending AbstractExperiment<S, I>, see the docs for more information.");
} else {
log.error("Experiment found, but none passed filters. Verify that 'solver.experiments={}' is correct. Experiments detected: {}", experimentPattern, experimentImplementations.stream().map(AbstractExperiment::getName).toList());
log.error("At least one experiment definition was found, but none survived filters. Verify that 'solver.experiments={}' is correct and that experiments are valid. List of detected experiments: {}", experimentPattern, experimentImplementations.stream().map(AbstractExperiment::getName).toList());
}
}
}
Expand Down

0 comments on commit 6921f89

Please sign in to comment.