Skip to content

dzibma/FuzzyMath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FuzzyMath

A lightweight library for fuzzy arithmetic based on operations over the α-cuts of piecewise linear fuzzy numbers.

Installation

Install via NuGet

License

The MIT License (MIT)

Basic usage

Fuzzy Number

The easiest way to create a (piecewise linear) fuzzy number is to use a FuzzyNumberFactory service. The constructor takes two optional arguments. The first one is a number of α-cuts, which the fuzzy numbers are made of. The second one is an epsilon to deal with floating points rounding errors.

var factory = new FuzzyNumberFactory(6);

FuzzyNumber A = factory.createTriangular(2, 3, 5, 7);
FuzzyNumber B = factory.createTrapezoidal(5, 8, 9);
FuzzyNumber C = factory.createCrisp(7);

Each α-cut (Interval) of the fuzzy number is accessible from FuzzyNumber.AlphaCuts property (IList<Interval>) by its index

Interval a = A.AlphaCuts[0]; // kernel

or you can get an α-cut by its membership value [0-1]

Interval b = B.GetAlhpaCut(.75);

To get a degree of membership μ(x) of value x (double) use

double m1 = B.GetMembership(4); // returns 0
double m2 = B.GetMembership(7.1) // returns .7
double m3 = B.GetMembership(8) // returns 1

Basic arithmetic

Operators +-*/ are overloaded, so you can use the fuzzy numbers created above as if they were doubles

FuzzyNumber D = 2 * C - (2.5 + A / B);

Shapes of fuzzy numbers created above: Fuzzy numbers A, B, C

Operations

Every operation over fuzzy number(s) is perfomed as the same operation over the set of corresponding α-cuts (Intervals). That is exactly what the static method FuzzyNumber.Map() does.

For example operations

var E = -1 * D;
var F = D + E;

are actualy performed as

var E = FuzzyNumber.Map(D, d => -1 * d); // unary operation
var F = FuzzyNumber.Map(D, E, (d, e) => d + e); // binary operation

About

A lightweight library for fuzzy arithmetic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages