roulette-wheel
roulette wheel selection
Last updated a year ago by patrickdmiller .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install roulette-wheel 
SYNC missed versions from official npm registry.

Roulette Wheel Selection / Fitness proportionate selection

See this

Usage

var RouletteWheel = require('./roulette-wheel.js');

//requires each individual have a name and val for fitness
var fitnesses = [
    {name:"a", val:100},
    {name:"b", val:10},
    {name:"c", val:1},
    {name:"d", val:0.1},
    {name:"e", val:0.01}
]

//optionally pass in precision for decimal fitness values
var rw = new RouletteWheel({fitnesses:fitnesses, precision:3})

//insert another fitness
rw.insert("f",0.001);

//returns the selected individual and the index in your original fitness array
//ex: { index: 0, target: { name: 'a', val: 100 } }
console.log(rw.spin());

Current Tags

  • 1.0.2                                ...           latest (a year ago)

2 Versions

  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |