22
33import ai .timefold .solver .core .api .domain .entity .PlanningEntity ;
44import ai .timefold .solver .core .api .domain .lookup .PlanningId ;
5- import ai .timefold .solver .core .api .domain .variable .IndexShadowVariable ;
5+ import ai .timefold .solver .core .api .domain .variable .InverseRelationShadowVariable ;
66import ai .timefold .solver .core .api .domain .variable .PreviousElementShadowVariable ;
77import ai .timefold .solver .core .api .domain .variable .ShadowSources ;
88import ai .timefold .solver .core .api .domain .variable .ShadowVariable ;
@@ -20,15 +20,15 @@ public class Job {
2020 private int id ;
2121 @ JsonIdentityReference (alwaysAsId = true )
2222 private Machine [] allMachines ;
23- @ IndexShadowVariable (sourceVariableName = "jobs" )
23+ @ InverseRelationShadowVariable (sourceVariableName = "jobs" )
2424 @ JsonIgnore
25- private Integer index ;
25+ private Machine machine ;
2626 @ PreviousElementShadowVariable (sourceVariableName = "jobs" )
2727 @ JsonIgnore
2828 private Job previousJob ;
29- @ ShadowVariable (supplierName = "updateMakespan " )
29+ @ ShadowVariable (supplierName = "updateCompletionTime " )
3030 @ JsonIgnore
31- private JobMakespan makespan ;
31+ private JobCompletionTime completionTime ;
3232 private int processTimeSum = 0 ;
3333
3434 public Job () {
@@ -55,17 +55,17 @@ public void setPreviousJob(Job previousJob) {
5555 this .previousJob = previousJob ;
5656 }
5757
58- public JobMakespan getMakespan () {
59- return makespan ;
58+ public JobCompletionTime getCompletionTime () {
59+ return completionTime ;
6060 }
6161
62- public void setMakespan ( JobMakespan makespan ) {
63- this .makespan = makespan ;
62+ public void setCompletionTime ( JobCompletionTime completionTime ) {
63+ this .completionTime = completionTime ;
6464 }
6565
6666 public int getProcessingTimeSum () {
6767 if (processTimeSum == 0 ) {
68- for (Machine allMachine : allMachines ) {
68+ for (var allMachine : allMachines ) {
6969 processTimeSum += allMachine .getProcessTime (id );
7070 }
7171 }
@@ -77,52 +77,51 @@ public int getProcessingTime(int machineId) {
7777 }
7878
7979 @ JsonIgnore
80- @ ShadowSources (value = { "previousJob.makespan " , "index " })
81- public JobMakespan updateMakespan () {
82- if (index == null ) {
80+ @ ShadowSources (value = { "previousJob.completionTime " , "machine " })
81+ public JobCompletionTime updateCompletionTime () {
82+ if (machine == null ) {
8383 return null ;
8484 }
85- var newMakespan = new JobMakespan (allMachines .length );
85+ var newCompletionTime = new JobCompletionTime (allMachines .length );
8686 // A machine can perform only one job at a time,
8787 // and a job can only start on one machine after finishing the process at the previous machine.
88- // The makespan of this job in the first machine depends only on the previous job makespan .
88+ // The completion time of this job in the first machine depends only on the previous job completion time .
8989 // It can only start after the previous job is completed.
90- var newPreviousMakespan = newMakespan . setMakespan (0 , getPreviousMakespan (0 ) + allMachines [0 ].getProcessTime (id ));
90+ var previousMachineCompletionTime = newCompletionTime . setCompletionTime (0 , getPreviousCompletionTime (0 ) + allMachines [0 ].getProcessTime (id ));
9191 for (var i = 1 ; i < allMachines .length ; i ++) {
92- // The job execution for the following machines relies on the makespan of either the previous job
92+ // The job execution for the following machines relies on the completion time of either the previous job
9393 // or the previous machine,
9494 // depending on which is greater.
9595 // That way, the job can only begin on the machine once it has completed on the previous machine
9696 // or after the prior job has finished.
97- newPreviousMakespan = newMakespan . setMakespan (i ,
98- Math .max (getPreviousMakespan (i ), newPreviousMakespan ) + allMachines [i ].getProcessTime (id ));
97+ previousMachineCompletionTime = newCompletionTime . setCompletionTime (i ,
98+ Math .max (getPreviousCompletionTime (i ), previousMachineCompletionTime ) + allMachines [i ].getProcessTime (id ));
9999 }
100- return newMakespan ;
100+ return newCompletionTime ;
101101 }
102102
103103 @ JsonIgnore
104- private int getPreviousMakespan (int machineId ) {
104+ private int getPreviousCompletionTime (int machineId ) {
105105 if (previousJob != null ) {
106- return previousJob .getMakespan (machineId );
106+ return previousJob .getCompletionTime (machineId );
107107 }
108108 return 0 ;
109109 }
110110
111111 @ JsonIgnore
112- public int getMakespan (int machineId ) {
113- if (makespan == null ) {
112+ public int getCompletionTime (int machineId ) {
113+ if (completionTime == null ) {
114114 return 0 ;
115115 }
116- return makespan . getMakespan (machineId );
116+ return completionTime . getCompletionTime (machineId );
117117 }
118118
119119 @ JsonIgnore
120- public int getLastMachineMakespan () {
121- if (makespan == null ) {
120+ public int getCompletionTimeLastMachine () {
121+ if (completionTime == null ) {
122122 return 0 ;
123123 }
124- // The makespan is given by the makespan of the last machine
125- return makespan .getLastMachineMakespan ();
124+ return completionTime .getCompletionTimeLastMachine ();
126125 }
127126
128127 @ Override
0 commit comments