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