Sha256: 14aec5e75f0fbb81ef831aa7a7559376d6fa5b0a4a02fec4f4219c5748a43054

Contents?: true

Size: 748 Bytes

Versions: 1

Compression:

Stored size: 748 Bytes

Contents

require 'evoasm'
require 'evoasm/x64'

Evoasm.log_level = :warn

examples = {
  [5, 1] => 1,
  [15, 5] => 5,
  [8, 2] => 2,
  [8, 4] => 4,
  [8, 6] => 2,
  [16, 8] => 8,
  [16, 2] => 2,
  [100, 10] => 10,
  [60, 10] => 10
}

parameters = Evoasm::Population::Parameters.new do |p|
  p.instructions = Evoasm::X64.instruction_names(:gp, :rflags)
  p.examples = examples
  p.deme_size = 2048
  p.parameters = %i(reg0 reg1 reg2 reg3)
  p.kernel_size = 20
  p.program_size = 3
  p.mutation_rate = 0.03
  p.deme_count = 2
  p.recur_limit = 100
end

population = Evoasm::Population.new parameters
program, loss = population.run do
  p "gen"
  population.plot File.join(__dir__, 'loss.gif')
end

p loss

program.to_gv.save File.join(__dir__, 'program.png')

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evoasm-0.1.0.pre2 docs/examples/vis.rb