tycho-solver
Version:
Evolutionary computation and optimization library
22 lines • 841 B
JavaScript
import { MoveSelectionOperator } from './MoveSelectionOperator';
export const NeighborhoodOperator = async ({ solution, fitness, neighborhoodFunction, objectiveFunction, options, iterations = 0 }) => {
let neighbors;
if (options.dynamicNeighborhoodFunction) {
neighbors = options.dynamicNeighborhoodFunction(solution);
}
else if (neighborhoodFunction) {
neighbors = neighborhoodFunction(solution);
}
else {
throw new Error('No neighborhood function provided. Please specify either neighborhoodFunction or dynamicNeighborhoodFunction.');
}
return await MoveSelectionOperator({
neighbors,
currentSolution: solution,
currentFitness: fitness,
objectiveFunction,
options,
iterations
});
};
//# sourceMappingURL=NeighborhoodOperator.js.map