diff options
author | 2020-06-30 18:03:48 +0200 | |
---|---|---|
committer | 2020-06-30 18:03:48 +0200 | |
commit | e11bce7ad3e803e80883499fec0ad6e4540ffe43 (patch) | |
tree | ca3ad9d5b9137e9455485e43350a4a353f487f22 /Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/IObjective.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/objectives/IObjective.java')
-rw-r--r-- | Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/IObjective.java | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/IObjective.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/IObjective.java new file mode 100644 index 00000000..849dd4e8 --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/IObjective.java | |||
@@ -0,0 +1,110 @@ | |||
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.objectives; | ||
10 | |||
11 | import java.util.Comparator; | ||
12 | |||
13 | import org.eclipse.viatra.dse.base.ThreadContext; | ||
14 | |||
15 | /** | ||
16 | * | ||
17 | * Implementation of this interface represents a single objective of the DSE problem, which can assess a solution | ||
18 | * (trajectory) in a single number. It has a name and a comparator which orders two solution based on the calculated | ||
19 | * value. | ||
20 | * <p> | ||
21 | * Objectives can be either hard or soft objectives. Hard objectives can be satisfied or unsatisfied. If all of the hard | ||
22 | * objectives are satisfied on a single solution, then it is considered to be a valid (or goal) solution. | ||
23 | * <p> | ||
24 | * Certain objectives can have inner state for calculating the fitness value. In this case a new instance is necessary | ||
25 | * for every new thread, and the {@code createNew} method should not return the same instance more than once. | ||
26 | * | ||
27 | * @author Andras Szabolcs Nagy | ||
28 | * | ||
29 | */ | ||
30 | public interface IObjective { | ||
31 | |||
32 | /** | ||
33 | * Returns the name of the objective. | ||
34 | * | ||
35 | * @return The name of the objective. | ||
36 | */ | ||
37 | String getName(); | ||
38 | |||
39 | /** | ||
40 | * Sets the {@link Comparator} which is used to compare fitness (doubles). It determines whether the objective is to | ||
41 | * minimize or maximize (or minimize or maximize a delta from a given number). | ||
42 | * | ||
43 | * @param comparator The comparator. | ||
44 | */ | ||
45 | void setComparator(Comparator<Double> comparator); | ||
46 | |||
47 | /** | ||
48 | * Returns a {@link Comparator} which is used to compare fitness (doubles). It determines whether the objective is | ||
49 | * to minimize or maximize (or minimize or maximize a delta from a given number). | ||
50 | * | ||
51 | * @return The comparator. | ||
52 | */ | ||
53 | Comparator<Double> getComparator(); | ||
54 | |||
55 | /** | ||
56 | * Calculates the value of the objective on a given solution (trajectory). | ||
57 | * | ||
58 | * @param context | ||
59 | * The {@link ThreadContext} | ||
60 | * @return The objective value in double. | ||
61 | */ | ||
62 | Double getFitness(ThreadContext context); | ||
63 | |||
64 | /** | ||
65 | * Initializes the objective. It is called exactly once for every thread starts. | ||
66 | * | ||
67 | * @param context | ||
68 | * The {@link ThreadContext}. | ||
69 | */ | ||
70 | void init(ThreadContext context); | ||
71 | |||
72 | /** | ||
73 | * Returns an instance of the {@link IObjective}. If it returns the same instance, all the methods has to be thread | ||
74 | * save as they are called concurrently. | ||
75 | * | ||
76 | * @return An instance of the objective. | ||
77 | */ | ||
78 | IObjective createNew(); | ||
79 | |||
80 | /** | ||
81 | * Returns true if the objective is a hard objective. In such a case the method | ||
82 | * {@link IObjective#satisifiesHardObjective(Double)} is called. | ||
83 | * | ||
84 | * @return True if the objective is a hard objective. | ||
85 | * @see IObjective#satisifiesHardObjective(Double) | ||
86 | * @see IObjective | ||
87 | */ | ||
88 | boolean isHardObjective(); | ||
89 | |||
90 | /** | ||
91 | * Determines if the given fitness value satisfies the hard objective. | ||
92 | * | ||
93 | * @param fitness | ||
94 | * The fitness value of a solution. | ||
95 | * @return True if it satisfies the hard objective or it is a soft constraint. | ||
96 | * @see IObjective | ||
97 | */ | ||
98 | boolean satisifiesHardObjective(Double fitness); | ||
99 | |||
100 | /** | ||
101 | * Set the level of the objective. | ||
102 | */ | ||
103 | void setLevel(int level); | ||
104 | |||
105 | /** | ||
106 | * Gets the level of the objective. | ||
107 | */ | ||
108 | int getLevel(); | ||
109 | |||
110 | } | ||