diff options
author | 2023-08-07 15:10:07 +0200 | |
---|---|---|
committer | 2023-08-07 15:12:37 +0200 | |
commit | d5d8ad817c2f7d348a1fb40ca3f627ccc4ea37d5 (patch) | |
tree | 649097dd4f9239a2072dfea38ecbeae56025aee5 /subprojects/store-dse/src/main/java/tools | |
parent | Clean up design space exploration (diff) | |
download | refinery-d5d8ad817c2f7d348a1fb40ca3f627ccc4ea37d5.tar.gz refinery-d5d8ad817c2f7d348a1fb40ca3f627ccc4ea37d5.tar.zst refinery-d5d8ad817c2f7d348a1fb40ca3f627ccc4ea37d5.zip |
Update visualizer builder
Diffstat (limited to 'subprojects/store-dse/src/main/java/tools')
2 files changed, 60 insertions, 6 deletions
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/DesignSpaceExplorationAdapterImpl.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/DesignSpaceExplorationAdapterImpl.java index 1329480c..008b2dab 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/DesignSpaceExplorationAdapterImpl.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/DesignSpaceExplorationAdapterImpl.java | |||
@@ -96,6 +96,9 @@ public class DesignSpaceExplorationAdapterImpl implements DesignSpaceExploration | |||
96 | trajectory.add(state); | 96 | trajectory.add(state); |
97 | strategy.initStrategy(this); | 97 | strategy.initStrategy(this); |
98 | strategy.explore(); | 98 | strategy.explore(); |
99 | if (isVisualizationEnabled) { | ||
100 | modelVisualizerAdapter.visualize(); | ||
101 | } | ||
99 | return solutions; | 102 | return solutions; |
100 | } | 103 | } |
101 | 104 | ||
@@ -247,7 +250,7 @@ public class DesignSpaceExplorationAdapterImpl implements DesignSpaceExploration | |||
247 | isNewState = !statesAndTraversedActivations.containsKey(newState); | 250 | isNewState = !statesAndTraversedActivations.containsKey(newState); |
248 | if (isVisualizationEnabled) { | 251 | if (isVisualizationEnabled) { |
249 | if (isNewState) { | 252 | if (isNewState) { |
250 | modelVisualizerAdapter.addState(newState); | 253 | modelVisualizerAdapter.addState(newState, getFitness().values()); |
251 | } | 254 | } |
252 | // TODO: Change to this: | 255 | // TODO: Change to this: |
253 | modelVisualizerAdapter.addTransition(previousState, newState, activation.transformationRule().getName(), | 256 | modelVisualizerAdapter.addTransition(previousState, newState, activation.transformationRule().getName(), |
@@ -272,11 +275,6 @@ public class DesignSpaceExplorationAdapterImpl implements DesignSpaceExploration | |||
272 | fireActivation(activationId); | 275 | fireActivation(activationId); |
273 | } | 276 | } |
274 | 277 | ||
275 | @Override | ||
276 | public boolean isCurrentInTrajectory() { | ||
277 | return trajectory.contains(model.getState()); | ||
278 | } | ||
279 | |||
280 | public List<Activation> getAllActivations() { | 278 | public List<Activation> getAllActivations() { |
281 | List<Activation> result = new LinkedList<>(); | 279 | List<Activation> result = new LinkedList<>(); |
282 | for (var rule : transformationRules) { | 280 | for (var rule : transformationRules) { |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/objectives/AlwaysSatisfiedRandomHardObjective.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/objectives/AlwaysSatisfiedRandomHardObjective.java new file mode 100644 index 00000000..327d5e2f --- /dev/null +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/objectives/AlwaysSatisfiedRandomHardObjective.java | |||
@@ -0,0 +1,56 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2016, Andras Szabolcs Nagy, Zoltan Ujhelyi and Daniel Varro | ||
3 | * Copyright (c) 2023 The Refinery Authors <https://refinery.tools/> | ||
4 | * This program and the accompanying materials are made available under the | ||
5 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
6 | * http://www.eclipse.org/legal/epl-v20.html. | ||
7 | * | ||
8 | * SPDX-License-Identifier: EPL-2.0 | ||
9 | *******************************************************************************/ | ||
10 | package tools.refinery.store.dse.objectives; | ||
11 | |||
12 | import tools.refinery.store.dse.DesignSpaceExplorationAdapter; | ||
13 | |||
14 | import java.util.Random; | ||
15 | |||
16 | /** | ||
17 | * This hard objective is fulfilled in any circumstances. Use it if all states should be regarded as a valid solution. | ||
18 | * | ||
19 | * @author Andras Szabolcs Nagy | ||
20 | * | ||
21 | */ | ||
22 | public class AlwaysSatisfiedRandomHardObjective extends BaseObjective { | ||
23 | |||
24 | private static final String DEFAULT_NAME = "AlwaysSatisfiedDummyHardObjective"; | ||
25 | private static final Random random = new Random(0); | ||
26 | |||
27 | public AlwaysSatisfiedRandomHardObjective() { | ||
28 | super(DEFAULT_NAME); | ||
29 | } | ||
30 | |||
31 | public AlwaysSatisfiedRandomHardObjective(String name) { | ||
32 | super(name); | ||
33 | } | ||
34 | |||
35 | @Override | ||
36 | public Double getFitness(DesignSpaceExplorationAdapter context) { | ||
37 | // return 0d; | ||
38 | return random.nextDouble(); | ||
39 | } | ||
40 | |||
41 | @Override | ||
42 | public boolean isHardObjective() { | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public boolean satisfiesHardObjective(Double fitness) { | ||
48 | return true; | ||
49 | } | ||
50 | |||
51 | @Override | ||
52 | public Objective createNew() { | ||
53 | return this; | ||
54 | } | ||
55 | |||
56 | } | ||