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

import tools.refinery.store.adapter.AbstractModelAdapterBuilder;
import tools.refinery.store.model.ModelStore;
import tools.refinery.store.model.ModelStoreBuilder;
import tools.refinery.store.query.dnf.RelationalQuery;
import tools.refinery.store.dse.DesignSpaceExplorationBuilder;
import tools.refinery.store.dse.Strategy;
import tools.refinery.store.dse.objectives.Objective;

import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;

public class DesignSpaceExplorationBuilderImpl
		extends AbstractModelAdapterBuilder<DesignSpaceExplorationStoreAdapterImpl>
		implements DesignSpaceExplorationBuilder {
	private final LinkedHashSet<TransformationRule> transformationSpecifications = new LinkedHashSet<>();
	private final LinkedHashSet<RelationalQuery> globalConstraints = new LinkedHashSet<>();
	private final List<Objective> objectives = new LinkedList<>();
	private Strategy strategy;

	@Override
	protected DesignSpaceExplorationStoreAdapterImpl doBuild(ModelStore store) {
		return new DesignSpaceExplorationStoreAdapterImpl(store, transformationSpecifications, globalConstraints,
				objectives, strategy);
	}

	@Override
	public DesignSpaceExplorationBuilder transformation(TransformationRule transformationRule) {
		checkNotConfigured();
		transformationSpecifications.add(transformationRule);
		return this;
	}

	@Override
	public DesignSpaceExplorationBuilder globalConstraint(RelationalQuery globalConstraint) {
		checkNotConfigured();
		globalConstraints.add(globalConstraint);
		return this;
	}

	@Override
	public DesignSpaceExplorationBuilder objective(Objective objective) {
		checkNotConfigured();
		objectives.add(objective);
		return this;
	}

	@Override
	public DesignSpaceExplorationBuilder strategy(Strategy strategy) {
		checkNotConfigured();
		this.strategy = strategy;
		return this;
	}

	@Override
	protected void doConfigure(ModelStoreBuilder storeBuilder) {
		storeBuilder.symbols(DesignSpaceExplorationAdapterImpl.NODE_COUNT_SYMBOL);
		super.doConfigure(storeBuilder);
	}
}