Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneslenfers committed Jul 26, 2022
1 parent ebc1a6f commit 684ac16
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 25 deletions.
4 changes: 4 additions & 0 deletions src/main/scala/elevate/heuristic_search/Metaheuristic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ case class Metaheuristic[P](name: String,
// result._3.writeToDisk(output)
//

(s"mv exploration/opentuner $output" !!)
(s"mv exploration/random_sampling $output" !!)
(s"mv exploration/exhaustive $output" !!)

// move tuner to output
// try {
// ("mv exploration/tuner/tuner_exploration.csv " + output + "/Executor" !!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ class AutotunerSearch[P] extends Heuristic[P] {
searchSpaceEmbeeding.addOne(ne)
embedding.add(ne, None)

println("search space embedding: " + searchSpaceEmbeeding.size)
println("search space embedding: " + embedding.getSize())
println(s"Embedding: (${searchSpaceEmbeeding.size}, ${embedding.getSize()})")
}
})
}
Expand Down Expand Up @@ -199,8 +198,9 @@ class AutotunerSearch[P] extends Heuristic[P] {

// todo read in these values
// val doe = size
val doe = 1000
val optimizationIterations = 1000 - doe

val doe = 0
val optimizationIterations = Math.min(200, searchSpace.size - 1)

val configStringOpentuner = {
s"""{
Expand Down Expand Up @@ -257,6 +257,30 @@ class AutotunerSearch[P] extends Heuristic[P] {
}"""
}

val configStringExhaustive =
s"""{
"application_name": "mv_exploration",
"optimization_objectives": ["runtime"],
"feasible_output" : {
"enable_feasible_predictor" : true,
"name" : "Valid",
"true_value" : "True",
"false_value" : "False"
},
"hypermapper_mode" : {
"mode" : "client-server"
},
"optimization_method": "exhaustive",
"input_parameters" : {
"i": {
"parameter_type" : "integer",
"values" : [0, ${size - 1}],
"constraints" : [],
"dependencies": []
}
}
}"""

def search(configFileString: String, iterations: Int, output: String, version: String) = {

// save configFile
Expand Down Expand Up @@ -371,20 +395,21 @@ class AutotunerSearch[P] extends Heuristic[P] {
}

// copy file to outpout (avoid overwriting)
("mv mv_exploration_output_samples.csv " + s"${output}/${version}_${k}.csv" !!)
(s"mkdir -p $output/$version/results" !!)
("mv mv_exploration_output_samples.csv " + s"${output}/${version}/results/${version}_${k}.csv" !!)

}


(s"mv ${configFile} " + s"${output}/${version}/tuner_exploration.json" !!)

// // plot results using hypermapper
// ("hm-plot-optimization-results " +
// "-j " + s"${output}/${version}/tuner_exploration.json" + " " +
// "-i " + s"${output}/${version}" + " " +
// "-o" + s"${output}/${version}/tuner_exploration.pdf" + " " +
// "--y_label \"Log Runtime(ms)\"" !!)
// // "-log --y_label \"Log Runtime(ms)\"" !!)
// plot results using hypermapper
("hm-plot-optimization-results " +
"-j " + s"${output}/${version}/tuner_exploration.json" + " " +
"-i " + s"${output}/${version}/results/" + " " +
"-o" + s"${output}/${version}/tuner_exploration.pdf" + " " +
"--y_label \"Log Runtime(ms)\"" !!)
// "-log --y_label \"Log Runtime(ms)\"" !!)

val duration2 = (System.currentTimeMillis() - explorationStartingPoint).toDouble
println("duration2: " + duration2 / 1000 + "s")
Expand All @@ -397,8 +422,27 @@ class AutotunerSearch[P] extends Heuristic[P] {

}

// search(configStringOpentuner, 1, "exploration", "opentuner")
search(configStringRandomSampling, 1, "exploration", "random_sampling")
val iterations = 10
try {
search(configStringOpentuner, iterations, "exploration", "opentuner")
}
catch {
case e: Throwable => println(e)
}

try {
search(configStringRandomSampling, iterations, "exploration", "random_sampling")
}
catch {
case e: Throwable => println(e)
}

try {
search(configStringExhaustive, 1, "exploration", "exhaustive")
}
catch {
case e: Throwable => println(e)
}

ExplorationResult(
solution,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,9 @@ class StandardPanel[P](

val result: Seq[Solution[P]] = afterRewrite match {
case Some(aftermath) =>
// todo check if normal form can be applied always
// println("rewrite: ")
val candidates = rewriteFunction.apply(solution).map(elem => Solution(aftermath.apply(elem.expression).get, elem.strategies))
// println("candidates: " + candidates.size)
// println("check")
val checked = candidates.filter(runner.checkSolution)
// val checked = candidates
// println("checked: " + checked.size)
checked
// rewriteFunction.apply(solution).map(elem => Solution(aftermath.apply(elem.expression).get, elem.strategies))
// todo check if normal form can be applied always
// rewriteFunction.apply(solution).map(elem => Solution(aftermath.apply(elem.expression).get, elem.strategies)).filter(runner.checkSolution)
rewriteFunction.apply(solution).map(elem => Solution(aftermath.apply(elem.expression).get, elem.strategies))
case None =>
rewriteFunction.apply(solution)
}
Expand All @@ -205,7 +198,8 @@ class StandardPanel[P](
// this.synchronized {

result match {
case _: Success[P] => Some(new Solution[P](result.get, solution.strategies :+ strategy)).filter(runner.checkSolution)
case _: Success[P] =>
Some(new Solution[P](result.get, solution.strategies :+ strategy))
case _: Failure[P] =>
// println("failure: " + result.toString)
None
Expand Down

0 comments on commit 684ac16

Please sign in to comment.