Options
All
  • Public
  • Public/Protected
  • All
Menu

@thi.ng/fuzzy-viz

Index

Functions

Const fuzzySetToAscii

  • fuzzySetToAscii(opts?: Partial<AsciiVizOpts>): InstrumentFn<string>
  • Parameters

    • Optional opts: Partial<AsciiVizOpts>

    Returns InstrumentFn<string>

Const fuzzySetToHiccup

  • fuzzySetToHiccup(opts?: Partial<VizualizeVarOpts>): InstrumentFn<any[]>
  • Parameters

    • Optional opts: Partial<VizualizeVarOpts>

    Returns InstrumentFn<any[]>

Const fuzzySetToSvg

  • fuzzySetToSvg(opts?: Partial<VizualizeVarOpts>): InstrumentFn<string>
  • Parameters

    • Optional opts: Partial<VizualizeVarOpts>

    Returns InstrumentFn<string>

Const instrumentStrategy

  • instrumentStrategy<T>(strategy: DefuzzStrategy, instrument: Fn3<FnN, Range, number, T>): DefuzzStrategy & IClear & IDeref<T[]>
  • Higher order function. Takes an existing DefuzzStrategy 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 mechanism implemented by the returned function. Since {@link defuzz} 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
    const strategy = instrumentStrategy(
    cogStrategy({ 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();

    Type parameters

    • T

    Parameters

    • strategy: DefuzzStrategy
    • instrument: Fn3<FnN, Range, number, T>

    Returns DefuzzStrategy & IClear & IDeref<T[]>

Const varToHiccup

  • varToHiccup(var: LVar<any>, opts?: Partial<VizualizeVarOpts>): any[]
  • Takes an LVar and visualization options. Evaluates all of the var's fuzzy sets in the var's value domain and visualizes them as polygons. Returns a @thi.ng/hiccup-canvas compatible shape component tree.

    Parameters

    • var: LVar<any>
    • opts: Partial<VizualizeVarOpts> = {}

    Returns any[]

Const varToSvg

  • varToSvg($var: LVar<any>, opts: Partial<VizualizeVarOpts>): string
  • Similar to varToHiccup, but then also serializes the result to an actual SVG string.

    Parameters

    • $var: LVar<any>
    • opts: Partial<VizualizeVarOpts>

    Returns string

Generated using TypeDoc