No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Solver.java 1.1KB

1234567891011121314151617181920212223242526272829
  1. package jobshop.solvers;
  2. import jobshop.Instance;
  3. import jobshop.Result;
  4. /** Common interface that must implemented by all solvers. */
  5. public interface Solver {
  6. /** Look for a solution until blocked or a deadline has been met.
  7. *
  8. * @param instance Jobshop instance that should be solved.
  9. * @param deadline Absolute time at which the solver should have returned a solution.
  10. * This time is in milliseconds and can be compared with System.currentTimeMilliseconds()
  11. * @return A Result containing the solution found and an explanation of why the solver exited.
  12. */
  13. Result solve(Instance instance, long deadline);
  14. /** Static factory method to create a new solver based on its name. */
  15. static Solver getSolver(String name) {
  16. switch (name) {
  17. case "basic": return new BasicSolver();
  18. case "random": return new RandomSolver();
  19. case "spt": return new GreedySolver(GreedySolver.Priority.SPT);
  20. // TODO: add new solvers
  21. default: throw new RuntimeException("Unknown solver: "+ name);
  22. }
  23. }
  24. }