diff options
author | 20001LastOrder <boqi.chen@mail.mcgill.ca> | 2020-11-04 01:16:22 -0500 |
---|---|---|
committer | 20001LastOrder <boqi.chen@mail.mcgill.ca> | 2020-11-04 01:16:22 -0500 |
commit | 93243cb3faf1ccd733081fcf380559ac03c9ad35 (patch) | |
tree | 421f9f174eb77c387b5acaa05f01e64a62cab3a7 /Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/DepthHardObjective.java | |
parent | add realistic solver (diff) | |
parent | Optimizing generator with linear objective functions (diff) | |
download | VIATRA-Generator-93243cb3faf1ccd733081fcf380559ac03c9ad35.tar.gz VIATRA-Generator-93243cb3faf1ccd733081fcf380559ac03c9ad35.tar.zst VIATRA-Generator-93243cb3faf1ccd733081fcf380559ac03c9ad35.zip |
merge with current master, comment numerical solver related logging
Diffstat (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/DepthHardObjective.java')
-rw-r--r-- | Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/DepthHardObjective.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/DepthHardObjective.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/DepthHardObjective.java new file mode 100644 index 00000000..b21da397 --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/impl/DepthHardObjective.java | |||
@@ -0,0 +1,89 @@ | |||
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.objectives.impl; | ||
10 | |||
11 | import org.eclipse.viatra.dse.base.ThreadContext; | ||
12 | import org.eclipse.viatra.dse.objectives.IObjective; | ||
13 | |||
14 | /** | ||
15 | * This hard objective is fulfilled if the trajectory is in the specified interval (inclusive). | ||
16 | * | ||
17 | * @author Andras Szabolcs Nagy | ||
18 | * | ||
19 | */ | ||
20 | public class DepthHardObjective extends BaseObjective { | ||
21 | |||
22 | private static final String DEFAULT_NAME = "DepthHardObjective"; | ||
23 | protected int minDepth; | ||
24 | protected int maxDepth; | ||
25 | private ThreadContext context; | ||
26 | |||
27 | public DepthHardObjective() { | ||
28 | this(DEFAULT_NAME, 0, Integer.MAX_VALUE); | ||
29 | } | ||
30 | |||
31 | public DepthHardObjective(String name) { | ||
32 | this(name, 0, Integer.MAX_VALUE); | ||
33 | } | ||
34 | |||
35 | public DepthHardObjective(int minDepth) { | ||
36 | this(DEFAULT_NAME, minDepth, Integer.MAX_VALUE); | ||
37 | } | ||
38 | |||
39 | public DepthHardObjective(String name, int minDepth) { | ||
40 | this(name, minDepth, Integer.MAX_VALUE); | ||
41 | } | ||
42 | |||
43 | public DepthHardObjective(int minDepth, int maxDepth) { | ||
44 | this(DEFAULT_NAME, minDepth, maxDepth); | ||
45 | } | ||
46 | |||
47 | public DepthHardObjective(String name, int minDepth, int maxDepth) { | ||
48 | super(name); | ||
49 | this.minDepth = minDepth; | ||
50 | this.maxDepth = maxDepth; | ||
51 | } | ||
52 | |||
53 | public DepthHardObjective withMinDepth(int minDepth) { | ||
54 | this.minDepth = minDepth; | ||
55 | return this; | ||
56 | } | ||
57 | |||
58 | public DepthHardObjective withMaxDepth(int maxDepth) { | ||
59 | this.maxDepth = maxDepth; | ||
60 | return this; | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | public void init(ThreadContext context) { | ||
65 | super.init(context); | ||
66 | this.context = context; | ||
67 | } | ||
68 | |||
69 | @Override | ||
70 | public Double getFitness(ThreadContext context) { | ||
71 | return 0d; | ||
72 | } | ||
73 | |||
74 | @Override | ||
75 | public boolean isHardObjective() { | ||
76 | return true; | ||
77 | } | ||
78 | |||
79 | @Override | ||
80 | public boolean satisifiesHardObjective(Double fitness) { | ||
81 | return minDepth <= context.getDepth() && context.getDepth() <= maxDepth; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public IObjective createNew() { | ||
86 | return new DepthHardObjective(name, minDepth, maxDepth); | ||
87 | } | ||
88 | |||
89 | } | ||