blob: 60913ff31c7037d412ae0f058d8355d82d6b7db9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/*
* SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.store.dse.transition;
import java.util.Arrays;
public interface ObjectiveValues {
public record ObjectiveValue1(double value0) implements ObjectiveValue {
@Override
public double get(int index) {
if(index == 0) return value0;
else throw new IllegalArgumentException("No value at " + index);
}
@Override
public int getSize() {
return 1;
}
}
public record ObjectiveValue2(double value0, double value1) implements ObjectiveValue {
@Override
public double get(int index) {
if(index == 0) return value0;
else if(index == 1) return value1;
else throw new IllegalArgumentException("No value at " + index);
}
@Override
public int getSize() {
return 2;
}
}
public record ObjectiveValueN(double[] values) implements ObjectiveValue {
@Override
public double get(int index) {
return values[index];
}
@Override
public int getSize() {
return values().length;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ObjectiveValueN that = (ObjectiveValueN) o;
return Arrays.equals(values, that.values);
}
@Override
public int hashCode() {
return Arrays.hashCode(values);
}
@Override
public String toString() {
return "ObjectiveValueN{" +
"values=" + Arrays.toString(values) +
'}';
}
}
}
|