@thi.ng/fuzzy 2.1.81 → 2.1.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/README.md +1 -1
- package/package.json +8 -11
- package/strategies/bisector.d.ts +4 -2
- package/strategies/bisector.js +2 -2
- package/strategies/centroid.d.ts +4 -2
- package/strategies/centroid.js +2 -2
- package/strategies/maxima.d.ts +12 -6
- package/strategies/maxima.js +3 -3
- package/strategies/opts.d.ts +2 -1
- package/strategies/opts.js +2 -2
- package/var.d.ts +6 -6
- package/var.js +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 193 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/fuzzy",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.82",
|
|
4
4
|
"description": "Fuzzy logic operators & configurable rule inferencing engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/fuzzy",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/math": "^5.
|
|
39
|
+
"@thi.ng/api": "^8.11.3",
|
|
40
|
+
"@thi.ng/math": "^5.11.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@microsoft/api-extractor": "^7.
|
|
44
|
-
"esbuild": "^0.21.
|
|
43
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
44
|
+
"esbuild": "^0.21.5",
|
|
45
45
|
"typedoc": "^0.25.13",
|
|
46
|
-
"typescript": "^5.
|
|
46
|
+
"typescript": "^5.5.2"
|
|
47
47
|
},
|
|
48
48
|
"keywords": [
|
|
49
49
|
"agent",
|
|
@@ -92,9 +92,6 @@
|
|
|
92
92
|
"./strategies/maxima": {
|
|
93
93
|
"default": "./strategies/maxima.js"
|
|
94
94
|
},
|
|
95
|
-
"./strategies/opts": {
|
|
96
|
-
"default": "./strategies/opts.js"
|
|
97
|
-
},
|
|
98
95
|
"./tnorms": {
|
|
99
96
|
"default": "./tnorms.js"
|
|
100
97
|
},
|
|
@@ -105,5 +102,5 @@
|
|
|
105
102
|
"thi.ng": {
|
|
106
103
|
"year": 2020
|
|
107
104
|
},
|
|
108
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
109
106
|
}
|
package/strategies/bisector.d.ts
CHANGED
|
@@ -12,10 +12,12 @@ import type { DefuzzStrategy, DefuzzStrategyOpts } from "../api.js";
|
|
|
12
12
|
* Also see {@link DefuzzStrategyOpts}
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
-
* ```ts
|
|
15
|
+
* ```ts tangle:../../export/bisector-strategy.ts
|
|
16
16
|
* import { bisectorStrategy, trapezoid } from "@thi.ng/fuzzy";
|
|
17
17
|
*
|
|
18
|
-
*
|
|
18
|
+
* console.log(
|
|
19
|
+
* bisectorStrategy()(trapezoid(0,1,5,6), [0,6])
|
|
20
|
+
* );
|
|
19
21
|
* // 2.97
|
|
20
22
|
*
|
|
21
23
|
* // ......▁█████████████|█████████████▁.....
|
package/strategies/bisector.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fit } from "@thi.ng/math/fit";
|
|
2
|
-
import {
|
|
2
|
+
import { __defaultOpts } from "./opts.js";
|
|
3
3
|
const bisectorStrategy = (opts) => {
|
|
4
|
-
let { samples } =
|
|
4
|
+
let { samples } = __defaultOpts(opts);
|
|
5
5
|
return (fn, [min, max]) => {
|
|
6
6
|
const delta = (max - min) / samples;
|
|
7
7
|
let sum = [];
|
package/strategies/centroid.d.ts
CHANGED
|
@@ -12,10 +12,12 @@ import type { DefuzzStrategy, DefuzzStrategyOpts } from "../api.js";
|
|
|
12
12
|
* Also see {@link DefuzzStrategyOpts}
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
-
* ```ts
|
|
15
|
+
* ```ts tangle:../../export/centroid-strategy.ts
|
|
16
16
|
* import { centroidStrategy, trapezoid } from "@thi.ng/fuzzy";
|
|
17
17
|
*
|
|
18
|
-
*
|
|
18
|
+
* console.log(
|
|
19
|
+
* centroidStrategy()(trapezoid(0,1,5,6), [0,6])
|
|
20
|
+
* );
|
|
19
21
|
* // 3.0000000000000004
|
|
20
22
|
*
|
|
21
23
|
* // ......▁█████████████|█████████████▁.....
|
package/strategies/centroid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __defaultOpts } from "./opts.js";
|
|
2
2
|
const centroidStrategy = (opts) => {
|
|
3
|
-
let { samples } =
|
|
3
|
+
let { samples } = __defaultOpts(opts);
|
|
4
4
|
return (fn, [min, max]) => {
|
|
5
5
|
const delta = (max - min) / samples;
|
|
6
6
|
let num = 0;
|
package/strategies/maxima.d.ts
CHANGED
|
@@ -9,10 +9,12 @@ import type { DefuzzStrategy, DefuzzStrategyOpts } from "../api.js";
|
|
|
9
9
|
* Also see {@link DefuzzStrategyOpts}
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
|
-
* ```ts
|
|
12
|
+
* ```ts tangle:../../export/mean-of-maxima-strategy.ts
|
|
13
13
|
* import { meanOfMaximaStrategy, trapezoid } from "@thi.ng/fuzzy";
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* console.log(
|
|
16
|
+
* meanOfMaximaStrategy()(trapezoid(0,1,5,6), [0,6])
|
|
17
|
+
* );
|
|
16
18
|
* // 3
|
|
17
19
|
*
|
|
18
20
|
* // ......▁█████████████|█████████████▁.....
|
|
@@ -40,10 +42,12 @@ export declare const meanOfMaximaStrategy: (opts?: Partial<DefuzzStrategyOpts>)
|
|
|
40
42
|
* Also see {@link DefuzzStrategyOpts}
|
|
41
43
|
*
|
|
42
44
|
* @example
|
|
43
|
-
* ```ts
|
|
45
|
+
* ```ts tangle:../../export/first-of-maxima-strategy.ts
|
|
44
46
|
* import { firstOfMaximaStrategy, trapezoid } from "@thi.ng/fuzzy";
|
|
45
47
|
*
|
|
46
|
-
*
|
|
48
|
+
* console.log(
|
|
49
|
+
* firstOfMaximaStrategy()(trapezoid(0,1,5,6), [0,6])
|
|
50
|
+
* );
|
|
47
51
|
* // 1.02
|
|
48
52
|
*
|
|
49
53
|
* // ......▁|██████████████████████████▁.....
|
|
@@ -71,10 +75,12 @@ export declare const firstOfMaximaStrategy: (opts?: Partial<DefuzzStrategyOpts>)
|
|
|
71
75
|
* Also see {@link DefuzzStrategyOpts}
|
|
72
76
|
*
|
|
73
77
|
* @example
|
|
74
|
-
* ```ts
|
|
78
|
+
* ```ts tangle:../../export/last-of-maxima-strategy.ts
|
|
75
79
|
* import { lastOfMaximaStrategy, trapezoid } from "@thi.ng/fuzzy";
|
|
76
80
|
*
|
|
77
|
-
*
|
|
81
|
+
* console.log(
|
|
82
|
+
* lastOfMaximaStrategy()(trapezoid(0,1,5,6), [0,6])
|
|
83
|
+
* );
|
|
78
84
|
* // 4.98
|
|
79
85
|
*
|
|
80
86
|
* // ......▁██████████████████████████|▁.....
|
package/strategies/maxima.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { eqDelta } from "@thi.ng/math/eqdelta";
|
|
2
|
-
import {
|
|
2
|
+
import { __defaultOpts } from "./opts.js";
|
|
3
3
|
const meanOfMaximaStrategy = (opts) => {
|
|
4
|
-
const { samples, eps } =
|
|
4
|
+
const { samples, eps } = __defaultOpts(opts);
|
|
5
5
|
return (fn, [min, max]) => {
|
|
6
6
|
const delta = (max - min) / samples;
|
|
7
7
|
let peak = -Infinity;
|
|
@@ -23,7 +23,7 @@ const meanOfMaximaStrategy = (opts) => {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
const firstOfMaximaStrategy = (opts) => {
|
|
26
|
-
const { samples } =
|
|
26
|
+
const { samples } = __defaultOpts(opts);
|
|
27
27
|
return (fn, [min, max]) => {
|
|
28
28
|
const delta = (max - min) / samples;
|
|
29
29
|
let peak = -Infinity;
|
package/strategies/opts.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { DefuzzStrategyOpts } from "../api.js";
|
|
2
|
-
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const __defaultOpts: (opts?: Partial<DefuzzStrategyOpts>) => DefuzzStrategyOpts;
|
|
3
4
|
//# sourceMappingURL=opts.d.ts.map
|
package/strategies/opts.js
CHANGED
package/var.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Maybe } from "@thi.ng/api";
|
|
2
|
-
import type { LVar } from "./api.js";
|
|
2
|
+
import type { LVar, LVarDomain } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Takes a `domain` interval and on object of named fuzzy sets and returns a new
|
|
5
5
|
* Linguistic variable, which can then be used as input or output var for
|
|
@@ -21,7 +21,7 @@ import type { LVar } from "./api.js";
|
|
|
21
21
|
* @param domain -
|
|
22
22
|
* @param terms -
|
|
23
23
|
*/
|
|
24
|
-
export declare const variable: <K extends string>(domain:
|
|
24
|
+
export declare const variable: <K extends string>(domain: LVarDomain, terms: LVar<K>["terms"]) => LVar<K>;
|
|
25
25
|
/**
|
|
26
26
|
* Takes an LVar and a domain value `x`. Returns the ID of the var's fuzzy set
|
|
27
27
|
* term which yields the max truth value for given `x`. If `threshold` is
|
|
@@ -29,7 +29,7 @@ export declare const variable: <K extends string>(domain: import("@thi.ng/api").
|
|
|
29
29
|
* considered. The function returns undefined if classification failed.
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
|
-
* ```ts
|
|
32
|
+
* ```ts tangle:../export/classify.ts
|
|
33
33
|
* import { classify, variable, invSigmoid, sigmoid, trapezoid } from "@thi.ng/fuzzy";
|
|
34
34
|
*
|
|
35
35
|
* // temperature sets (in celsius)
|
|
@@ -40,7 +40,7 @@ export declare const variable: <K extends string>(domain: import("@thi.ng/api").
|
|
|
40
40
|
* hot: sigmoid(30, 2)
|
|
41
41
|
* });
|
|
42
42
|
*
|
|
43
|
-
* classify(temp, 28)
|
|
43
|
+
* console.log(classify(temp, 28));
|
|
44
44
|
* // "warm"
|
|
45
45
|
* ```
|
|
46
46
|
*
|
|
@@ -54,7 +54,7 @@ export declare const classify: <K extends string>({ terms }: LVar<K>, x: number,
|
|
|
54
54
|
* `x` and returns object of results.
|
|
55
55
|
*
|
|
56
56
|
* @example
|
|
57
|
-
* ```ts
|
|
57
|
+
* ```ts tangle:../export/evaluate.ts
|
|
58
58
|
* import { evaluate, variable, invSigmoid, sigmoid, trapezoid } from "@thi.ng/fuzzy";
|
|
59
59
|
*
|
|
60
60
|
* // temperature sets (in celsius)
|
|
@@ -65,7 +65,7 @@ export declare const classify: <K extends string>({ terms }: LVar<K>, x: number,
|
|
|
65
65
|
* hot: sigmoid(30, 2)
|
|
66
66
|
* });
|
|
67
67
|
*
|
|
68
|
-
* evaluate(temp, 28)
|
|
68
|
+
* console.log(evaluate(temp, 28));
|
|
69
69
|
* // { freezing: 0, cold: 0, warm: 0.4, hot: 0.01798620996209156 }
|
|
70
70
|
* ```
|
|
71
71
|
*
|