Skip to content

Commit

Permalink
Basic unimproved termination
Browse files Browse the repository at this point in the history
  • Loading branch information
triceo committed Mar 27, 2024
1 parent 437275c commit 52f33b2
Showing 1 changed file with 2 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
import ai.timefold.solver.core.impl.constructionheuristic.DefaultConstructionHeuristicPhaseFactory;
import ai.timefold.solver.core.impl.domain.solution.descriptor.SolutionDescriptor;
import ai.timefold.solver.core.impl.heuristic.HeuristicConfigPolicy;
import ai.timefold.solver.core.impl.phase.scope.AbstractPhaseScope;
import ai.timefold.solver.core.impl.score.director.InnerScoreDirectorFactory;
import ai.timefold.solver.core.impl.solver.ClassInstanceCache;
import ai.timefold.solver.core.impl.solver.DefaultSolver;
import ai.timefold.solver.core.impl.solver.event.SolverEventSupport;
import ai.timefold.solver.core.impl.solver.random.DefaultRandomFactory;
import ai.timefold.solver.core.impl.solver.recaller.BestSolutionRecallerFactory;
import ai.timefold.solver.core.impl.solver.scope.SolverScope;
import ai.timefold.solver.core.impl.solver.termination.AbstractTermination;
import ai.timefold.solver.core.impl.solver.termination.BasicPlumbingTermination;
import ai.timefold.solver.core.impl.solver.termination.TerminationFactory;

Expand Down Expand Up @@ -94,8 +92,8 @@ null, null, null, null, new Random(0), scoreDirectorFactory.getInitializingScore
solverScope.setSolverMetricSet(EnumSet.noneOf(SolverMetric.class));
solverScope.startingNow();
var solver = new DefaultSolver<>(EnvironmentMode.REPRODUCIBLE, new DefaultRandomFactory(RandomType.JDK, 0L),
bestSolutionRecaller, null, new NoopTermination<>(), List.of(constructionHeuristicPhase), solverScope,
null);
bestSolutionRecaller, null, new BasicPlumbingTermination<>(false), List.of(constructionHeuristicPhase),
solverScope, null);
constructionHeuristicPhase.setSolver(solver);

// Start the construction heuristic.
Expand All @@ -113,25 +111,4 @@ null, null, null, null, new Random(0), scoreDirectorFactory.getInitializingScore
}
}

private static final class NoopTermination<Solution_> extends AbstractTermination<Solution_> {
@Override
public boolean isSolverTerminated(SolverScope<Solution_> solverScope) {
return false;
}

@Override
public boolean isPhaseTerminated(AbstractPhaseScope<Solution_> phaseScope) {
return false;
}

@Override
public double calculateSolverTimeGradient(SolverScope<Solution_> solverScope) {
return 0;
}

@Override
public double calculatePhaseTimeGradient(AbstractPhaseScope<Solution_> phaseScope) {
return 0;
}
}
}

0 comments on commit 52f33b2

Please sign in to comment.