diff options
author | 2019-05-22 20:38:53 -0400 | |
---|---|---|
committer | 2019-05-22 20:38:53 -0400 | |
commit | b7ed3353ba34dd837bfc15f7e48c30a2cdc7ce75 (patch) | |
tree | 53e966837f2403b47e62f978bc777d6fe93ce10a /Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.java | |
parent | VIATRA DSE and COIN-OR CBC implementations of CPS case study (diff) | |
download | VIATRA-Generator-b7ed3353ba34dd837bfc15f7e48c30a2cdc7ce75.tar.gz VIATRA-Generator-b7ed3353ba34dd837bfc15f7e48c30a2cdc7ce75.tar.zst VIATRA-Generator-b7ed3353ba34dd837bfc15f7e48c30a2cdc7ce75.zip |
MDEOptimiser implementation of CPS benchmark
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.java')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.java new file mode 100644 index 00000000..6100d821 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.java | |||
@@ -0,0 +1,54 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo; | ||
2 | |||
3 | import com.google.common.collect.HashMultiset; | ||
4 | import com.google.common.collect.Multiset; | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; | ||
9 | import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.common.util.EList; | ||
12 | import org.eclipse.emf.ecore.EObject; | ||
13 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction; | ||
14 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution; | ||
15 | |||
16 | @SuppressWarnings("all") | ||
17 | public class NonRedundantAllocationsConstraint implements IGuidanceFunction { | ||
18 | @Override | ||
19 | public String getName() { | ||
20 | return "NonRedundantAllocations"; | ||
21 | } | ||
22 | |||
23 | @Override | ||
24 | public double computeFitness(final Solution solution) { | ||
25 | int _xblockexpression = (int) 0; | ||
26 | { | ||
27 | EObject _model = solution.getModel(); | ||
28 | final CyberPhysicalSystem cps = ((CyberPhysicalSystem) _model); | ||
29 | int cost = 0; | ||
30 | EList<HostType> _hostTypes = cps.getHostTypes(); | ||
31 | for (final HostType hostType : _hostTypes) { | ||
32 | EList<HostInstance> _instances = hostType.getInstances(); | ||
33 | for (final HostInstance host : _instances) { | ||
34 | { | ||
35 | final HashMultiset<Requirement> bins = HashMultiset.<Requirement>create(); | ||
36 | EList<ApplicationInstance> _applications = host.getApplications(); | ||
37 | for (final ApplicationInstance app : _applications) { | ||
38 | bins.add(app.getRequirement()); | ||
39 | } | ||
40 | Set<Multiset.Entry<Requirement>> _entrySet = bins.entrySet(); | ||
41 | for (final Multiset.Entry<Requirement> entry : _entrySet) { | ||
42 | int _cost = cost; | ||
43 | int _count = entry.getCount(); | ||
44 | int _minus = (_count - 1); | ||
45 | cost = (_cost + _minus); | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | _xblockexpression = cost; | ||
51 | } | ||
52 | return _xblockexpression; | ||
53 | } | ||
54 | } | ||