Return to best program sometimes

This commit is contained in:
Ian Gulliver
2021-11-24 20:08:47 -08:00
parent 1c4cf25e34
commit 0bccd0c94b
2 changed files with 9 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package grow
import "io"
import "math/rand"
import "sort"
import "gopkg.in/yaml.v2"
@@ -15,6 +16,8 @@ type Definition struct {
InstructionsPerFunctionMean uint64 `yaml:"instructions_per_function_mean"`
InstructionsPerFunctionStdDev uint64 `yaml:"instructions_per_function_std_dev"`
ReturnToBestPeriodMean uint64 `yaml:"return_to_best_period_mean"`
Samples []*Sample `yaml:"samples"`
// Sample indices ranked by each output dimension
@@ -67,6 +70,10 @@ func (def *Definition) Grow(statusChan chan<- Status) (*vm.Program, error) {
for {
status.Attempts++
if def.ReturnToBestPeriodMean != 0 && rand.Uint64()%def.ReturnToBestPeriodMean == 0 {
prog = status.BestProgram.Copy()
}
Mutate(def, prog)
scores, err := def.score(prog)