npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

microverse

v1.1.0

Published

A library for quickly prototyping genetic algorithms for nodejs

Downloads

18

Readme

#microverse microverse is a tiny library for quickly prototyping genetic algorithms. currently only compatible with node.

####Install npm i -S microverse

#####Breaking Changes (v1.1.0):

  • Chromosomes are now instances of Array.

#####Usage (TL;DR):

    let {Algorithm, Operators} = require('microverse');
    let {Crossovers, Selectors} = Operators;
    
    let population = [];
    
    //Generate a random population somehow
    for (let i = 0; i < 5; i++) {
        let chromosome = [...];
        population.push(chromosome);
    }
    
    let opts = {...};
    let alg = new Algorithm(opts);
    
    //Subscribe to events
    alg.on('evaluation', info => {...});
    alg.on('selection', info => {...});
    alg.on('crossover', info => {...});
    alg.on('generation', info => {...});
    alg.on('end', info => {...});
    
    //Run the algorithm indefinitely or until the criteria has met
    alg.run().then(info => {...});
    
    //Run the algorithm for 100 iterations or until the criteria has met
    alg.run(100).then(info => {...});
    
    //Pipe the progress (will stream json string 'generation' events)
    alg.pipe(process.stdout); 

#####Options:

  • lazyEval: Boolean (optional, default: true) - will evaluate each solution only once.
  • population: Array (required) - an array of chromosomes.
  • crossover: function (parents, done) (required) - errback accepts the offspring created.
  • selector: function (population, done) (required) - errback accepts the selected parents from the population created.
  • mutator: function (chromosome, done) (optional, default: (chromosome, done) => done()). errback accepts the mutated chromosome (falsely for unchanged).
  • fitnessFn: function (chromosome, done) (required) - errback accepts the fitness value for this chromosome.
  • stopCriteria: function (leader, population) (optional, default: (leader, population) => false) - A synchronous stop criteria to evaluate for each generation (truthy or falsely).
  • steadyState: (optional, default: false) - will determine if the algorithm should use the steady-state concept.

####Factories:

    let {Crossovers, Selectors} = require('microverse').Operators;
    let {SinglePoint, DoublePoint, Uniform, Arithmetic} = Crossovers;
    let {Elitism, Roulette, Rank} = Selectors;
    
    //Returns a selector function that selects 
    //2 parents based on the Roulette Wheel algorithm.
    let rws = Roulette(2);
    
    //Returns a crossover function that spreads
    //parents traits evenly across a new 
    let uxo = Uniform;

Note: unless specified manually, all

Read more about crossovers and selectors.

##TODO -[x] Stream / Generator support as population output. -[x] Add more crossover functions (Single Point, Double Point, Arithmetic). -[x] Add more selector functions (Roulette Wheel, Rank, Steady-State). -[ ] Proper object stream output. -[ ] Add genetic programming example. -[ ] Make it available to browsers. -[ ] Benchmarks.

##Development Install dependencies: npm i

Run tests: npm test