import { Base } from "../class/Base.js"; import { ClassUnion } from "../class/Mixin.js"; import { ChainedIterator } from "../collection/Iterator.js"; import { WalkContext, WalkStep } from "../graph/WalkDepth.js"; /** * Type alias for formula ids. A synonym for `number` */ export declare type FormulaId = number; /** * Type alias for cycle variables. Just a synonym for `symbol` */ export declare type Variable = symbol; /** * Type for cycle resolution value. It maps every variable to a formula. */ export declare type CycleResolutionValue = Map; export declare type CycleResolutionFormulas = Set; /** * Pre-defined constant formula id. If assigned to some variable, specifies, that this variable should keep the value proposed by user * (user input), or, if there's none, its previous value. */ export declare const CalculateProposed: FormulaId; /** * Class, describing a formula, which is part of the cyclic set. Formula just specifies its input variables and output variable, * it does not contain actual calculation. * * It is assumed that formula can only be "activated" if all of its inputs has value. It can be either a value from the previous iteration, * a value provided by user, or an output value of some other formula. See [[VariableInputState]] and [[CycleResolutionInput]]. */ export declare class Formula extends Base { /** * The id of the formula. It is assigned automatically, should not be changed. */ formulaId: FormulaId; /** * A set of the input variables for this formula. */ inputs: Set; /** * An output variable for this formula. */ output: Variable; } export declare class VariableWalkContext extends WalkContext { cache: FormulasCache; collectNext(sourceNode: Variable | Formula, toVisit: WalkStep[]): void; } declare const FormulasCache_base: Pick<{ new (...input: any[]): { /** * A set of variables, which forms cyclic computation */ variables: Set; /** * A set of formulas, which forms cyclic computation */ formulas: Set; $formulasByInput: Map>; $formulasByOutput: Map>; readonly formulasByInput: Map>; readonly formulasByOutput: Map>; add(formula: Formula): void; has(formula: Formula): boolean; fillCache(): void; allInputVariables(): Iterable; isCyclic(): boolean; initialize(props?: Partial): void; }; new: typeof Base.new; maybeNew: typeof Base.maybeNew; }, "prototype" | "new" | "maybeNew"> & (new (...args: any[]) => { /** * A set of variables, which forms cyclic computation */ variables: Set; /** * A set of formulas, which forms cyclic computation */ formulas: Set; $formulasByInput: Map>; $formulasByOutput: Map>; readonly formulasByInput: Map>; readonly formulasByOutput: Map>; add(formula: Formula): void; has(formula: Formula): boolean; fillCache(): void; allInputVariables(): Iterable; isCyclic(): boolean; initialize(props?: Partial): void; }) & import("typescript-mixin-class/src/class/Mixin").StaticPartOfMixinConstructor<{ new (...input: any[]): { /** * A set of variables, which forms cyclic computation */ variables: Set; /** * A set of formulas, which forms cyclic computation */ formulas: Set; $formulasByInput: Map>; $formulasByOutput: Map>; readonly formulasByInput: Map>; readonly formulasByOutput: Map>; add(formula: Formula): void; has(formula: Formula): boolean; fillCache(): void; allInputVariables(): Iterable; isCyclic(): boolean; initialize(props?: Partial): void; }; new: typeof Base.new; maybeNew: typeof Base.maybeNew; }, (base: ClassUnion) => { new (...input: any[]): { /** * A set of variables, which forms cyclic computation */ variables: Set; /** * A set of formulas, which forms cyclic computation */ formulas: Set; $formulasByInput: Map>; $formulasByOutput: Map>; readonly formulasByInput: Map>; readonly formulasByOutput: Map>; add(formula: Formula): void; has(formula: Formula): boolean; fillCache(): void; allInputVariables(): Iterable; isCyclic(): boolean; initialize(props?: Partial): void; }; new: typeof Base.new; maybeNew: typeof Base.maybeNew; }>; export declare class FormulasCache extends FormulasCache_base { } export declare type GraphInputsHash = string; /** * Abstract description of the cycle. Does not include the default formula resolution, only variables and formulas. See also [[CycleResolution]]. */ export declare class CycleDescription extends FormulasCache { } /** * Class describing the cycle resolution process. Requires the abstract cycle [[description]] and a set of default formulas. * * The resolution is performed with [[CycleResolution.resolve]] method. * * Resolution are memoized, based on the input. You should generally have a single instance of this class for a single set of default formulas, * to accumulate the results and make resolution fast. */ export declare class CycleResolution extends Base { /** * Abstract cycle description for this resolution. */ description: CycleDescription; /** * A set of default formulas for this resolution. Default formulas specifies how the calculation should be performed, if there's no user input * for any variable (or there's input for all of them). Also, default formulas are preferred, if several formulas can be chosen to continue the resolution. */ defaultResolutionFormulas: CycleResolutionFormulas; resolutionsByInputHash: Map; clear(): void; /** * This method accepts an input object and returns a cycle resolution. * Resolution are memoized, based on the input. * * @param input */ resolve(input: CycleResolutionInput): CycleResolutionValue; buildResolution(input: CycleResolutionInput): CycleResolutionValue; } /** * Enumeration for various states of the input data for variables in the cycle. Individual members corresponds to binary bits and can be set simultaneously, like: * * ```ts * const input : VariableInputState = VariableInputState.HasPreviousValue | VariableInputState.HasProposedValue * ``` */ export declare enum VariableInputState { NoInput = 0, /** * This bit indicates that variable has some previous value, when resolution starts. It can be any non-`undefined` value, including `null`. */ HasPreviousValue = 1, /** * This bit indicates that variable has user input, when resolution starts. It can be any non-`undefined` value, including `null`. */ HasProposedValue = 2, /** * This bit indicates, that user intention is to keep this variable unchanged, if that is possible (does not contradict to other user input). */ KeepIfPossible = 4 } /** * Class, describing the input data for a set of variables during cycle resolution. */ export declare class CycleResolutionInput extends Base { /** * A cycle resolution instance this input corresponds to. */ context: CycleResolution; private input; private $hash; get hash(): GraphInputsHash; get description(): CycleDescription; /** * Returns the same result as calling [[CycleResolution.resolve]] on this input instance */ get resolution(): CycleResolutionValue; initialize(...args: any[]): void; buildHash(): GraphInputsHash; batchToCharCode(batch: Variable[]): number; /** * This method sets the [[HasProposedValue]] flag for the specified variable. * * @param variable */ addProposedValueFlag(variable: Variable): void; hasProposedValue(variable: Variable): boolean; hasProposedValueVars(): ChainedIterator; /** * This method sets the [[HasPreviousValue]] flag for the specified variable. * * @param variable */ addPreviousValueFlag(variable: Variable): void; hasPreviousValue(variable: Variable): boolean; hasPreviousValueVars(): ChainedIterator; /** * This method sets the [[KeepIfPossible]] flag for the specified variable. * * @param variable */ addKeepIfPossibleFlag(variable: Variable): void; keepIfPossible(variable: Variable): boolean; keepIfPossibleVars(): ChainedIterator; } export declare class WalkState extends Base { context: CycleResolution; input: CycleResolutionInput; previous: WalkState; activatedFormula: Formula; private $activatedFormulas; get activatedFormulas(): FormulasCache; get description(): CycleDescription; thisAndPreviousStates(): Iterable; formulaHasProposedValueInInput(formula: Formula): boolean; unCoveredInputWeight(): number; preferFormula(formula1: Formula, formula2: Formula): -1 | 0 | 1; formulaIsDefault(formula: Formula): boolean; formulaCountInputsWithProposedOrKeep(formula: Formula): number; formulaAllInputsHasProposedOrKeep(formula: Formula): boolean; formulaAllInputsHasProposed(formula: Formula): boolean; formulaIsApplicable(formula: Formula): boolean; formulaIsInsignificant(formula: Formula): boolean; unvisitedFormulas(): Formula[]; next(): Iterable; asResolution(): CycleResolutionValue; } export {};