JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q38589F
  • License ISC

A library for operating on fuzzy sets.

Package Exports

  • vaguely
  • vaguely/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vaguely) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Vaguely

A Typescript package for creating and manipulating fuzzy sets.

Installation

npm install vaguely

Example Usage

For operating on fuzzy sets over non-numerical domain:

import { EnumeratedDomain, FuzzySet } from "vaguely";

// Create a domain with four values
const D = new EnumeratedDomain("Foo", ["a", "b", "c", "d"]);

// Create a fuzzy set and assign membership values
const F1 = new FuzzySet("F1", D);
F1.assign("a", 0.5);
F1.assign("b", 1.0);
F1.assign("c", 0.5);
F1.assign("d", 0.1);
console.log(F1.toString()); 

// Create a second fuzzy set over the same domain
const F2 = new FuzzySet("F2", D);
F2.assign("a", 0.33);
F2.assign("b", 0.44);
F2.assign("c", 0.55);
F2.assign("d", 0.66);
console.log(F2.toString());

// Compute union and print the result
const F3 = F1.union(F2);
console.log(F3.toString());

// Compute intersection and print the result
const F4 = F1.intersect(F2);
console.log(F4.toString());

// Output: 
// -------
// F1 {a/0.50, b/1.00, c/0.50, d/0.10}
// F2 {a/0.33, b/0.44, c/0.55, d/0.66}
// F1 ∨ F2 {a/0.50, b/1.00, c/0.55, d/0.66}
// F1 ∧ F2 {a/0.33, b/0.44, c/0.50, d/0.10}

When operating over a numerical domain:

import { NumericalDomain, FuzzySet, up } from "vaguely";

// Create a domain from 10 to 20 with increments of 0.5
const D = new NumericalDomain("Foo", 10, 20, 0.5);

// Create a fuzzy set ramp up function over the domain
const F1: FuzzySet<number> = up(D, 12, 18)
console.log(F1.toString(true)); // print only non-zero values

// Output:
// --------
// up(12,18) {12.5/0.08, 13/0.17, 13.5/0.25, 14/0.33, 20/1.00}

When operating over the unit interval (i.e., [0, 1]) use:

import { UnitInterval, FuzzySet, trap } from "vaguely";

// Unit interval, values from 0 to 1 with step size 0.01
const UI = new UnitInterval(0.01);

// Create a trapezoid function over the unit interval
const F1: FuzzySet<number> = trap(UI, 0.1, 0.2, 0.3, 0.4)

// Print at most 10 non-zero values from the set and
// format the domain values to have two decimal points
console.log(F1.toString(true, 10, x => x.toFixed(2)));

// Output:
// --------
// trap(0.1,0.2,0.3,0.4) {0.11/0.10, 0.12/0.20, 0.13/0.30, 
//  0.14/0.40, 0.15/0.50, 0.16/0.60, 0.17/0.70, 0.18/0.80,
//  0.19/0.90, ... , 0.39/0.10}