Skip to content

Commit b23c1fc

Browse files
committed
fixed missing bounds in JSSPMakespanObjectiveFunction2
1 parent a627e79 commit b23c1fc

File tree

4 files changed

+65
-13
lines changed

4 files changed

+65
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ First, you need to add the following repository, which is a repository that can
4444
```
4545

4646
Than you can add the dependency on our `aitoa-code` repository into your `dependencies` section.
47-
Here, `0.8.73` is the current version of `aitoa-code`.
47+
Here, `0.8.74` is the current version of `aitoa-code`.
4848
Notice that you may have more dependencies in your `dependencies` section, say on `junit`, but here I just put the one for `aitoa-code` as example.
4949

5050
```xml
5151
<dependencies>
5252
<dependency>
5353
<groupId>com.github.thomasWeise</groupId>
5454
<artifactId>aitoa-code</artifactId>
55-
<version>0.8.73</version>
55+
<version>0.8.74</version>
5656
</dependency>
5757
</dependencies>
5858
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>aitoa</groupId>
77
<artifactId>aitoa-code</artifactId>
8-
<version>0.8.73</version>
8+
<version>0.8.74</version>
99
<packaging>jar</packaging>
1010
<name>aitoa-code</name>
1111
<description>Example Source Codes from the Book "Introduction to Optimization Algorithms"</description>

src/main/java/aitoa/examples/jssp/JSSPMakespanObjectiveFunction.java

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,11 @@ public double evaluate(final JSSPCandidateSolution y) {
7575
* Journal of Operational Research, 64.2: 278-285, 1993. doi:
7676
* 10.1016/0377-2217(93)90182-M
7777
*
78+
* @param inst
79+
* the instance
7880
* @return the lower bound
7981
*/
80-
@Override
81-
public double lowerBound() {
82-
final JSSPInstance inst = this.instance;
83-
82+
static int lowerBound(final JSSPInstance inst) {
8483
final int[] a = new int[inst.m]; // lb inactive time at start
8584
final int[] b = new int[inst.m]; // lb inactive time at end
8685
final int[] T = new int[inst.m]; // time of machine
@@ -134,15 +133,29 @@ public double lowerBound() {
134133
}
135134

136135
/**
137-
* Compute the upper bound of the instance in a very sloppy
138-
* way. This is just a placeholder for now. The idea is that I
139-
* can use this in unit tests to check whether results are
140-
* sane.
136+
* Compute the lower bound of the objective value. See E. D.
137+
* Taillard. Benchmarks for basic scheduling problems. European
138+
* Journal of Operational Research, 64.2: 278-285, 1993. doi:
139+
* 10.1016/0377-2217(93)90182-M
140+
*
141+
* @return the lower bound
141142
*/
142143
@Override
143-
public double upperBound() {
144+
public double lowerBound() {
145+
return JSSPMakespanObjectiveFunction.lowerBound(//
146+
this.instance);
147+
}
148+
149+
/**
150+
* Compute the upper bound for the instance
151+
*
152+
* @param inst
153+
* the instance
154+
* @return the upper bound
155+
*/
156+
static int upperBound(final JSSPInstance inst) {
144157
int sum = 0;
145-
for (final int[] job : this.instance.jobs) {
158+
for (final int[] job : inst.jobs) {
146159
for (int i = job.length - 1; i > 0; i -= 2) {
147160
sum = Math.addExact(sum, job[i]);
148161
}
@@ -155,6 +168,18 @@ public double upperBound() {
155168
return sum;
156169
}
157170

171+
/**
172+
* Compute the upper bound of the instance in a very sloppy
173+
* way. This is just a placeholder for now. The idea is that I
174+
* can use this in unit tests to check whether results are
175+
* sane.
176+
*/
177+
@Override
178+
public double upperBound() {
179+
return JSSPMakespanObjectiveFunction.upperBound(//
180+
this.instance);
181+
}
182+
158183
// start relevant
159184
}
160185
// end relevant

src/main/java/aitoa/examples/jssp/JSSPMakespanObjectiveFunction2.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,31 @@ public double evaluate(final int[] y) {
102102
}
103103
return end;
104104
}
105+
106+
/**
107+
* Compute the lower bound of the objective value. See E. D.
108+
* Taillard. Benchmarks for basic scheduling problems. European
109+
* Journal of Operational Research, 64.2: 278-285, 1993. doi:
110+
* 10.1016/0377-2217(93)90182-M
111+
*
112+
* @return the lower bound
113+
*/
114+
@Override
115+
public double lowerBound() {
116+
return JSSPMakespanObjectiveFunction.lowerBound(//
117+
this.instance);
118+
}
119+
120+
/**
121+
* Compute the upper bound of the instance in a very sloppy
122+
* way. This is just a placeholder for now. The idea is that I
123+
* can use this in unit tests to check whether results are
124+
* sane.
125+
*/
126+
@Override
127+
public double upperBound() {
128+
return JSSPMakespanObjectiveFunction.upperBound(//
129+
this.instance);
130+
}
131+
105132
}

0 commit comments

Comments
 (0)