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/api/Solution.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/api/Solution.java')
-rw-r--r-- | Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Solution.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Solution.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Solution.java new file mode 100644 index 00000000..b776db7a --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Solution.java | |||
@@ -0,0 +1,60 @@ | |||
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 java.util.Collection; | ||
12 | import java.util.HashSet; | ||
13 | import java.util.Iterator; | ||
14 | import java.util.Set; | ||
15 | |||
16 | public class Solution { | ||
17 | |||
18 | private Set<SolutionTrajectory> trajectories; | ||
19 | private final Object stateId; | ||
20 | |||
21 | public Solution(Object stateId, SolutionTrajectory trajectory) { | ||
22 | this.stateId = stateId; | ||
23 | trajectories = new HashSet<>(); | ||
24 | trajectories.add(trajectory); | ||
25 | } | ||
26 | |||
27 | public void addTrajectory(SolutionTrajectory trajectory) { | ||
28 | trajectories.add(trajectory); | ||
29 | } | ||
30 | |||
31 | public SolutionTrajectory getArbitraryTrajectory() { | ||
32 | return trajectories.iterator().next(); | ||
33 | } | ||
34 | |||
35 | public SolutionTrajectory getShortestTrajectory() { | ||
36 | Iterator<SolutionTrajectory> iterator = trajectories.iterator(); | ||
37 | SolutionTrajectory shortestTrajecotry = iterator.next(); | ||
38 | int minSize = shortestTrajecotry.getTrajectoryLength(); | ||
39 | |||
40 | while (iterator.hasNext()) { | ||
41 | SolutionTrajectory traj = iterator.next(); | ||
42 | int size = traj.getTrajectoryLength(); | ||
43 | if (size < minSize) { | ||
44 | shortestTrajecotry = traj; | ||
45 | minSize = size; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | return shortestTrajecotry; | ||
50 | } | ||
51 | |||
52 | public Collection<SolutionTrajectory> getTrajectories() { | ||
53 | return trajectories; | ||
54 | } | ||
55 | |||
56 | public Object getStateCode() { | ||
57 | return stateId; | ||
58 | } | ||
59 | |||
60 | } | ||