Commit c5117c97 by Tomasz Ciesielczyk

tradeoff api

parent a6f56bef
...@@ -10,7 +10,7 @@ import psnc.m2dc.rtm.utils.toJson ...@@ -10,7 +10,7 @@ import psnc.m2dc.rtm.utils.toJson
/** /**
* Created by Tomek on 2018-04-20. * Created by Tomek on 2018-04-20.
* @tradeoff power and energy efficiency tradeoff - α, (0- maximum performance, 1 – maximum energy efficiency), α ε * <0,1> * @tradeoff power and energy efficiency tradeoff - α, (1- maximum performance, 0 – maximum energy efficiency), α ε * <0,1>
* @impact tradeoff's impact - β, β ε<0,∞) * @impact tradeoff's impact - β, β ε<0,∞)
*/ */
class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private val advancedPriorityMode: Boolean = true) { class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private val advancedPriorityMode: Boolean = true) {
...@@ -34,7 +34,17 @@ class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private v ...@@ -34,7 +34,17 @@ class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private v
mPowerOverLimit = currentPowerOverLimit mPowerOverLimit = currentPowerOverLimit
} }
val alpha: Double private var alpha: Double
var tradeOff
get() = this.alpha
set(value) {
if (value in 0.0..1.0) {
alpha = value
} else {
throw IllegalArgumentException("trade off value must be between 0 and 1 inclusively")
}
logInfo("Evaluation tradeOff (alpha parameter): $alpha")
}
//#region initializers //#region initializers
constructor(powerCap: Double, mode: PowerMode, advancedPriorityMode: Boolean = true) : this(powerCap, mode.alpha, constructor(powerCap: Double, mode: PowerMode, advancedPriorityMode: Boolean = true) : this(powerCap, mode.alpha,
......
...@@ -9,9 +9,11 @@ import psnc.m2dc.rtm.model.rest.ResourceAction ...@@ -9,9 +9,11 @@ import psnc.m2dc.rtm.model.rest.ResourceAction
import psnc.m2dc.rtm.model.rest.ResourceActionResult import psnc.m2dc.rtm.model.rest.ResourceActionResult
import psnc.m2dc.rtm.pcm.PCMAlgorithm import psnc.m2dc.rtm.pcm.PCMAlgorithm
import psnc.m2dc.rtm.pcm.PCMApi import psnc.m2dc.rtm.pcm.PCMApi
import psnc.m2dc.rtm.pcm.algorithm.Evaluation
import psnc.m2dc.rtm.pcm.algorithm.Solver import psnc.m2dc.rtm.pcm.algorithm.Solver
import psnc.m2dc.rtm.pcm.algorithm.Utils import psnc.m2dc.rtm.pcm.algorithm.Utils
import psnc.m2dc.rtm.properties.RTMProperties import psnc.m2dc.rtm.properties.RTMProperties
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.rpm.RPMApi import psnc.m2dc.rtm.rpm.RPMApi
import psnc.m2dc.rtm.utils.loadJsonFile import psnc.m2dc.rtm.utils.loadJsonFile
import psnc.m2dc.rtm.utils.logDebug import psnc.m2dc.rtm.utils.logDebug
...@@ -108,35 +110,36 @@ class RTMApi private constructor() { ...@@ -108,35 +110,36 @@ class RTMApi private constructor() {
fun checkAlgorithm(path: String, algorithm: Solver.Algorithm?, limit: Double) { fun checkAlgorithm(path: String, algorithm: Solver.Algorithm?, limit: Double) {
log.info("Algorithm Check!") log.info("Algorithm Check!")
val state = { val state = {tradeoff:Double ->
val s = loadJsonFile<CurrentState>(Paths.get(path), CurrentState::class.java) val s = loadJsonFile<CurrentState>(Paths.get(path), CurrentState::class.java)
?: throw NullPointerException("State not found") ?: throw NullPointerException("State not found")
s.currentPowerOverLimit = s.powerUsage - limit s.currentPowerOverLimit = s.powerUsage - limit
s.eval.resetPowerBudget(s.currentPowerOverLimit) s.eval.resetPowerBudget(s.currentPowerOverLimit)
s.eval.tradeOff =tradeoff
s s
} }
ServerInitializer.check() ServerInitializer.check()
val initialState = state() val tradeoff = Evaluation.PowerMode.valueOf(Keys.RTM.power_setting_evaluation_mode.get()).alpha
val initialState = state(tradeoff)
if (algorithm != null) { if (algorithm != null) {
var res = PCMAlgorithm(state(), algorithm).next() var res = PCMAlgorithm(state(tradeoff), algorithm).next()
this.saveResult(res, algorithm, "pcm", initialState) this.saveResult(res, algorithm, "pcm", initialState,limit.toInt())
res = ESMAlgorithm(state(), algorithm).next() res = ESMAlgorithm(state(tradeoff), algorithm).next()
this.saveResult(res, algorithm, "esm", initialState) this.saveResult(res, algorithm, "esm", initialState,limit.toInt())
// res.toJson(RTMProperties.parsePath("${RTMProperties.basePath}/esm_$algorithm.out").toAbsolutePath().toString(), true) // res.toJson(RTMProperties.parsePath("${RTMProperties.basePath}/esm_$algorithm.out").toAbsolutePath().toString(), true)
} else { } else {
Solver.Algorithm.values().forEach { algorithm -> Solver.Algorithm.values().forEach { algorithm ->
var res = PCMAlgorithm(state(), algorithm).next() var res = PCMAlgorithm(state(tradeoff), algorithm).next()
this.saveResult(res, algorithm, "pcm", initialState) this.saveResult(res, algorithm, "pcm", initialState,limit.toInt())
res = ESMAlgorithm(state(), algorithm).next() res = ESMAlgorithm(state(tradeoff), algorithm).next()
this.saveResult(res, algorithm, "esm", initialState) this.saveResult(res, algorithm, "esm", initialState,limit.toInt())
} }
} }
} }
fun saveResult(powerSettings: PowerSettings, algorithm: Solver.Algorithm, procedure: String, initialState: CurrentState) { fun saveResult(powerSettings: PowerSettings, algorithm: Solver.Algorithm, procedure: String, initialState: CurrentState,powerLimit:Int) {
var avgPerf = 0.0 var avgPerf = 0.0
var expectedPowerConsumption = 0.0 var expectedPowerConsumption = 0.0
var expectedPowerConsumption100 = 0.0 var expectedPowerConsumption100 = 0.0
...@@ -158,8 +161,12 @@ class RTMApi private constructor() { ...@@ -158,8 +161,12 @@ class RTMApi private constructor() {
} }
avgPerf /= powerSettings.getSettings().size avgPerf /= powerSettings.getSettings().size
val path = RTMProperties.parsePath("${RTMProperties.basePath}/${procedure}_$algorithm.out").toAbsolutePath().toString() val path = RTMProperties.parsePath("${RTMProperties.basePath}/powercap_output/limit_$powerLimit/${procedure}_$algorithm.out").toAbsolutePath()
val f = File(path)
val f = File(path.toString())
f.parentFile.mkdirs()
val sb = StringBuilder() val sb = StringBuilder()
powerSettings.getSettings().forEach { powerSettings.getSettings().forEach {
sb.append("${it.key} => ${it.value}\n") sb.append("${it.key} => ${it.value}\n")
......
package psnc.m2dc.rtm.commands.java package psnc.m2dc.rtm.commands.java
val APP_VERSION = "1.0.530_65154" val APP_VERSION = "1.0.530_69557"
\ No newline at end of file \ No newline at end of file
package psnc.m2dc.rtm.client package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.530_65155" const val APP_VERSION = "1.1.530_69557"
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment