aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Objectives.java
blob: 3b375fac6e9356e61e396473e1509b3ad3468aff (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*******************************************************************************
 * Copyright (c) 2010-2016, Andras Szabolcs Nagy, 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.objectives.impl.CompositeObjective;
import org.eclipse.viatra.dse.objectives.impl.ConstraintsObjective;
import org.eclipse.viatra.dse.objectives.impl.AlwaysSatisfiedDummyHardObjective;
import org.eclipse.viatra.dse.objectives.impl.DepthHardObjective;
import org.eclipse.viatra.dse.objectives.impl.NeverSatisfiedDummyHardObjective;
import org.eclipse.viatra.dse.objectives.impl.NoRuleActivationsHardObjective;
import org.eclipse.viatra.dse.objectives.impl.TrajectoryCostSoftObjective;

/**
 * 
 * Helper class for creating built-in objectives.
 * 
 * @author Andras Szabolcs Nagy
 *
 */
public class Objectives {

    private Objectives() {
    }

    /**
     * This objective uses VIATRA Queries to calculate fitness and/or goal constraints. Use methods on the returned
     * objective to configure it.
     * 
     * @param name
     * @return The objective.
     * @see ConstraintsObjective
     */
    public static ConstraintsObjective createConstraintsObjective(String name) {
        return new ConstraintsObjective(name);
    }

    /**
     * This objective calculates fitness on the trajectory by adding either fix costs to the rules, or by calculating
     * custom fitness on activation of rules.
     * 
     * @param name
     * @return The objective.
     * @see TrajectoryCostSoftObjective
     */
    public static TrajectoryCostSoftObjective createTrajcetoryCostObjective(String name) {
        return new TrajectoryCostSoftObjective(name);
    }

    /**
     * This objective adds a goal constraint that a solution state should not have any activations.
     * 
     * @return The objective.
     * @see NoRuleActivationsHardObjective
     */
    public static NoRuleActivationsHardObjective createNoRuleActivationsHardConstraint() {
        return new NoRuleActivationsHardObjective();
    }

    /**
     * This objective adds a goal constraint that a solution state should not have any activations.
     * 
     * @param name
     * @return The objective.
     * @see NoRuleActivationsHardObjective
     */
    public static NoRuleActivationsHardObjective createNoRuleActivationsHardConstraint(String name) {
        return new NoRuleActivationsHardObjective(name);
    }

    /**
     * This objective can combine the calculated fitness value of other objectives. Weights are supported.
     * 
     * @param name
     * @return The objective.
     * @see NoRuleActivationsHardObjective
     */
    public static CompositeObjective createCompositeObjective(String name) {
        return new CompositeObjective(name);
    }

    /**
     * This hard objective is fulfilled in any circumstances. Use it if all states should be regarded as a valid
     * solution.
     * 
     * @return The objective.
     * @see AlwaysSatisfiedDummyHardObjective
     */
    public static AlwaysSatisfiedDummyHardObjective createAlwaysSatisfiedDummyHardObjective() {
        return new AlwaysSatisfiedDummyHardObjective();
    }

    /**
     * This hard objective is fulfilled in any circumstances. Use it if all states should be regarded as a valid
     * solution.
     * 
     * @param name
     * @return The objective.
     * @see AlwaysSatisfiedDummyHardObjective
     */
    public static AlwaysSatisfiedDummyHardObjective createDummyHardObjective(String name) {
        return new AlwaysSatisfiedDummyHardObjective(name);
    }

    /**
     * This hard objective is never fulfilled. Use it if all states should be regarded as an invalid solution.
     * 
     * @return The objective.
     * @see AlwaysSatisfiedDummyHardObjective
     */
    public static NeverSatisfiedDummyHardObjective createNeverSatisfiedDummyHardObjective() {
        return new NeverSatisfiedDummyHardObjective();
    }

    /**
     * This hard objective is never fulfilled. Use it if all states should be regarded as an invalid solution.
     * 
     * @return The objective.
     * @see AlwaysSatisfiedDummyHardObjective
     */
    public static NeverSatisfiedDummyHardObjective createNeverSatisfiedDummyHardObjective(String name) {
        return new NeverSatisfiedDummyHardObjective(name);
    }

    /**
     * This hard objective is fulfilled if the length of the trajectory is in the specified interval (inclusive). Use
     * {@link DepthHardObjective#withMinDepth(int)} and {@link DepthHardObjective#withMaxDepth(int)} to configure.
     * 
     * @return The objective.
     * @see DepthHardObjective
     */
    public static DepthHardObjective createDepthHardObjective() {
        return new DepthHardObjective();
    }

    /**
     * This hard objective is fulfilled if the length of the trajectory is in the specified interval (inclusive). Use
     * {@link DepthHardObjective#withMinDepth(int)} and {@link DepthHardObjective#withMaxDepth(int)} to configure.
     * 
     * @param name
     * @return The objective.
     * @see DepthHardObjective
     */
    public static DepthHardObjective createDepthHardObjective(String name) {
        return new DepthHardObjective(name);
    }

}