Skip to content

Commit 87c6a9d

Browse files
committed
refactor: validate constraint name
1 parent 9b2be5d commit 87c6a9d

5 files changed

Lines changed: 22 additions & 22 deletions

File tree

java/task-assigning/src/main/java/org/acme/taskassigning/domain/Employee.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public Affinity getAffinity(Customer customer) {
102102
}
103103

104104
@JsonIgnore
105-
public Integer getEndTime() {
106-
return tasks.isEmpty() ? 0 : tasks.get(tasks.size() - 1).getEndTime();
105+
public long getEndTime() {
106+
return tasks.isEmpty() ? 0L : tasks.get(tasks.size() - 1).getEndTime();
107107
}
108108

109109
@Override

java/task-assigning/src/main/java/org/acme/taskassigning/domain/Task.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class Task {
2020
private TaskType taskType;
2121
private int indexInTaskType;
2222
private Customer customer;
23-
private int minStartTime;
23+
private long minStartTime;
2424
private Priority priority;
2525

2626
// Shadow variables
@@ -32,7 +32,7 @@ public class Task {
3232
private Task previousTask;
3333
// Not ignored, used in the UI.
3434
@ShadowVariable(supplierName = "startTimeSupplier")
35-
private Integer startTime; // In minutes
35+
private Long startTime; // In minutes
3636

3737
public Task() {
3838
}
@@ -88,11 +88,11 @@ public void setCustomer(Customer customer) {
8888
this.customer = customer;
8989
}
9090

91-
public int getMinStartTime() {
91+
public long getMinStartTime() {
9292
return minStartTime;
9393
}
9494

95-
public void setMinStartTime(int minStartTime) {
95+
public void setMinStartTime(long minStartTime) {
9696
this.minStartTime = minStartTime;
9797
}
9898

@@ -120,11 +120,11 @@ public void setPreviousTask(Task previousTask) {
120120
this.previousTask = previousTask;
121121
}
122122

123-
public Integer getStartTime() {
123+
public Long getStartTime() {
124124
return startTime;
125125
}
126126

127-
public void setStartTime(Integer startTime) {
127+
public void setStartTime(Long startTime) {
128128
this.startTime = startTime;
129129
}
130130

@@ -134,11 +134,11 @@ public void setStartTime(Integer startTime) {
134134

135135
@SuppressWarnings("unused")
136136
@ShadowSources({"employee", "previousTask.startTime"})
137-
public Integer startTimeSupplier() {
137+
public Long startTimeSupplier() {
138138
if (employee == null) {
139139
return null;
140140
} else if (previousTask == null) {
141-
return minStartTime;
141+
return (long) minStartTime;
142142
} else {
143143
var previousEndTime = previousTask.getEndTime();
144144
return Math.max(previousEndTime, minStartTime);
@@ -160,7 +160,7 @@ public int getMissingSkillCount() {
160160
}
161161

162162
@JsonIgnore
163-
public int getDuration() {
163+
public long getDuration() {
164164
Affinity affinity = getAffinity();
165165
return taskType.getBaseDuration() * affinity.getDurationMultiplier();
166166
}
@@ -171,7 +171,7 @@ public Affinity getAffinity() {
171171
}
172172

173173
@JsonIgnore
174-
public Integer getEndTime() {
174+
public Long getEndTime() {
175175
if (startTime == null) {
176176
return null;
177177
}

java/task-assigning/src/main/java/org/acme/taskassigning/domain/TaskType.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class TaskType {
1111

1212
private String code;
1313
private String title;
14-
private int baseDuration; // In minutes
14+
private long baseDuration; // In minutes
1515
private List<String> requiredSkills;
1616

1717
public TaskType() {
@@ -47,11 +47,11 @@ public void setTitle(String title) {
4747
this.title = title;
4848
}
4949

50-
public int getBaseDuration() {
50+
public long getBaseDuration() {
5151
return baseDuration;
5252
}
5353

54-
public void setBaseDuration(int baseDuration) {
54+
public void setBaseDuration(long baseDuration) {
5555
this.baseDuration = baseDuration;
5656
}
5757

java/task-assigning/src/main/java/org/acme/taskassigning/solver/TaskAssigningConstraintProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected Constraint minimizeMakespan(ConstraintFactory constraintFactory) {
5252
return constraintFactory.forEach(Employee.class)
5353
.penalize(BendableScore.ofSoft(BENDABLE_SCORE_HARD_LEVELS_SIZE, BENDABLE_SCORE_SOFT_LEVELS_SIZE, 1, 1),
5454
employee -> employee.getEndTime() * employee.getEndTime())
55-
.asConstraint("Minimize makespan, latest ending employee first");
55+
.asConstraint("Minimize makespan - latest ending employee first");
5656
}
5757

5858
protected Constraint criticalPriorityTaskEndTime(ConstraintFactory constraintFactory) {

java/task-assigning/src/test/java/org/acme/taskassigning/solver/TaskAssigningConstraintProviderTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void criticalPriorityTaskEndTime() {
7070
// Task 1
7171
TaskType type1 = new TaskType("1", "1", 10);
7272
Task task1 = new Task("1", type1, 1, customer, employee, 1, Priority.CRITICAL);
73-
task1.setStartTime(1);
73+
task1.setStartTime(1L);
7474
// Task 2
7575
TaskType type2 = new TaskType("1", "1", 20);
7676
Task task2 = new Task("2", type2, 1, customer, employee, 2, Priority.MINOR);
@@ -90,15 +90,15 @@ void minimizeMakespan() {
9090
// Task 1
9191
TaskType type1 = new TaskType("1", "1", 10);
9292
Task task1 = new Task("1", type1, 1, customer, employee1, 1, Priority.CRITICAL);
93-
task1.setStartTime(1);
93+
task1.setStartTime(1L);
9494
// Task 2
9595
TaskType type2 = new TaskType("2", "1", 20);
9696
Task task2 = new Task("2", type2, 1, customer, employee1, 2, Priority.MINOR);
97-
task2.setStartTime(2);
97+
task2.setStartTime(2L);
9898
// Task 3
9999
TaskType invalidType2 = new TaskType("3", "3", 1);
100100
Task task3 = new Task("3", invalidType2, 1, customer, employee2, 1, Priority.CRITICAL);
101-
task3.setStartTime(3);
101+
task3.setStartTime(3L);
102102

103103
employee1.setTasks(List.of(task1, task2));
104104
employee2.setTasks(List.of(task3));
@@ -116,7 +116,7 @@ void majorPriorityTaskEndTime() {
116116
// Task 1
117117
TaskType type1 = new TaskType("1", "1", 10);
118118
Task task1 = new Task("1", type1, 1, customer, employee, 1, Priority.MAJOR);
119-
task1.setStartTime(1);
119+
task1.setStartTime(1L);
120120
// Task 2
121121
TaskType type2 = new TaskType("1", "1", 20);
122122
Task task2 = new Task("2", type2, 1, customer, employee, 2, Priority.MINOR);
@@ -134,7 +134,7 @@ void minorPriorityTaskEndTime() {
134134
// Task 1
135135
TaskType type1 = new TaskType("1", "1", 10);
136136
Task task1 = new Task("1", type1, 1, customer, employee, 1, Priority.MINOR);
137-
task1.setStartTime(1);
137+
task1.setStartTime(1L);
138138
// Task 2
139139
TaskType type2 = new TaskType("1", "1", 20);
140140
Task task2 = new Task("2", type2, 1, customer, employee, 2, Priority.MAJOR);

0 commit comments

Comments
 (0)