UNPKG

@thi.ng/fuzzy

Version:

Fuzzy logic operators & configurable rule inferencing engine

43 lines 1.88 kB
import type { FnN2 } from "@thi.ng/api"; import type { LVarKeySet, LVarSet, Rule } from "./api.js"; /** * Defines and returns a new rule object. Takes a T-norm (or S-norm) `op`, an * object of input conditions, an object of results and optional rule `weight`. * The `op` function is used to combine input terms. * * @remarks * The input and output objects are each using LVar names as keys and respective * var terms (their names) as values (see example). * * The optional rule weight (default: 1) is used by {@link defuzz} to adjust * rule importance. * * Also see {@link and}, {@link strongAnd}, {@link or} for syntax sugar. * * @example * ```ts * import { rule } from "@thi.ng/fuzzy"; * * // given 3 LVars from a classic fuzzy logic example: * // food, service, tip * * // define this rule: * // "If the food was bad AND service poor, then a small tip only" * // here multiply is used for strong conjunction of the food & service terms * rule( * (a, b) => a * b, * { food: "bad", service: "poor" }, * { tip: "small" } * ) * ``` * * @param op - * @param $if * @param then - * @param weight - */ export declare const rule: <I extends LVarSet<string>, O extends LVarSet<string>>(op: FnN2, $if: LVarKeySet<I, keyof I>, then: LVarKeySet<O, keyof O>, weight?: number) => Rule<I, O>; export declare const and: <I extends LVarSet<string>, O extends LVarSet<string>>($if: LVarKeySet<I, keyof I>, then: LVarKeySet<O, keyof O>, weight?: number) => Rule<I, O>; export declare const strongAnd: <I extends LVarSet<string>, O extends LVarSet<string>>($if: LVarKeySet<I, keyof I>, then: LVarKeySet<O, keyof O>, weight?: number) => Rule<I, O>; export declare const or: <I extends LVarSet<string>, O extends LVarSet<string>>($if: LVarKeySet<I, keyof I>, then: LVarKeySet<O, keyof O>, weight?: number) => Rule<I, O>; //# sourceMappingURL=rules.d.ts.map