@syntest/search
Version:
The common core of the SynTest Framework
110 lines • 2.98 kB
JavaScript
;
/*
* Copyright 2020-2021 Delft University of Technology and SynTest contributors
*
* This file is part of SynTest Framework - SynTest Core.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.EvaluationBudget = void 0;
const logging_1 = require("@syntest/logging");
/**
* Budget for the number of evaluation performed during the search process.
*
* @author Mitchell Olsthoorn
*/
class EvaluationBudget {
/**
* Constructor.
*
* @param maxEvaluations The maximum number of evaluations of this budget
*/
constructor(maxEvaluations = Number.MAX_SAFE_INTEGER) {
EvaluationBudget.LOGGER = (0, logging_1.getLogger)("EvaluationBudget");
this._currentEvaluations = 0;
this._maxEvaluations = maxEvaluations;
this._tracking = false;
}
/**
* @inheritDoc
*/
getRemainingBudget() {
return this._maxEvaluations - this._currentEvaluations;
}
/**
* @inheritDoc
*/
getUsedBudget() {
return this._currentEvaluations;
}
/**
* @inheritDoc
*/
getTotalBudget() {
return this._maxEvaluations;
}
/**
* @inheritDoc
*/
reset() {
EvaluationBudget.LOGGER.silly("reset");
this._currentEvaluations = 0;
this._tracking = false;
}
/**
* @inheritDoc
*/
initializationStarted() {
EvaluationBudget.LOGGER.silly("initializationStarted");
this._tracking = true;
}
/**
* @inheritDoc
*/
initializationStopped() {
EvaluationBudget.LOGGER.silly("initializationStopped");
this._tracking = false;
}
/**
* @inheritDoc
*/
searchStarted() {
EvaluationBudget.LOGGER.silly("searchStarted");
this._tracking = true;
}
/**
* @inheritDoc
*/
searchStopped() {
EvaluationBudget.LOGGER.silly("searchStopped");
this._tracking = false;
}
/**
* @inheritDoc
*/
iteration() {
EvaluationBudget.LOGGER.silly("iteration");
}
/**
* @inheritDoc
*/
evaluation() {
EvaluationBudget.LOGGER.silly("evaluation");
if (this._tracking && this._currentEvaluations < this._maxEvaluations) {
this._currentEvaluations++;
}
}
}
exports.EvaluationBudget = EvaluationBudget;
//# sourceMappingURL=EvaluationBudget.js.map