Commits

Piotr Jessa committed 0242fe8

Preparations for final runs

Comments (0)

Files changed (8)

resources/benchmarks/mgr-test12/analysis.sql

+-- Getting all of the statistics from the runs:
+-- adjusted fitness
+-- hits
+-- number of generations
+
+
+select
+	x.key
+	,avg(x."adjusted-fitness") as "avg-fitness"
+	,stddev(x."adjusted-fitness") as "stddev-fitness"
+	,avg(x."hits-fitness") as "avg-hits"
+	,stddev(x."hits-fitness") as "stddev-hits"
+	,avg(x."generations") as "avg-generations"
+	,stddev(x."generations") as "stddev-generations"
+	,count(*) as "runs"
+from 
+(
+	select 
+	r.id
+	,p.key as "key"
+	,max(kaf.fitness) as "adjusted-fitness"
+	,max(khf.fitness) as "hits-fitness"
+	,count(*) as "generations"
+	from "runs" r 
+	join "prototypes" p on r."experimentId" = p."id" 
+	join "logs" l on l."runId" = r."id"
+	join "koza-adjusted-fitness-log" kaf on kaf."logId" = l."id"
+	join "koza-hits-fitness-log" khf on khf."logId" = l."id" + 1
+	where p.key like '%'
+	and r.state = 'done'
+	group by r.id, p.key
+	order by r.id 
+) x
+group by x.key;
+

resources/benchmarks/mgr-test12/in-1.properties

 configuration = pl.put.gi.running.universal.RunnerConfigurationProvider
 
 # Map of experiments prototype_key = number_of_runs
-
-
-
-
+map.TGP_0=10
+map.UMDA_0=10
+map.BOA_0=10
+map.Pure Push_0=10
+map.Push_0=10
+map.TGP_1=10
+map.UMDA_1=10
+map.BOA_1=10
+map.Pure Push_1=10
+map.Push_1=10
+map.TGP_2=10
+map.UMDA_2=10
+map.BOA_2=10
+map.Pure Push_2=10
+map.Push_2=10

src/main/scala/pl/put/regression/psh/ClassicDoublePshRegressionProblem.scala

         loadTestCases(state, base)
         
         repeatsInStack = state.parameters.getIntWithDefault(base.push(P_REPEATINTSTACK), null, 1);
-
+        state.output.warning("Repeat in stacks %d".format(repeatsInStack))
+        
         // safe check
         state.output.exitIfErrors()
     }

src/main/scala/pl/put/regression/psh/ClassicIntegerPshRegressionProblem.scala

         loadTestCases(state, base)
 
         repeatsInStack = state.parameters.getIntWithDefault(base.push(P_REPEATINTSTACK), null, 1);
+        state.output.warning("Repeat in stacks %d".format(repeatsInStack))
 
         // safe check
         state.output.exitIfErrors()

src/main/scala/pl/put/ri/mapper/FlatCodeMapper.scala

  */
 class FlatCodeMapper extends ICodeMapper {
 
-  private val logger = LoggerFactory.getLogger(classOf[FlatCodeMapper])
+    private val logger = LoggerFactory.getLogger(classOf[FlatCodeMapper])
 
-  private var cached: Boolean = false
-  private var instructions: Seq[String] = null
+    private var cached: Boolean = false
+    private var instructions: Seq[String] = null
 
-  def setInterpreter(interpreter: Interpreter) = {
+    def setInterpreter(interpreter: Interpreter) = {
 
-    if (!cached) {
-      val instructionString = interpreter.GetInstructionsString()
+        if (!cached) {
+            val instructionString = interpreter.GetInstructionsString()
 
-      val instructionSet = instructionString.split(" ").toSet
-      // sort instruction set
-      val sortedInstructionSeq = instructionSet.toSeq.sortWith((x, y) => x < y)
+            val instructionSet = instructionString.split(" ").toSet
+            // sort instruction set
+            val sortedInstructionSeq = instructionSet.toSeq.sortWith((x, y) => x < y)
 
-      // generate mapping between vectors and instruction set 
-      // the index is the position on the genome ;)
-      instructions = sortedInstructionSeq.toSeq
+            // generate mapping between vectors and instruction set 
+            // the index is the position on the genome ;)
+            instructions = sortedInstructionSeq.toSeq
 
-      // perform safe checking of few instructions 
-      validate()
+            // perform safe checking of few instructions 
+            validate()
 
-      cached = true
+            cached = true
+        }
     }
-  }
 
-  def validate() = {
-    // in instruction set there should no more validation at all, in ecj-psh
-    // the NOP instruction is used as result of bad position of the other instructions
-  }
+    def validate() = {
+        // in instruction set there should no more validation at all, in ecj-psh
+        // the NOP instruction is used as result of bad position of the other instructions
+    }
 
-  private def toInstruction(gene: Short): String = {
+    private def toInstruction(gene: Short): String = {
 
-    // TODO: this code should be refactored into some other methods ?
-    // this is fail safe distribution changing ability
-    if (gene >= instructions.size) {
-      return instructions.head
-    }
-    if (gene < 0) {
-      return instructions.last
+        // TODO: this code should be refactored into some other methods ?
+        // this is fail safe distribution changing ability
+        if (gene >= instructions.size) {
+            val rank = gene % instructions.size
+            return instructions(rank)
+        }
+        if (gene < 0) {
+            val absGene = math.abs(gene)
+            val rank = absGene % instructions.size
+            return instructions(rank)
+        }
+        return instructions(gene)
     }
-    return instructions(gene)
-  }
 
-  override def toProgram(genome: Array[Short]): Program = {
-    logger.debug("Mapping genome: {}", genome)
-    val innerCode = genome.map(x => toInstruction(x)).mkString(" ")
-    val programCode = "(%s)".format(innerCode)
-    logger.debug("Maping program: {}", programCode)
-    new Program(programCode)
-  }
+    override def toProgram(genome: Array[Short]): Program = {
+        logger.debug("Mapping genome: {}", genome)
+        val innerCode = genome.map(x => toInstruction(x)).mkString(" ")
+        val programCode = "(%s)".format(innerCode)
+        logger.debug("Maping program: {}", programCode)
+        new Program(programCode)
+    }
 
-  override def toGeome(program: Program): Array[Short] = {
-    // TODO: this code is left to be written
-    throw new RuntimeException("not yet implemented")
-  }
+    override def toGeome(program: Program): Array[Short] = {
+        // TODO: this code is left to be written
+        throw new RuntimeException("not yet implemented")
+    }
 }

src/main/scala/pl/put/ri/problem/PshRegressionProblem.scala

         // read code mapper 
         mapper = new FlatCodeMapper()
         repeatInStack = state.parameters.getIntWithDefault(base.push(P_REPEATINTSTACK), null, 1);
+        state.output.warning("Repeat in stacks %d".format(repeatInStack))
 
         // safe check
         state.output.exitIfErrors()

src/test/resources/psh/pure-instructions-erc.txt

+float.*
+float.+
+float.-
+float./
+float.dup
+float.flush
+float.stackdepth
+float.swap
+float.erc
+input.makeinputs1

src/test/resources/psh/pure-instructions.txt

 float.flush
 float.stackdepth
 float.swap
-float.erc
 input.makeinputs1