@zfunction/genetics-js
Version:
Genetic and evolutionary algorithms framework for the web
67 lines • 2.69 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 floating_1 = require("../../../reader/numeric/floating");
var base_1 = require("../base");
/**
* ## Floating Individual
* Floating individual is an individual which
* contains an array of floating point numbers.
* The representation could be a string with
* the numbers or the array of numbers.
*/
var FloatingIndividual = /** @class */ (function (_super) {
__extends(FloatingIndividual, _super);
/**
* Constructor of the class.
* It takes a representation and a range as
* parameters.
*
* Representation could be a string or an
* array of numbers. If representation is
* a `string`, it takes the default range as
* parameter. if it is a number[]` it takes the
* specified range.
* @param representation
* @param range of the individual. Only if representation
* is a `number[]`.
* @throws Error if range is not valid.
* @throws RangeError if representation is a `number[]` and
* is not in range specified by the range parameter.
* @throws Error if representation is an `string` with an
* wrong format.
*/
function FloatingIndividual(representation, range) {
if (range === void 0) { range = base_1.NumericRange.DEFAULT; }
var _this = this;
if (typeof representation === 'string') {
_this = _super.call(this, []) || this;
var reader = new floating_1.FloatingReader();
_this.copy(reader.read(representation));
}
else {
_this = _super.call(this, representation, range) || this;
}
return _this;
}
return FloatingIndividual;
}(base_1.NumericIndividual));
exports.FloatingIndividual = FloatingIndividual;
//# sourceMappingURL=FloatingIndividual.js.map