Return to best program sometimes
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user