Click or drag to resize
Accord.NET (logo)

PiecewiseLinearFunction Class

Membership function composed by several connected linear functions.
Inheritance Hierarchy
SystemObject
  Accord.FuzzyPiecewiseLinearFunction
    Accord.FuzzyTrapezoidalFunction

Namespace:  Accord.Fuzzy
Assembly:  Accord.Fuzzy (in Accord.Fuzzy.dll) Version: 3.8.0
Syntax
public class PiecewiseLinearFunction : IMembershipFunction
Request Example View Source

The PiecewiseLinearFunction type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyLeftLimit
The leftmost x value of the membership function, given by the first (X,Y) coordinate.
Public propertyRightLimit
The rightmost x value of the membership function, given by the last (X,Y) coordinate.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetMembership
Calculate membership of a given value to the piecewise function.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Fields
  NameDescription
Protected fieldpoints
Vector of (X,Y) coordinates for end/start of each line.
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The piecewise linear is a generic function used by many specific fuzzy membership functions, like the trappezoidal function. This class must be instantiated with a sequence of points representing the edges of each one of the lines composing the piecewise function.

Note Note
The x-axis points must be ordered (crescent), so the GetMembership(Single) function will use each X value as an ending point for one line and starting point of the next.

While trapezoidal and half trapezoidal are classic functions used in fuzzy functions, this class supports any function or approximation that can be represented as a sequence of lines.

Sample usage:

// creating an array of points representing a typical trapezoidal function /-\
Point [] points = new Point[4];
// point where membership starts to rise
points[0] = new Point( 10, 0 );
// maximum membership (1) reached at the second point 
points[1] = new Point( 20, 1 );
// membership starts to fall at the third point 
points[2] = new Point( 30, 1 );
// membership gets to zero at the last point 
points[3] = new Point( 40, 0 );
// creating the instance
PiecewiseLinearFunction membershipFunction = new PiecewiseLinearFunction( points );
// getting membership for several points
for ( int i = 5; i < 45; i++ )
    Console.WriteLine( membershipFunction.GetMembership( i ) );
See Also