Return to best program sometimes
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package grow
|
package grow
|
||||||
|
|
||||||
import "io"
|
import "io"
|
||||||
|
import "math/rand"
|
||||||
import "sort"
|
import "sort"
|
||||||
|
|
||||||
import "gopkg.in/yaml.v2"
|
import "gopkg.in/yaml.v2"
|
||||||
@@ -15,6 +16,8 @@ type Definition struct {
|
|||||||
InstructionsPerFunctionMean uint64 `yaml:"instructions_per_function_mean"`
|
InstructionsPerFunctionMean uint64 `yaml:"instructions_per_function_mean"`
|
||||||
InstructionsPerFunctionStdDev uint64 `yaml:"instructions_per_function_std_dev"`
|
InstructionsPerFunctionStdDev uint64 `yaml:"instructions_per_function_std_dev"`
|
||||||
|
|
||||||
|
ReturnToBestPeriodMean uint64 `yaml:"return_to_best_period_mean"`
|
||||||
|
|
||||||
Samples []*Sample `yaml:"samples"`
|
Samples []*Sample `yaml:"samples"`
|
||||||
|
|
||||||
// Sample indices ranked by each output dimension
|
// Sample indices ranked by each output dimension
|
||||||
@@ -67,6 +70,10 @@ func (def *Definition) Grow(statusChan chan<- Status) (*vm.Program, error) {
|
|||||||
for {
|
for {
|
||||||
status.Attempts++
|
status.Attempts++
|
||||||
|
|
||||||
|
if def.ReturnToBestPeriodMean != 0 && rand.Uint64()%def.ReturnToBestPeriodMean == 0 {
|
||||||
|
prog = status.BestProgram.Copy()
|
||||||
|
}
|
||||||
|
|
||||||
Mutate(def, prog)
|
Mutate(def, prog)
|
||||||
|
|
||||||
scores, err := def.score(prog)
|
scores, err := def.score(prog)
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ instruction_limit: 10
|
|||||||
instructions_per_function_mean: 5
|
instructions_per_function_mean: 5
|
||||||
instructions_per_function_std_dev: 3
|
instructions_per_function_std_dev: 3
|
||||||
|
|
||||||
|
return_to_best_period_mean: 10000
|
||||||
|
|
||||||
samples:
|
samples:
|
||||||
- in: [3,4]
|
- in: [3,4]
|
||||||
out: [5]
|
out: [5]
|
||||||
|
|||||||
Reference in New Issue
Block a user