Skip to content

computational-problem-solving/js-metaheuristics

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metaheuristic code bricks for JavaScript.

for ( const [ candidate , fitness ] of localsearch( [ solution , best ] ) ) ... ;

NPM license NPM version Bower version Build Status Coverage Status Dependencies Status devDependencies Status Code Climate NPM downloads per month GitHub issues Inline docs

Can be managed through jspm, duo, component, bower, ender, jam, spm, and npm.

Install

jspm

jspm install github:aureooms/js-metaheuristics # or jspm install npm:aureooms-js-metaheuristics 

duo

No install step needed for duo!

component

component install aureooms/js-metaheuristics 

bower

bower install aureooms-js-metaheuristics 

ender

ender add aureooms-js-metaheuristics 

jam

jam install aureooms-js-metaheuristics 

spm

spm install aureooms-js-metaheuristics --save 

npm

npm install aureooms-js-metaheuristics --save 

Require

jspm

let metaheuristics = require( "github:aureooms/js-metaheuristics" ) ; // or import metaheuristics from 'aureooms-js-metaheuristics' ;

duo

let metaheuristics = require( "aureooms/js-metaheuristics" ) ;

component, ender, spm, npm

let metaheuristics = require( "aureooms-js-metaheuristics" ) ;

bower

The script tag exposes the global variable metaheuristics.

<script src="bower_components/aureooms-js-metaheuristics/js/dist/metaheuristics.min.js"></script>

Alternatively, you can use any tool mentioned here.

jam

require( [ "aureooms-js-metaheuristics" ] , function ( metaheuristics ) { ... } ) ;

Use

Evaluation methods

let fitness = evaluate( solution , mutation ) ;

Application methods

apply( solution , mutation ) ;

Walking methods

for ( const mutation of walk( solution ) ) ... ;

Acceptance methods

if ( accept( fitness , best ) ) ... ;

Pivoting methods

The signature of a pivoting method is the following

let [ mutation , fitness ] = pivoting( [ solution , best ] , walk , evaluate ) ;

Search methods

Global and local search methods either halt or loop forerver. In order to maintain a fine-grained step count, every step of the search method will yield a solution. This means there will be a lot of repetitions.

Halting

You can iterate over all candidates

for ( const [ candidate , fitness ] of localsearch( [ solution , best ] ) ) ... ;

To keep only the best candidate, maximize over fitness

import { increasing , attr } from 'aureooms-js-compare' ; import { max } from 'aureooms-js-itertools' ; let [ candidate , fitness ] = max( attr( increasing , 1 ) , localsearch( [ solution , best ] ) ) ;

Non-halting

For non-halting methods you can restrict your search to the first n candidates

import { head } from 'aureooms-js-itertools' ; for ( const [ candidate , fitness ] of head( localsearch( solution , best ) , n ) ) ... ;

The same is valid for selecting the best of the first n candidates

import { increasing , attr } from 'aureooms-js-compare' ; import { head , max } from 'aureooms-js-itertools' ; let [ candidate , fitness ] = max( attr( increasing , 1 ) , head( localsearch( [ solution , best ] ) , n ) ) ;

Packages

No packages published

Contributors 2

  •  
  •