UNPKG

tycho-solver

Version:

Evolutionary computation and optimization library

47 lines 1.4 kB
/** * GeneticAlgorithm.ts * A flexible and powerful genetic algorithm library for TypeScript and JavaScript */ /** * Export utility functions */ export const geneticAlgorithmUtils = { /** * Helper to create a binary gene generator */ binaryGeneGenerator: () => Math.random() < 0.5 ? 0 : 1, /** * Helper to convert binary genes to decimal */ binaryToDecimal: (genes) => { return genes.reduce((decimal, bit, index) => { if (bit !== 0 && bit !== 1) { throw new Error(`Invalid binary value at index ${index}: ${bit}. Only 0 and 1 are allowed.`); } return decimal + bit * Math.pow(2, genes.length - index - 1); }, 0); }, /** * Helper to create a gene generator for real values in a range */ realValueGeneGenerator: (min, max) => { return () => min + Math.random() * (max - min); } }; /** * Tycho Solver - Evolutionary Computation Library * * A modular and extensible library for evolutionary computation * and optimization problems. */ // Core interfaces and operators export * from './core'; // Algorithm implementations export * from './algorithms'; // Search algorithms and components export * from './search'; // Parallel computation modules export * from './parallel'; // Utility functions export * from './utils'; //# sourceMappingURL=index.js.map