@zfunction/genetics-js
Version:
Genetic and evolutionary algorithms framework for the web
63 lines • 2.72 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.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var base_1 = require("../../../individual/numeric/base");
var utils_1 = require("../../utils");
var base_2 = require("./../../base/");
/**
* ## NumericGenerator
* Generator of [[NumericIndividuals]]
*/
var NumericGenerator = /** @class */ (function (_super) {
__extends(NumericGenerator, _super);
function NumericGenerator() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Generates a [[NumericIndividual]]
* with the specified params.
* @param length of the individual that is going to be generated.
* @param range of the individual that is going to be generated.
* @param engine (of `random-js`) that is going to be used.
* @return [[NumericIndividual]] with the generated genotype.
* @throws RangeError if `length` is not greater than `0`.
* @throws Error if `range` is not valid.
*/
NumericGenerator.prototype.generate = function (length, range, engine) {
if (range === void 0) { range = base_1.NumericRange.DEFAULT; }
if (engine === void 0) { engine = utils_1.Generator.DEFAULT_ENGINE; }
var params = { length: length, range: range, engine: engine };
return this.generateWith(params);
};
/**
* Generates a [[NumericIndividual]] with
* the specified params.
* @param params of the generator.
* @return [[NumericIndividual]] with the generated genotype.
* @throws RangeError if `length` is not greater than `0`.
* @throws Error if `range` is not valid.
*/
NumericGenerator.prototype.generateWith = function (params) {
return _super.prototype.generateWith.call(this, params);
};
return NumericGenerator;
}(base_2.BaseGenerator));
exports.NumericGenerator = NumericGenerator;
//# sourceMappingURL=NumericGenerator.js.map