@zfunction/genetics-js
Version:
Genetic and evolutionary algorithms framework for the web
38 lines • 1.37 kB
JavaScript
;
/*
* @license
* Copyright (c) 2019 Cristian Abrante. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var NumericRange_1 = require("../../base/NumericRange");
var IntegerNormalizer = /** @class */ (function () {
function IntegerNormalizer() {
}
/**
* Normalize the given gene, rounding it.
* @param gene that we want to normalize.
*/
IntegerNormalizer.normalize = function (gene) {
return Math.round(gene);
};
/**
* Normalizes a complete numeric genotype.
* @param genotype that we want to normalize.
*/
IntegerNormalizer.normalizeGenotype = function (genotype) {
var _this = this;
return genotype.map(function (gene) { return _this.normalize(gene); });
};
/**
* Normalizes a given numeric range.
* @param range that we want to normalize.
* @return the normalized range.
*/
IntegerNormalizer.normalizeRange = function (range) {
return new NumericRange_1.NumericRange(this.normalize(range.lowest), this.normalize(range.highest));
};
return IntegerNormalizer;
}());
exports.IntegerNormalizer = IntegerNormalizer;
//# sourceMappingURL=IntegerNormalizer.js.map