diff options
Diffstat (limited to 'subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/objectives/Objectives.java')
-rw-r--r-- | subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/objectives/Objectives.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/objectives/Objectives.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/objectives/Objectives.java new file mode 100644 index 00000000..e552d14c --- /dev/null +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/objectives/Objectives.java | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.dse.transition.objectives; | ||
7 | |||
8 | import tools.refinery.store.query.dnf.FunctionalQuery; | ||
9 | import tools.refinery.store.query.dnf.RelationalQuery; | ||
10 | |||
11 | import java.util.Collection; | ||
12 | import java.util.List; | ||
13 | |||
14 | public final class Objectives { | ||
15 | private Objectives() { | ||
16 | throw new IllegalStateException("This is a static utility class and should not be instantiated directly"); | ||
17 | } | ||
18 | |||
19 | public static CountObjective count(RelationalQuery query, double weight) { | ||
20 | return new CountObjective(query, weight); | ||
21 | } | ||
22 | |||
23 | public static CountObjective count(RelationalQuery query) { | ||
24 | return new CountObjective(query); | ||
25 | } | ||
26 | |||
27 | public static QueryObjective value(FunctionalQuery<? extends Number> query) { | ||
28 | return new QueryObjective(query); | ||
29 | } | ||
30 | |||
31 | public static Objective sum(Objective... objectives) { | ||
32 | return sum(List.of(objectives)); | ||
33 | } | ||
34 | |||
35 | public static Objective sum(Collection<? extends Objective> objectives) { | ||
36 | if (objectives.size() == 1) { | ||
37 | return objectives.iterator().next(); | ||
38 | } | ||
39 | return new CompositeObjective(objectives); | ||
40 | } | ||
41 | } | ||