aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/objectives/Objectives.java
blob: e552d14c54d4e6e1098bc141af7581e0c142b66f (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
/*
 * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.store.dse.transition.objectives;

import tools.refinery.store.query.dnf.FunctionalQuery;
import tools.refinery.store.query.dnf.RelationalQuery;

import java.util.Collection;
import java.util.List;

public final class Objectives {
	private Objectives() {
		throw new IllegalStateException("This is a static utility class and should not be instantiated directly");
	}

	public static CountObjective count(RelationalQuery query, double weight) {
		return new CountObjective(query, weight);
	}

	public static CountObjective count(RelationalQuery query) {
		return new CountObjective(query);
	}

	public static QueryObjective value(FunctionalQuery<? extends Number> query) {
		return new QueryObjective(query);
	}

	public static Objective sum(Objective... objectives) {
		return sum(List.of(objectives));
	}

	public static Objective sum(Collection<? extends Objective> objectives) {
		if (objectives.size() == 1) {
			return objectives.iterator().next();
		}
		return new CompositeObjective(objectives);
	}
}