aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java
blob: ed7a90dad167e2bc06eb599ba055bc260d8c3efe (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*******************************************************************************
 * Copyright (c) 2010-2014, Miklos Foldenyi, Andras Szabolcs Nagy, Abel Hegedus, Akos Horvath, Zoltan Ujhelyi and Daniel Varro
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-v20.html.
 * 
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/
package org.eclipse.viatra.dse.api;

import org.eclipse.viatra.dse.api.strategy.impl.BestFirstStrategy;
import org.eclipse.viatra.dse.api.strategy.impl.BreadthFirstStrategy;
import org.eclipse.viatra.dse.api.strategy.impl.DepthFirstStrategy;
import org.eclipse.viatra.dse.api.strategy.impl.FixedPriorityStrategy;
import org.eclipse.viatra.dse.api.strategy.impl.HillClimbingStrategy;
import org.eclipse.viatra.dse.api.strategy.interfaces.IStrategy;

/**
 * Helper class for instantiating strategies. To implement a new strategy use the {@link IStrategy} interface.
 * 
 * @author Andras Szabolcs Nagy
 * 
 */
public final class Strategies {

    private Strategies() {
    }

    /**
     * Creates a depth-first search exploration strategy without a depth limit.
     * 
     * @return The strategy.
     * @see DepthFirstStrategy
     */
    public static DepthFirstStrategy createDfsStrategy() {
        return new DepthFirstStrategy();
    }

    /**
     * Creates a depth-first search exploration strategy with a depth limit. A negative depth limit means no
     * depth limit, zero means that it will check the initial state.
     * 
     * @param depthLimit
     * @return The strategy.
     * @see DepthFirstStrategy
     */
    public static DepthFirstStrategy createDfsStrategy(int depthLimit) {
        return new DepthFirstStrategy(depthLimit);
    }

    /**
     * Creates a fixed priority exploration strategy without a depth limit. It is a depth-first search exploration
     * strategy but from a current state it only explores the activations with the highest priority. Priorities can be
     * defined on the strategy itself.
     * 
     * @return The strategy.
     * @see FixedPriorityStrategy
     */
    public static FixedPriorityStrategy createFixedPriorityStrategy() {
        return createFixedPriorityStrategy(-1);
    }

    /**
     * Creates a fixed priority exploration strategy with a depth limit, where a zero or negative depth limit means no
     * depth limit. It is a depth-first search exploration strategy but from a current state it only explores the
     * activations with the highest priority. Priorities can be defined on the strategy itself.
     * 
     * @param depthLimit
     * @return The strategy.
     * @see FixedPriorityStrategy
     */
    public static FixedPriorityStrategy createFixedPriorityStrategy(int depthLimit) {
        return new FixedPriorityStrategy().withDepthLimit(depthLimit);
    }

    /**
     * Creates a breadth-first search exploration strategy without a depth limit.
     * 
     * @return The strategy.
     * @see BreadthFirstStrategy
     */
    public static BreadthFirstStrategy createBfsStrategy() {
        return new BreadthFirstStrategy();
    }

    /**
     * Creates a breadth-first search exploration strategy with a depth limit. A zero or negative depth limit means no
     * depth limit.
     * 
     * @param depthLimit
     * @return The strategy.
     * @see BreadthFirstStrategy
     */
    public static BreadthFirstStrategy createBfsStrategy(int depthLimit) {
        return new BreadthFirstStrategy(depthLimit);
    }

    /**
     * Creates a hill climbing exploration strategy. By default, it explores all neighborhood states and chooses the
     * best one to continue with until all neighborhood states are dominated by the current state. Other options are
     * available on the strategy.
     * 
     * @return The strategy.
     * @see HillClimbingStrategy
     */
    public static HillClimbingStrategy creatHillClimbingStrategy() {
        return new HillClimbingStrategy();
    }

    /**
     * See {@link BestFirstStrategy}.
     */
    public static BestFirstStrategy createBestFirstStrategy() {
        return new BestFirstStrategy();
    }

    /**
     * See {@link BestFirstStrategy}.
     */
    public static BestFirstStrategy createBestFirstStrategy(int depthLimit) {
        return new BestFirstStrategy(depthLimit);
    }
}