diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/NoRuleActivationsHardObjective.java')
-rw-r--r-- | Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/NoRuleActivationsHardObjective.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/NoRuleActivationsHardObjective.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/NoRuleActivationsHardObjective.java new file mode 100644 index 00000000..756d94ec --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/NoRuleActivationsHardObjective.java | |||
@@ -0,0 +1,59 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2015, Andras Szabolcs Nagy and Daniel Varro | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package org.eclipse.viatra.dse.objectives.impl; | ||
10 | |||
11 | import org.eclipse.viatra.dse.base.ThreadContext; | ||
12 | import org.eclipse.viatra.dse.objectives.IObjective; | ||
13 | |||
14 | /** | ||
15 | * This hard objective is satisfied if there are no rule activations from the current state (returning 1 in this case). | ||
16 | * | ||
17 | * @author Andras Szabolcs Nagy | ||
18 | * | ||
19 | */ | ||
20 | public class NoRuleActivationsHardObjective extends BaseObjective { | ||
21 | |||
22 | protected static final String DEFAULT_NAME = "NoMoreActivationHardObjective"; | ||
23 | private ThreadContext context; | ||
24 | |||
25 | public NoRuleActivationsHardObjective(String name) { | ||
26 | super(name); | ||
27 | } | ||
28 | |||
29 | public NoRuleActivationsHardObjective() { | ||
30 | this(DEFAULT_NAME); | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | public Double getFitness(ThreadContext context) { | ||
35 | return 0d; | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public void init(ThreadContext context) { | ||
40 | super.init(context); | ||
41 | this.context = context; | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | public IObjective createNew() { | ||
46 | return new NoRuleActivationsHardObjective(name); | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public boolean isHardObjective() { | ||
51 | return true; | ||
52 | } | ||
53 | |||
54 | @Override | ||
55 | public boolean satisifiesHardObjective(Double fitness) { | ||
56 | return context.getConflictSet().getNextActivations().isEmpty(); | ||
57 | } | ||
58 | |||
59 | } | ||