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/TooLowAverageHddConstraint.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/TooLowAverageHddConstraint.xtend')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.xtend | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.xtend new file mode 100644 index 00000000..85cc8115 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.xtend | |||
@@ -0,0 +1,33 @@ | |||
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 TooLowAverageHddConstraint implements IGuidanceFunction { | ||
8 | static val THRESHOLD = 0.25 | ||
9 | |||
10 | override getName() { | ||
11 | "TooLowAverageHdd" | ||
12 | } | ||
13 | |||
14 | override computeFitness(Solution solution) { | ||
15 | val cps = solution.model as CyberPhysicalSystem | ||
16 | var double sumUtilization | ||
17 | var int numHosts | ||
18 | for (hostType : cps.hostTypes) { | ||
19 | numHosts += hostType.instances.size | ||
20 | for (host : hostType.instances) { | ||
21 | val utilization = ResourceUtilizationUtil.getHddUtilization(host) | ||
22 | sumUtilization += (utilization as double) / hostType.defaultHdd | ||
23 | } | ||
24 | } | ||
25 | val averageUtilization = sumUtilization / numHosts | ||
26 | val difference = THRESHOLD - averageUtilization | ||
27 | if (difference > 0) { | ||
28 | difference | ||
29 | } else { | ||
30 | 0 | ||
31 | } | ||
32 | } | ||
33 | } | ||