import type { Fn3, IClear, IDeref } from "@thi.ng/api"; import type { DefuzzStrategy, FuzzyFn, LVarDomain } from "@thi.ng/fuzzy"; import type { AsciiVizOpts, InstrumentFn, VizualizeVarOpts } from "./api.js"; /** * Higher order function. Takes an existing * [`DefuzzStrategy`](https://docs.thi.ng/umbrella/fuzzy/types/DefuzzStrategy.html) * and an instrumentation function. Returns new `DefuzzStrategy` which first * executes original `strategy`, then calls `instrument` with the same args AND * the computed result obtained from `strategy`. Returns result of original * `strategy`. * * @remarks * The instrumentation function is intended to perform side effects (e.g. debug * outputs) and/or produce secondary results (e.g. visualizations). The latter * can be obtained through the * [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html) mechanism * implemented by the returned function. Since * [`defuzz`](https://docs.thi.ng/umbrella/fuzzy/functions/defuzz.html) might * call the strategy multiple times (i.e. if there are multiple output vars * used), `.deref()` will always return an array of secondary results. * * Note: The secondary results from the instrumentation function will persist & * accumulate. If re-using the instrumented strategy for multiple `defuzz()` * invocations, it's highly recommended to clear any previous results using * `.clear()`. * * @example * ```ts tangle:../export/instrument-strategy.ts * import { centroidStrategy, gaussian } from "@thi.ng/fuzzy"; * import { instrumentStrategy, fuzzySetToAscii } from "@thi.ng/fuzzy-viz"; * * const strategy = instrumentStrategy( * centroidStrategy({ samples: 1000 }), * fuzzySetToAscii({ width: 40, height: 8 }) * ); * * strategy(gaussian(5, 2), [0, 10]); * // 4.995 * * console.log(strategy.deref()[0]) * // .................▄▆█|█▆▄................. * // ...............▅████|████▅............... * // .............▄██████|██████▄............. * // ...........▂▇███████|███████▇▂........... * // ..........▅█████████|█████████▅.......... * // .......▁▅███████████|███████████▅▁....... * // .....▃▆█████████████|█████████████▆▃..... * // ▃▄▅▇████████████████|████████████████▇▅▄▃ * // ^ 5.00 * * // cleanup (optional) * strategy.clear(); * ``` * * @param strategy - * @param instrument - */ export declare const instrumentStrategy: (strategy: DefuzzStrategy, instrument: Fn3) => DefuzzStrategy & IClear & IDeref; export declare const fuzzySetToHiccup: (opts?: Partial) => InstrumentFn; export declare const fuzzySetToSvg: (opts?: Partial) => InstrumentFn; export declare const fuzzySetToAscii: (opts?: Partial) => InstrumentFn; //# sourceMappingURL=strategy.d.ts.map