UNPKG

consys

Version:

consys is a flexible tool to evaluate models using generic and readable constraints.

46 lines (45 loc) 1.49 kB
import { ConstraintData, Evaluation, EvaluationData } from './Util'; /** * Represents a single constraint, with specified model and state data types. */ export default class Constraint<M, S> { private textProcessor; private readonly assertionFunction; private readonly resource; private readonly ast; /** * Create a new constraint from constraint data. * * @param resource constraint data */ constructor(resource: ConstraintData); /** * Returns a map of the number of occurrences for each key of the model. */ getModelVarOccurrences(): { [key: string]: number; }; /** * Returns a map of the number of occurrences for each key of the state. */ getStateVarOccurrences(): { [key: string]: number; }; /** * Evaluate this constraint with a given model and state, along with custom functions. * * @param data data to evaluate, along with functions * @param rescan determine if the text processor should rescan if something has changed */ evaluate(data: EvaluationData<M, S>, rescan: boolean): Evaluation; /** * Checks if this constraint is consistent with given model, state and functions. * * @param data data to evaluate, along with functions */ isConsistent(data: EvaluationData<M, S>): boolean; /** * Returns the original resource that was used to generate this constraint. */ getResource(): ConstraintData; }