Parameterize ideal function size
This commit is contained in:
@@ -10,6 +10,10 @@ type Definition struct {
|
|||||||
GlobalMemorySize uint64 `yaml:"global_memory_size"`
|
GlobalMemorySize uint64 `yaml:"global_memory_size"`
|
||||||
FunctionMemorySize uint64 `yaml:"function_memory_size"`
|
FunctionMemorySize uint64 `yaml:"function_memory_size"`
|
||||||
InstructionLimit uint64 `yaml:"instruction_limit"`
|
InstructionLimit uint64 `yaml:"instruction_limit"`
|
||||||
|
|
||||||
|
InstructionsPerFunctionMean uint64 `yaml:"instructions_per_function_mean"`
|
||||||
|
InstructionsPerFunctionStdDev uint64 `yaml:"instructions_per_function_std_dev"`
|
||||||
|
|
||||||
Samples []*Sample `yaml:"samples"`
|
Samples []*Sample `yaml:"samples"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,25 @@
|
|||||||
global_memory_size: 2
|
global_memory_size: 2
|
||||||
function_memory_size: 1
|
function_memory_size: 1
|
||||||
instruction_limit: 20
|
instruction_limit: 20
|
||||||
|
|
||||||
|
instructions_per_function_mean: 5
|
||||||
|
instructions_per_function_std_dev: 3
|
||||||
|
|
||||||
samples:
|
samples:
|
||||||
- in: [3,4]
|
- in: [3,4]
|
||||||
out: [5]
|
out: [5]
|
||||||
|
|
||||||
- in: [5,12]
|
|
||||||
out: [13]
|
|
||||||
|
|
||||||
- in: [8,15]
|
|
||||||
out: [17]
|
|
||||||
|
|
||||||
- in: [7,24]
|
- in: [7,24]
|
||||||
out: [25]
|
out: [25]
|
||||||
|
|
||||||
- in: [20,21]
|
|
||||||
out: [29]
|
|
||||||
|
|
||||||
- in: [12,35]
|
|
||||||
out: [37]
|
|
||||||
|
|
||||||
- in: [9, 40]
|
|
||||||
out: [41]
|
|
||||||
|
|
||||||
- in: [88, 105]
|
- in: [88, 105]
|
||||||
out: [137]
|
out: [137]
|
||||||
|
|
||||||
|
- in: [140, 171]
|
||||||
|
out: [221]
|
||||||
|
|
||||||
|
- in: [105, 208]
|
||||||
|
out: [233]
|
||||||
|
|
||||||
- in: [161, 240]
|
- in: [161, 240]
|
||||||
out: [289]
|
out: [289]
|
||||||
|
|||||||
@@ -5,13 +5,8 @@ import "math/rand"
|
|||||||
import "github.com/firestuff/subcoding/gen"
|
import "github.com/firestuff/subcoding/gen"
|
||||||
import "github.com/firestuff/subcoding/vm"
|
import "github.com/firestuff/subcoding/vm"
|
||||||
|
|
||||||
const instructionsPerFunctionMean = 15
|
func Mutate(def *Definition, prog *vm.Program) {
|
||||||
const instrucitonsPerFunctionStdDev = 10
|
target := int(rand.NormFloat64()*float64(def.InstructionsPerFunctionStdDev) + float64(def.InstructionsPerFunctionMean))
|
||||||
|
|
||||||
const minifyPeriodMean = 10000
|
|
||||||
|
|
||||||
func Mutate(_ *Definition, prog *vm.Program) {
|
|
||||||
target := int(rand.NormFloat64()*instrucitonsPerFunctionStdDev + instructionsPerFunctionMean)
|
|
||||||
|
|
||||||
if len(prog.Functions[0].Instructions) < target {
|
if len(prog.Functions[0].Instructions) < target {
|
||||||
addInstruction(prog, prog.Functions[0])
|
addInstruction(prog, prog.Functions[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user