UNPKG

@syntest/search

Version:

The common core of the SynTest Framework

139 lines 4.67 kB
import { Logger } from "@syntest/logging"; import { Archive } from "../../Archive"; import { BudgetManager } from "../../budget/BudgetManager"; import { Encoding } from "../../Encoding"; import { EncodingRunner } from "../../EncodingRunner"; import { SearchSubject } from "../../SearchSubject"; import { TerminationManager } from "../../termination/TerminationManager"; import { ObjectiveFunction } from "../ObjectiveFunction"; import { SecondaryObjectiveComparator } from "../secondary/SecondaryObjectiveComparator"; /** * Manager that keeps track of which objectives have been covered and are still to be searched. * * @author Mitchell Olsthoorn */ export declare abstract class ObjectiveManager<T extends Encoding> { protected static LOGGER: Logger; /** * Archive of covered objectives with the fittest encoding for that objective. * @protected */ protected _archive: Archive<T>; /** * Set of current objectives. * @protected */ protected _currentObjectives: Set<ObjectiveFunction<T>>; /** * Set of covered objectives. * @protected */ protected _coveredObjectives: Set<ObjectiveFunction<T>>; /** * Set of uncovered objectives. * @protected */ protected _uncoveredObjectives: Set<ObjectiveFunction<T>>; /** * Runner for executing encodings. * @protected */ protected _runner: EncodingRunner<T>; /** * List of secondary objectives. * @protected */ protected _secondaryObjectives: Set<SecondaryObjectiveComparator<T>>; /** * The subject of the search. * @protected */ protected _subject: SearchSubject<T>; /** * Constructor. * * @param runner Encoding runner * @param secondaryObjectives Secondary objectives to use */ constructor(runner: EncodingRunner<T>, secondaryObjectives: Set<SecondaryObjectiveComparator<T>>); /** * Logic for handling covered objectives. * * @param objectiveFunction * @param encoding */ protected abstract _handleCoveredObjective(objectiveFunction: ObjectiveFunction<T>, encoding: T): ObjectiveFunction<T>[]; /** * Logic for handling uncovered objectives. * * @param objectiveFunction * @param encoding * @param distance */ protected abstract _handleUncoveredObjective(objectiveFunction: ObjectiveFunction<T>, encoding: T, distance: number): void; /** * Update the objectives. * * @param objectiveFunction * @param encoding * @param distance * @protected */ protected abstract _updateObjectives(objectiveFunction: ObjectiveFunction<T>): ObjectiveFunction<T>[]; /** * Evaluate multiple encodings on the current objectives. * * @param encodings The encoding to evaluate * @param budgetManager The budget manager to track the remaining budget * @param terminationManager The termination trigger manager */ evaluateMany(encodings: T[], budgetManager: BudgetManager<T>, terminationManager: TerminationManager): Promise<void>; /** * Evaluate one encoding on the current objectives. * * @param encoding The encoding to evaluate * @param budgetManager The budget manager to track evaluation * @param terminationManager The termination trigger manager */ evaluateOne(encoding: T, budgetManager: BudgetManager<T>, _terminationManager: TerminationManager): Promise<void>; protected evaluateObjective(encoding: T, objectiveFunction: ObjectiveFunction<T>): void; /** * Load the objectives from the search subject into the manager. * * @param subject The subject to load in */ abstract load(subject: SearchSubject<T>): void; /** * Finalize the objectives before retrieving the archive. */ abstract finalize(_finalPopulation: T[]): void; /** * Reset the objectives. * * This function is used to reset the objectives when the search subject changes. * * TODO: Should the archive be reset as well? */ protected _reset(): void; /** * Return the uncovered objectives. */ getUncoveredObjectives(): Set<ObjectiveFunction<T>>; /** * Return the current objectives. */ getCurrentObjectives(): Set<ObjectiveFunction<T>>; /** * Return the covered objectives. */ getCoveredObjectives(): Set<ObjectiveFunction<T>>; /** * Return the archive. */ getArchive(): Archive<T>; /** * Determines if there are objectives left to cover. */ hasObjectives(): boolean; } //# sourceMappingURL=ObjectiveManager.d.ts.map