Commit 243bc267 by Tomasz Ciesielczyk

evaluation bug fix

parent 2eb84ad9
......@@ -40,7 +40,7 @@ class CurrentState(val powerUsage: Double) {
private var activeMachines: ArrayList<NodeUtil> = ArrayList()
fun getNodeUtil(resourceId: String):NodeUtil? {
return activeMachines.find { it.nodeId == resourceId }
?: this.unusedMachines.find { it.nodeId == resourceId }?:null
?: this.unusedMachines.find { it.nodeId == resourceId }
}
/**
......
......@@ -15,6 +15,7 @@ import psnc.m2dc.rtm.rpm.RPMApi
import psnc.m2dc.rtm.utils.Timer
import psnc.m2dc.rtm.utils.printConsole
import psnc.m2dc.rtm.utils.sum
import psnc.m2dc.rtm.utils.toJson
class PCMApi() {
//#region initialize INSTANCE
......@@ -194,6 +195,9 @@ class PCMApi() {
} else {
this.getMaxPowerUsageList()
}
printConsole("test0:" + this.getPowerCappingStrategy())
printConsole("test1:" + map.toJson())
printConsole("test2:" + map.sum())
if (totalLimit == null) {
totalLimit = this.getMaxPowerUsageList().sum()
}
......
......@@ -70,7 +70,7 @@ class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private v
open class PowerMode(val alpha: Double/*,val beta: Double=1.0*/) {
companion object {
fun valueOf(s: String) = when (s) {
"MAX_PERFORRMANCE" -> MAX_PERFORRMANCE
"MAX_PERFORMANCE" -> MAX_PERFORMANCE
"PERFORMANCE" -> PERFORMANCE
"BALANCED" -> BALANCED
"EFFICIENCY" -> EFFICIENCY
......@@ -81,11 +81,11 @@ class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private v
override fun toString() = this::class.java.simpleName
object MAX_PERFORRMANCE : PowerMode(0.0)
object PERFORMANCE : PowerMode(0.2)
object BALANCED : PowerMode(0.55)
object EFFICIENCY : PowerMode(0.85)
object MAX_EFFICIENCY : PowerMode(1.0)
object MAX_PERFORMANCE : PowerMode(1.0)
object PERFORMANCE : PowerMode(0.75)
object BALANCED : PowerMode(0.45)
object EFFICIENCY : PowerMode(0.15)
object MAX_EFFICIENCY : PowerMode(0.0)
class CUSTOM(alpha: Double) : PowerMode(alpha) {
override fun toString(): String {
return this.toJson()
......@@ -239,11 +239,17 @@ class Evaluation(initialPowerToReduce: Double, tradeOff: Double = 0.4, private v
val power = model.getPower(MAX_PERFORMANCE_LVL, util_0) //TODO: czy na pewno skalować przez utylizacje
val r_i = if (currentState.priority > 0.0 && currentState.priority < 1.0) (currentState.priority) / (1 - currentState.priority) else 1.0
val performanceImpact = Math.pow(model.getPerformance(perfLvlx), alpha)
val efficiencyImpact = Math.pow(model.getEfficiency(perfLvlx), 1 - alpha)
val eval = power * r_i * performanceImpact * efficiencyImpact
return eval
val perfValue = model.getPerformance(perfLvlx)
val effValue = model.getEfficiency(perfLvlx)
if (perfValue > 0 && effValue > 0) {
val performanceImpact = Math.pow(perfValue, alpha)
val efficiencyImpact = Math.pow(effValue, 1 - alpha)
val eval = power * r_i * performanceImpact * efficiencyImpact
return eval
} else {
return 0.0
}
}
......
......@@ -6,6 +6,7 @@ import org.ojalgo.optimisation.Variable
import org.slf4j.LoggerFactory
import psnc.m2dc.rtm.model.rpm.StateDefinition
import psnc.m2dc.rtm.utils.logInfo
import psnc.m2dc.rtm.utils.printConsole
import java.util.*
import java.util.concurrent.atomic.AtomicInteger
......@@ -19,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger
* https://github.com/optimatika/ojAlgo/wiki/Using-MPS
*
*/
open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,val algorithm: Algorithm) : Algorithm(e) {
open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double, val algorithm: Algorithm) : Algorithm(e) {
enum class SolverMode {
pcm, esm
}
......@@ -29,7 +30,6 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,v
}
private var currentBudget: Double
......@@ -145,18 +145,19 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,v
// }
return sum
}
fun solve():HashMap<String, Double>?{
return when (this.algorithm){
fun solve(): HashMap<String, Double>? {
printConsole("Solve via: " + this.algorithm)
return when (this.algorithm) {
Algorithm.milp -> exactAlgo()
Algorithm.greedy -> approximateAlgo()
Algorithm.random ->randomAlgo()
Algorithm.simple ->simpleAlgo()
Algorithm.proportional->proportionalAlgo()
Algorithm.random -> randomAlgo()
Algorithm.simple -> simpleAlgo()
Algorithm.proportional -> proportionalAlgo()
}
}
private fun exactAlgo(): HashMap<String, Double>? {
if (upperBoundCheck(null) < -currentBudget) {
/**impossible to fulfil requirements*/
......@@ -213,7 +214,7 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,v
return result
}
private fun proportionalAlgo(): HashMap<String, Double>? {
private fun proportionalAlgo(): HashMap<String, Double>? {
if (upperBoundCheck(null) < -currentBudget) {
/**impossible to fulfil requirements*/
return null
......@@ -281,7 +282,7 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,v
return null
}
private fun randomAlgo(): HashMap<String, Double>? {
private fun randomAlgo(): HashMap<String, Double>? {
if (upperBoundCheck(null) < -currentBudget) {
/**impossible to fulfil requirements*/
return null
......@@ -343,7 +344,7 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,v
return null
}
private fun simpleAlgo(): HashMap<String, Double>? {
private fun simpleAlgo(): HashMap<String, Double>? {
if (upperBoundCheck(null) < -currentBudget) {
/**impossible to fulfil requirements*/
return null
......@@ -398,7 +399,7 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,v
return result
}
private fun approximateAlgo(): HashMap<String, Double>? {
private fun approximateAlgo(): HashMap<String, Double>? {
if (upperBoundCheck(null) < -currentBudget) {
/**impossible to fulfil requirements*/
return null
......@@ -476,8 +477,6 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double,v
}
}
data class PerformanceSetting(val settingIndex: Int, val solver: Solver) {
......
package psnc.m2dc.rtm.commands.java
val APP_VERSION = "1.0.550_64170"
\ No newline at end of file
val APP_VERSION = "1.0.551_50237"
\ No newline at end of file
package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.550_64170"
\ No newline at end of file
const val APP_VERSION = "1.1.551_50237"
\ No newline at end of file
......@@ -115,13 +115,13 @@ class RECSApiMock(parser: XStream) : RECSApi(parser) {
return Pair(putXML ?: "", headers)
}
@Suppress("UNCHECKED_CAST")
override fun <T> postXML(url: String, body: String?, headers: HashMap<String, String>):
Pair<T, Map<String, String>> {
val res = this.put(url, body, headers).first
println("recs post output: ${res}")
return Pair(XMLParser.fromXML(res) as T, headers)
}
// @Suppress("UNCHECKED_CAST")
// override fun <T> postXML(url: String, body: String?, headers: HashMap<String, String>):
// Pair<T, Map<String, String>> {
// val res = this.put(url, body, headers).first
// println("recs post output: ${res}")
// return Pair(XMLParser.fromXML(res) as T, headers)
// }
@Suppress("UNCHECKED_CAST")
override fun loadRECSHosts(): List<String> /*List<LDAPRECSNode>*/ {
......
......@@ -42,7 +42,7 @@ class RTM {
// val online_data_timeout = RTMProperty(RTM + "online_data_timeout", 15000L /* 1000L*/)
val debug_actions = RTMProperty(RTM + "debug_actions", false)
val power_setting_evaluation_mode = RTMProperty(RTM + "power_setting_evaluation_mode", "BALANCED", description = """
MAX_PERFORRMANCE(0.0), PERFORMANCE(0.2) ,BALANCED(0.55), EFFICIENCY (0.85),MAX_EFFICIENCY (1.0), CUSTOM: {"alpa":0.3}
MAX_PERFORRMANCE(1.0), PERFORMANCE(0.75) ,BALANCED(0.45), EFFICIENCY (0.15),MAX_EFFICIENCY (0.0), CUSTOM: {"alpa":0.3}
""".trimIndent())
val management_threadpool_size = RTMProperty(RTM + "management_threadpool_size", 10)
val load_node_children = RTMProperty(RTM + "load_node_children", false)
......
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