diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2020-06-30 18:03:48 +0200 |
---|---|---|
committer | Kristóf Marussy <marussy@mit.bme.hu> | 2020-06-30 18:03:48 +0200 |
commit | e11bce7ad3e803e80883499fec0ad6e4540ffe43 (patch) | |
tree | ca3ad9d5b9137e9455485e43350a4a353f487f22 /Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Objectives.java | |
parent | Disable unrepairable match scoping for now (diff) | |
download | VIATRA-Generator-e11bce7ad3e803e80883499fec0ad6e4540ffe43.tar.gz VIATRA-Generator-e11bce7ad3e803e80883499fec0ad6e4540ffe43.tar.zst VIATRA-Generator-e11bce7ad3e803e80883499fec0ad6e4540ffe43.zip |
Add modified VIATRA-DSE version
Diffstat (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Objectives.java')
-rw-r--r-- | Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Objectives.java | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Objectives.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Objectives.java new file mode 100644 index 00000000..3b375fac --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Objectives.java | |||
@@ -0,0 +1,153 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2016, Andras Szabolcs Nagy, Zoltan Ujhelyi 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.api; | ||
10 | |||
11 | import org.eclipse.viatra.dse.objectives.impl.CompositeObjective; | ||
12 | import org.eclipse.viatra.dse.objectives.impl.ConstraintsObjective; | ||
13 | import org.eclipse.viatra.dse.objectives.impl.AlwaysSatisfiedDummyHardObjective; | ||
14 | import org.eclipse.viatra.dse.objectives.impl.DepthHardObjective; | ||
15 | import org.eclipse.viatra.dse.objectives.impl.NeverSatisfiedDummyHardObjective; | ||
16 | import org.eclipse.viatra.dse.objectives.impl.NoRuleActivationsHardObjective; | ||
17 | import org.eclipse.viatra.dse.objectives.impl.TrajectoryCostSoftObjective; | ||
18 | |||
19 | /** | ||
20 | * | ||
21 | * Helper class for creating built-in objectives. | ||
22 | * | ||
23 | * @author Andras Szabolcs Nagy | ||
24 | * | ||
25 | */ | ||
26 | public class Objectives { | ||
27 | |||
28 | private Objectives() { | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * This objective uses VIATRA Queries to calculate fitness and/or goal constraints. Use methods on the returned | ||
33 | * objective to configure it. | ||
34 | * | ||
35 | * @param name | ||
36 | * @return The objective. | ||
37 | * @see ConstraintsObjective | ||
38 | */ | ||
39 | public static ConstraintsObjective createConstraintsObjective(String name) { | ||
40 | return new ConstraintsObjective(name); | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * This objective calculates fitness on the trajectory by adding either fix costs to the rules, or by calculating | ||
45 | * custom fitness on activation of rules. | ||
46 | * | ||
47 | * @param name | ||
48 | * @return The objective. | ||
49 | * @see TrajectoryCostSoftObjective | ||
50 | */ | ||
51 | public static TrajectoryCostSoftObjective createTrajcetoryCostObjective(String name) { | ||
52 | return new TrajectoryCostSoftObjective(name); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * This objective adds a goal constraint that a solution state should not have any activations. | ||
57 | * | ||
58 | * @return The objective. | ||
59 | * @see NoRuleActivationsHardObjective | ||
60 | */ | ||
61 | public static NoRuleActivationsHardObjective createNoRuleActivationsHardConstraint() { | ||
62 | return new NoRuleActivationsHardObjective(); | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * This objective adds a goal constraint that a solution state should not have any activations. | ||
67 | * | ||
68 | * @param name | ||
69 | * @return The objective. | ||
70 | * @see NoRuleActivationsHardObjective | ||
71 | */ | ||
72 | public static NoRuleActivationsHardObjective createNoRuleActivationsHardConstraint(String name) { | ||
73 | return new NoRuleActivationsHardObjective(name); | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * This objective can combine the calculated fitness value of other objectives. Weights are supported. | ||
78 | * | ||
79 | * @param name | ||
80 | * @return The objective. | ||
81 | * @see NoRuleActivationsHardObjective | ||
82 | */ | ||
83 | public static CompositeObjective createCompositeObjective(String name) { | ||
84 | return new CompositeObjective(name); | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * This hard objective is fulfilled in any circumstances. Use it if all states should be regarded as a valid | ||
89 | * solution. | ||
90 | * | ||
91 | * @return The objective. | ||
92 | * @see AlwaysSatisfiedDummyHardObjective | ||
93 | */ | ||
94 | public static AlwaysSatisfiedDummyHardObjective createAlwaysSatisfiedDummyHardObjective() { | ||
95 | return new AlwaysSatisfiedDummyHardObjective(); | ||
96 | } | ||
97 | |||
98 | /** | ||
99 | * This hard objective is fulfilled in any circumstances. Use it if all states should be regarded as a valid | ||
100 | * solution. | ||
101 | * | ||
102 | * @param name | ||
103 | * @return The objective. | ||
104 | * @see AlwaysSatisfiedDummyHardObjective | ||
105 | */ | ||
106 | public static AlwaysSatisfiedDummyHardObjective createDummyHardObjective(String name) { | ||
107 | return new AlwaysSatisfiedDummyHardObjective(name); | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * This hard objective is never fulfilled. Use it if all states should be regarded as an invalid solution. | ||
112 | * | ||
113 | * @return The objective. | ||
114 | * @see AlwaysSatisfiedDummyHardObjective | ||
115 | */ | ||
116 | public static NeverSatisfiedDummyHardObjective createNeverSatisfiedDummyHardObjective() { | ||
117 | return new NeverSatisfiedDummyHardObjective(); | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * This hard objective is never fulfilled. Use it if all states should be regarded as an invalid solution. | ||
122 | * | ||
123 | * @return The objective. | ||
124 | * @see AlwaysSatisfiedDummyHardObjective | ||
125 | */ | ||
126 | public static NeverSatisfiedDummyHardObjective createNeverSatisfiedDummyHardObjective(String name) { | ||
127 | return new NeverSatisfiedDummyHardObjective(name); | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * This hard objective is fulfilled if the length of the trajectory is in the specified interval (inclusive). Use | ||
132 | * {@link DepthHardObjective#withMinDepth(int)} and {@link DepthHardObjective#withMaxDepth(int)} to configure. | ||
133 | * | ||
134 | * @return The objective. | ||
135 | * @see DepthHardObjective | ||
136 | */ | ||
137 | public static DepthHardObjective createDepthHardObjective() { | ||
138 | return new DepthHardObjective(); | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * This hard objective is fulfilled if the length of the trajectory is in the specified interval (inclusive). Use | ||
143 | * {@link DepthHardObjective#withMinDepth(int)} and {@link DepthHardObjective#withMaxDepth(int)} to configure. | ||
144 | * | ||
145 | * @param name | ||
146 | * @return The objective. | ||
147 | * @see DepthHardObjective | ||
148 | */ | ||
149 | public static DepthHardObjective createDepthHardObjective(String name) { | ||
150 | return new DepthHardObjective(name); | ||
151 | } | ||
152 | |||
153 | } | ||