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.

DescentSolver.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package jobshop.solvers;
  2. import jobshop.Instance;
  3. import jobshop.Result;
  4. import jobshop.Solver;
  5. import jobshop.encodings.ResourceOrder;
  6. import java.util.List;
  7. public class DescentSolver implements Solver {
  8. /** A block represents a subsequence of the critical path such that all tasks in it execute on the same machine.
  9. * This class identifies a block in a ResourceOrder representation.
  10. *
  11. * Consider the solution in ResourceOrder representation
  12. * machine 0 : (0,1) (1,2) (2,2)
  13. * machine 1 : (0,2) (2,1) (1,1)
  14. * machine 2 : ...
  15. *
  16. * The block with : machine = 1, firstTask= 0 and lastTask = 1
  17. * Represent the task sequence : [(0,2) (2,1)]
  18. *
  19. * */
  20. static class Block {
  21. /** machine on which the block is identified */
  22. final int machine;
  23. /** index of the first task of the block */
  24. final int firstTask;
  25. /** index of the last task of the block */
  26. final int lastTask;
  27. Block(int machine, int firstTask, int lastTask) {
  28. this.machine = machine;
  29. this.firstTask = firstTask;
  30. this.lastTask = lastTask;
  31. }
  32. }
  33. /**
  34. * Represents a swap of two tasks on the same machine in a ResourceOrder encoding.
  35. *
  36. * Consider the solution in ResourceOrder representation
  37. * machine 0 : (0,1) (1,2) (2,2)
  38. * machine 1 : (0,2) (2,1) (1,1)
  39. * machine 2 : ...
  40. *
  41. * The swap with : machine = 1, t1= 0 and t2 = 1
  42. * Represent inversion of the two tasks : (0,2) and (2,1)
  43. * Applying this swap on the above resource order should result in the following one :
  44. * machine 0 : (0,1) (1,2) (2,2)
  45. * machine 1 : (2,1) (0,2) (1,1)
  46. * machine 2 : ...
  47. */
  48. static class Swap {
  49. // machine on which to perform the swap
  50. final int machine;
  51. // index of one task to be swapped
  52. final int t1;
  53. // index of the other task to be swapped
  54. final int t2;
  55. Swap(int machine, int t1, int t2) {
  56. this.machine = machine;
  57. this.t1 = t1;
  58. this.t2 = t2;
  59. }
  60. /** Apply this swap on the given resource order, transforming it into a new solution. */
  61. public void applyOn(ResourceOrder order) {
  62. throw new UnsupportedOperationException();
  63. }
  64. }
  65. @Override
  66. public Result solve(Instance instance, long deadline) {
  67. throw new UnsupportedOperationException();
  68. }
  69. /** Returns a list of all blocks of the critical path. */
  70. List<Block> blocksOfCriticalPath(ResourceOrder order) {
  71. throw new UnsupportedOperationException();
  72. }
  73. /** For a given block, return the possible swaps for the Nowicki and Smutnicki neighborhood */
  74. List<Swap> neighbors(Block block) {
  75. throw new UnsupportedOperationException();
  76. }
  77. }