tycho-solver
Version:
Evolutionary computation and optimization library
64 lines (63 loc) • 2.25 kB
JavaScript
;
/**
* GeneticAlgorithm.ts
* A flexible and powerful genetic algorithm library for TypeScript and JavaScript
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.geneticAlgorithmUtils = void 0;
/**
* Export utility functions
*/
exports.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
__exportStar(require("./core"), exports);
// Algorithm implementations
__exportStar(require("./algorithms"), exports);
// Search algorithms and components
__exportStar(require("./search"), exports);
// Parallel computation modules
__exportStar(require("./parallel"), exports);
// Utility functions
__exportStar(require("./utils"), exports);