Skip to content

Trapezoid

Trapezoid

Bases: Term

Basic Term that represents the trapezoid membership function.

Equation

\(\mu(x)= \begin{cases} 0 & \mbox{if } x < a \vee x > d\cr h \dfrac{x - a}{b - a} & \mbox{if } a \le x < b\cr h & \mbox{if } (b \le x \le c) \vee (a=-\infty \wedge x < b) \vee (d=\infty \wedge x > c) \cr h \dfrac{d - x}{d - c} & \mbox{if } c < x \le d\cr \text{NaN} & \mbox{otherwise} \end{cases}\)

where

  • \(h\): height of the Term
  • \(a\): bottom left vertex of the Trapezoid
  • \(b\): top left vertex of the Trapezoid
  • \(c\): top right vertex of the Trapezoid
  • \(d\): bottom right vertex of the trapezoid

Attributes

bottom_left instance-attribute

bottom_left = bottom_left

bottom_right instance-attribute

bottom_right = bottom_right

top_left instance-attribute

top_left = top_left

top_right instance-attribute

top_right = top_right

Functions

__init__

__init__(
    name: str = "",
    bottom_left: float = nan,
    top_left: float = nan,
    top_right: float = nan,
    bottom_right: float = nan,
    height: float = 1.0,
) -> None

Constructor.

Parameters:

Name Type Description Default
name str

name of the Term

''
bottom_left float

first vertex of the Trapezoid

nan
top_left float

second vertex of the Trapezoid

nan
top_right float

third vertex of the Trapezoid

nan
bottom_right float

fourth vertex of the Trapezoid

nan
height float

height of the Term

1.0

configure

configure(parameters: str) -> None

Configure the term with the parameters.

Parameters:

Name Type Description Default
parameters str

bottom_left top_left top_right bottom_right [height].

required

membership

membership(x: Scalar) -> Scalar

Computes the membership function evaluated at \(x\).

Parameters:

Name Type Description Default
x Scalar

scalar

required

Returns:

Type Description
Scalar

\(\mu(x)= \begin{cases} 0 & \mbox{if } x < a \vee x > d\cr h \dfrac{x - a}{b - a} & \mbox{if } a \le x < b\cr h & \mbox{if } (b \le x \le c) \vee (a=-\infty \wedge x < b) \vee (d=\infty \wedge x > c) \cr h \dfrac{d - x}{d - c} & \mbox{if } c < x \le d\cr \text{NaN} & \mbox{otherwise} \end{cases}\)

parameters

parameters() -> str

Return the parameters of the term.

Returns:

Type Description
str

bottom_left top_left top_right bottom_right [height].