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/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend | |
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/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend new file mode 100644 index 00000000..e46d59a6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend | |||
@@ -0,0 +1,27 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem | ||
4 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction | ||
5 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution | ||
6 | |||
7 | class UnavailableMemoryConstraint implements IGuidanceFunction { | ||
8 | override getName() { | ||
9 | "UnavailableMemory" | ||
10 | } | ||
11 | |||
12 | override computeFitness(Solution solution) { | ||
13 | val cps = solution.model as CyberPhysicalSystem | ||
14 | var int cost = 0 | ||
15 | for (hostType : cps.hostTypes) { | ||
16 | for (host : hostType.instances) { | ||
17 | val utilization = ResourceUtilizationUtil.getMemoryUtilization(host) | ||
18 | val difference = utilization - hostType.defaultMemory | ||
19 | if (difference > 0) { | ||
20 | cost += difference | ||
21 | } | ||
22 | } | ||
23 | } | ||
24 | cost | ||
25 | } | ||
26 | |||
27 | } | ||