diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java')
-rw-r--r-- | Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java new file mode 100644 index 00000000..ed7a90da --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java | |||
@@ -0,0 +1,123 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2014, Miklos Foldenyi, Andras Szabolcs Nagy, Abel Hegedus, Akos Horvath, 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.api.strategy.impl.BestFirstStrategy; | ||
12 | import org.eclipse.viatra.dse.api.strategy.impl.BreadthFirstStrategy; | ||
13 | import org.eclipse.viatra.dse.api.strategy.impl.DepthFirstStrategy; | ||
14 | import org.eclipse.viatra.dse.api.strategy.impl.FixedPriorityStrategy; | ||
15 | import org.eclipse.viatra.dse.api.strategy.impl.HillClimbingStrategy; | ||
16 | import org.eclipse.viatra.dse.api.strategy.interfaces.IStrategy; | ||
17 | |||
18 | /** | ||
19 | * Helper class for instantiating strategies. To implement a new strategy use the {@link IStrategy} interface. | ||
20 | * | ||
21 | * @author Andras Szabolcs Nagy | ||
22 | * | ||
23 | */ | ||
24 | public final class Strategies { | ||
25 | |||
26 | private Strategies() { | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * Creates a depth-first search exploration strategy without a depth limit. | ||
31 | * | ||
32 | * @return The strategy. | ||
33 | * @see DepthFirstStrategy | ||
34 | */ | ||
35 | public static DepthFirstStrategy createDfsStrategy() { | ||
36 | return new DepthFirstStrategy(); | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * Creates a depth-first search exploration strategy with a depth limit. A negative depth limit means no | ||
41 | * depth limit, zero means that it will check the initial state. | ||
42 | * | ||
43 | * @param depthLimit | ||
44 | * @return The strategy. | ||
45 | * @see DepthFirstStrategy | ||
46 | */ | ||
47 | public static DepthFirstStrategy createDfsStrategy(int depthLimit) { | ||
48 | return new DepthFirstStrategy(depthLimit); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * Creates a fixed priority exploration strategy without a depth limit. It is a depth-first search exploration | ||
53 | * strategy but from a current state it only explores the activations with the highest priority. Priorities can be | ||
54 | * defined on the strategy itself. | ||
55 | * | ||
56 | * @return The strategy. | ||
57 | * @see FixedPriorityStrategy | ||
58 | */ | ||
59 | public static FixedPriorityStrategy createFixedPriorityStrategy() { | ||
60 | return createFixedPriorityStrategy(-1); | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * Creates a fixed priority exploration strategy with a depth limit, where a zero or negative depth limit means no | ||
65 | * depth limit. It is a depth-first search exploration strategy but from a current state it only explores the | ||
66 | * activations with the highest priority. Priorities can be defined on the strategy itself. | ||
67 | * | ||
68 | * @param depthLimit | ||
69 | * @return The strategy. | ||
70 | * @see FixedPriorityStrategy | ||
71 | */ | ||
72 | public static FixedPriorityStrategy createFixedPriorityStrategy(int depthLimit) { | ||
73 | return new FixedPriorityStrategy().withDepthLimit(depthLimit); | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * Creates a breadth-first search exploration strategy without a depth limit. | ||
78 | * | ||
79 | * @return The strategy. | ||
80 | * @see BreadthFirstStrategy | ||
81 | */ | ||
82 | public static BreadthFirstStrategy createBfsStrategy() { | ||
83 | return new BreadthFirstStrategy(); | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * Creates a breadth-first search exploration strategy with a depth limit. A zero or negative depth limit means no | ||
88 | * depth limit. | ||
89 | * | ||
90 | * @param depthLimit | ||
91 | * @return The strategy. | ||
92 | * @see BreadthFirstStrategy | ||
93 | */ | ||
94 | public static BreadthFirstStrategy createBfsStrategy(int depthLimit) { | ||
95 | return new BreadthFirstStrategy(depthLimit); | ||
96 | } | ||
97 | |||
98 | /** | ||
99 | * Creates a hill climbing exploration strategy. By default, it explores all neighborhood states and chooses the | ||
100 | * best one to continue with until all neighborhood states are dominated by the current state. Other options are | ||
101 | * available on the strategy. | ||
102 | * | ||
103 | * @return The strategy. | ||
104 | * @see HillClimbingStrategy | ||
105 | */ | ||
106 | public static HillClimbingStrategy creatHillClimbingStrategy() { | ||
107 | return new HillClimbingStrategy(); | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * See {@link BestFirstStrategy}. | ||
112 | */ | ||
113 | public static BestFirstStrategy createBestFirstStrategy() { | ||
114 | return new BestFirstStrategy(); | ||
115 | } | ||
116 | |||
117 | /** | ||
118 | * See {@link BestFirstStrategy}. | ||
119 | */ | ||
120 | public static BestFirstStrategy createBestFirstStrategy(int depthLimit) { | ||
121 | return new BestFirstStrategy(depthLimit); | ||
122 | } | ||
123 | } | ||