Moved algorithm into SolverConfig, multi configuration support

This commit is contained in:
Asriel Camora
2023-07-23 02:27:08 +04:00
parent bac96201d2
commit c344815e50
5 changed files with 51 additions and 25 deletions
+17
View File
@@ -570,4 +570,21 @@ public sealed class Solver
return solution;
}
public static SolverSolution Search(SolverConfig config, SimulationInput input, Action<ActionType>? actionCallback = null, CancellationToken token = default) =>
Search(config, new SimulationState(input), actionCallback, token);
public static SolverSolution Search(SolverConfig config, SimulationState state, Action<ActionType>? actionCallback = null, CancellationToken token = default)
{
Func<SolverConfig, SimulationState, Action<ActionType>?, CancellationToken, SolverSolution> func = config.Algorithm switch
{
SolverAlgorithm.Oneshot => SearchOneshot,
SolverAlgorithm.OneshotForked => SearchOneshotForked,
SolverAlgorithm.Stepwise => SearchStepwise,
SolverAlgorithm.StepwiseForked => SearchStepwiseForked,
SolverAlgorithm.StepwiseFurcated or _ => SearchStepwiseFurcated,
};
return func(config, state, actionCallback, token);
}
}