Classes

T1FS

class pyit2fls.T1FS(domain, mf=<function zero_mf>, params=[])

Type 1 Fuzzy Set (T1FS).

Parameters

Parameters of the constructor function:

domain : numpy (n,) shaped array

Indicates the universe of discourse dedicated to the T1FS.

mf : Membership function

params : List of parameters of the membership function

Functions

Functions defined in T1FS class:

copy : Returns a copy of the T1FS.

plot : Plots the T1FS.

defuzzify : Defuzzifies the set.

negation operator - : Returns the negated T1FS.

Examples

>>> mySet = T1FS(linspace(0., 1., 100), 
                 trapezoid_mf, [0, 0.4, 0.6, 1., 1.])
>>> mySet.plot()
pyit2fls.T1FS.__repr__(self, /)

Return repr(self).

pyit2fls.T1FS.copy(self)

Copies the T1FS.

Returns

output : T1FS

Returns a copy of the T1FS.

pyit2fls.T1FS.__call__(self, x)

Call self as a function.

pyit2fls.T1FS.__neg__(self)
pyit2fls.T1FS._CoG(self)
pyit2fls.T1FS.defuzzify(self, method='CoG')

Defuzzifies the type 1 fuzzy set.

Parameters

method : str

Must be one of the methods listed below:

  1. CoG: Center of gravity

Returns

output : float

Defuzzified crisp output.

pyit2fls.T1FS.plot(self, title=None, legends=None, filename=None, ext='pdf', grid=True, xlabel='Domain', ylabel='Membership degree', legendloc='best', bbox_to_anchor=None, alpha=0.5)

Plots the T1FS.

Parameters

title : str

If set, it indicates the title which will be represented in the plot. If not set, the plot will not have a title.

legend_text : str

If set, it indicates the legend text which will be represented in the plot. If not set, the plot will not contain a legend.

filename : str

If set, the plot will be saved as a filename.ext file.

ext : str

Extension of the output file with ‘pdf’ as the default value.

grid : bool

Determines whether the grid is displayed in the plot.

xlabel : str

Label of the x axis.

ylabel : str

Label of the y axis.

Examples

>>> mySet = T1FS(linspace(0., 1., 100), 
                 trapezoid_mf, [0, 0.4, 0.6, 1., 1.])
>>> mySet.plot(filename="mySet")

T1TSK

class pyit2fls.T1TSK(default=0.0)

Type 1 TSK Fuzzy Logic System.

Parameters

Parameters of the constructor function:

The constructor function of the T1TSK class has no parameters.

Members

inputs : list of str

List of the inputs names as str.

outputs : list of str

List of the outputs names as str.

rules : list of tuples (antecedent, consequent)

List of rules, which each rule is defined as a tuple (antecedent, consequent)

Functions

add_input_variable:

Adds an input variable to the inputs list of the T1 TSK FLS.

add_output_variable:

Adds an output variable to the outputs list of the T1 TSK FLS.

add_rule:

Adds a rule to the rules list of the T1 TSK FLS.

copy:

Returns a copy of the T1 TSK FLS.

evaluate:

Evaluates the T1 TSK FLS based on the crisp inputs given by the user.

pyit2fls.T1TSK.__repr__(self)

Return repr(self).

pyit2fls.T1TSK.copy(self)

Returns a copy of the IT2FLS.

pyit2fls.T1TSK.add_input_variable(self, name)

Adds new input variable name.

Parameters

name : str

Name of the new input variable as a str.

pyit2fls.T1TSK.add_output_variable(self, name)

Adds new output variable name.

Parameters

name : str

Name of the new output variable as a str.

pyit2fls.T1TSK.add_rule(self, antecedent, consequent)

Adds new rule to the rule base of the T1 TSK FLS.

Parameters

antecedent : list of tuples

Antecedent is a list of tuples in which each tuple indicates assignment of a variable to a T1FS. The first element of the tuple must be the input variable name as a string, and the second element of the tuple must be a T1FS.

consequent : list of tuples

Consequent is a list of tuples in which each tuple indicates assignment of a variable to an output state. The first element of the tuple must be the output variable name as a string, and the second element of the tuple must be a callable object.

pyit2fls.T1TSK.evaluate(self, inputs, params)

Evaluates the T1 TSK FLS based on the crisp inputs given by the user.

Parameters

inputs : dictionary

Inputs is a dictionary, where the keys are input variable names as strings and the corresponded values are the crisp values of the inputs to be evaluated.

params : tuple

This tuple contains the parameters of the functions assigned to the consequents of the system rules.

Returns

Output : dict

The output is a dictionary, where the keys are output variable names as strings and the corresponded values are the crisp outputs of the system.

T1Mamdani

class pyit2fls.T1Mamdani(engine='Product', defuzzification='CoG')

Type 1 Mamdani Fuzzy Logic System.

Parameters

Parameters of the constructor function:

engine=”Product”: str

Inference engine of the type 1 Mamdani fuzzy logic system. This parameter is a string and can be one of the following items: Product, Minimum, Lukasiewicz, Zadeh, and Dienes-Rescher.

defuzzification=”CoG”: str

Defuzzification method of the system. When Lukasiewicz, Zadeh, and Dienes-Rescher inference engines are selected, the defuzzification method is center of the gravity by default. But for Product and Minimum inference engines, defuzzification can be selected among the methods CoG and CoA.

Members

inputs : list of str

List of the inputs names as strings.

outputs : list of str

List of the outputs names as strings.

rules : list of tuples (antecedent, consequent)

List of rules, which each rule is defined as a tuple (antecedent, consequent). Both antecedent and consequent are lists of tuples. Each tuple of this list represents the assignment of a variable to a T1FS. The first element of the tuple must be the variable name (input or output) as a string, and the second element must be a T1FS.

engine : str

Indicates the engine selected by the user.

defuzzification : str

Indicates the defuzzification method selected by the user.

Functions

add_input_variable:

Adds an input variable to the inputs list of the T1FLS.

add_output_variable:

Adds an output variable to the outputs list of the T1FLS.

add_rule:

Adds a rule to the rules list of the T1FLS.

copy:

Returns a copy of the type 1 Mamdani fuzzy logic system.

evaluate:

Evaluates the T1 Mamdani FLS’s output for the specified crisp input. The only input of the evaluate function is a dictionary in which the keys are input variable names as strings and the values are the crisp value of inputs to be evaluated. The output of the evaluate function depends on the method selected while constructing the class. For more information, please refer to the examples.

pyit2fls.T1Mamdani.__repr__(self)

Return repr(self).

pyit2fls.T1Mamdani.copy(self)
pyit2fls.T1Mamdani.add_input_variable(self, name)

Adds a new input variable by name.

Parameters

name : str

Name of the new input variable as a string.

pyit2fls.T1Mamdani.add_output_variable(self, name)

Adds a new output variable by name.

Parameters

name : str

Name of the new output variable as a string.

pyit2fls.T1Mamdani.add_rule(self, antecedent, consequent)

Adds a new rule to the rule base of the T1 Mamdani FLS.

Parameters

antecedent : list of tuples

Antecedent is a list of tuples in which each tuple indicates assignment of a variable to a T1FS. The first element of the tuple must be the input variable name as a string, and the second element of the tuple must be a T1FS.

consequent : list of tuples

Consequent is a list of tuples in which each tuple indicates assignment of a variable to a T1FS. The first element of the tuple must be the output variable name as a string, and the second element of the tuple must be a T1FS.

pyit2fls.T1Mamdani._CoG(self, B)
pyit2fls.T1Mamdani._CoA(self, B)
pyit2fls.T1Mamdani._product_evaluate(self, inputs)
pyit2fls.T1Mamdani._minimum_evaluate(self, inputs)
pyit2fls.T1Mamdani._lukasiewicz_evaluate(self, inputs)
pyit2fls.T1Mamdani._zadeh_evaluate(self, inputs)
pyit2fls.T1Mamdani._dienes_rescher_evaluate(self, inputs)

IT2FS

class pyit2fls.IT2FS(domain, umf=<function zero_mf>, umf_params=[], lmf=<function zero_mf>, lmf_params=[], check_set=False)

Interval Type 2 Fuzzy Set (IT2FS).

Parameters

Parameters of the constructor function:

domain : numpy (n,) shaped array

Indicates the universe of discourse dedicated to the IT2FS.

umf : Upper membership function

umf_params : list

Parameters of the upper membership function

lmf : Lower membership function

lmf_params : list

Parameters of lower membership function

check_set : bool

If True, then a function named check_set in IT2FS will verify the condition LMF(x) < UMF(x) for any x in the domain. If the user is sure that they have selected the parameters of the membership functions correctly, then calling this time-consuming function is not needed. By default the parameter check_set is False.

Functions

Functions defined in IT2FS class:

copy:

Returns a copy of the IT2FS.

plot:

Plots the IT2FS.

negation operator -:

Returns the negated IT2FS.

Examples

>>> mySet = IT2FS(linspace(0., 1., 100), 
                  trapezoid_mf, [0, 0.4, 0.6, 1., 1.], 
                  tri_mf, [0.25, 0.5, 0.75, 0.6])
>>> mySet.plot(filename="mySet")
pyit2fls.IT2FS.__repr__(self)

Return repr(self).

property IT2FS.upper
property IT2FS.lower
pyit2fls.IT2FS.check_set(self)

Verifies the condition LMF(x) < UMF(x) for any x in the domain.

pyit2fls.IT2FS.copy(self)

Copies the IT2FS.

Returns

output : IT2FS

Returns a copy of the IT2FS.

pyit2fls.IT2FS.plot(self, title=None, legends=None, filename=None, ext='pdf', grid=True, xlabel='Domain', ylabel='Membership degree', legendloc='best', bbox_to_anchor=None, alpha=0.5)

Plots the IT2FS.

Parameters

title : str

If set, it indicates the title to be represented in the plot. If not set, the plot will not have a title.

legend_text : str

If set, it indicates the legend text to be represented in the plot. If not set, the plot will not contain a legend.

filename : str

If set, the plot will be saved as a filename.ext file.

ext : str

Extension of the output file, with ‘pdf’ as the default value.

grid : bool

Determines whether the grid is displayed in the plot.

xlabel : str

Label of the x-axis.

ylabel : str

Label of the y-axis.

Examples

>>> mySet = IT2FS(linspace(0., 1., 100), 
                  trapezoid_mf, [0, 0.4, 0.6, 1., 1.], 
                  tri_mf, [0.25, 0.5, 0.75, 0.6])
>>> mySet.plot(filename="mySet")
pyit2fls.IT2FS.__neg__(self)

Negates the IT2FS.

Returns

output : IT2FS

Returns a negated copy of the IT2FS.

IT2FLS

class pyit2fls.IT2FLS

Interval type 2 fuzzy logic system.

No construction parameter is needed.

Members

inputs : List of str

List of names of inputs as str

outputs : List of str

List of names of outputs as str

rules : List of tuples (antecedent, consequent)

List of rules which each rule is defined as a tuple (antecedent, consequent)

Both antecedent and consequent are lists of tuples. Each tuple of this list shows assignment of a variable to an IT2FS. First element of the tuple must be variable name (input or output) as a str and the second element must be an IT2FS.

Functions

add_input_variable:

Adds an input variable to the inputs list of the IT2FLS.

add_output_variable:

Adds an output variable to the outputs list of the IT2FLS.

add_rule:

Adds a rule to the rules list of the IT2FLS.

copy:

Returns a copy of the IT2FLS.

evaluate:

Evaluates the IT2FLS’s output for a specified crisp input.

Examples

Assume that we are going to simulate an IT2FLS with two inputs and two outputs. Each input is defined by three IT2FSs, Small, Medium, and Large. These IT2FSs are from Gaussian type with uncertain standard deviation value. The universe of discourse of the fuzzy system is defined as the interval [0, 1]. Also, the rule base of the system is defined as below:

  • IF x1 is Small and x2 is Small THEN y1 is Small and y2 is Large

  • IF x1 is Medium and x2 is Medium THEN y1 is Medium and y2 is Small

  • IF x1 is Large and x2 is Large THEN y1 is Large and y2 is Small

The codes to simulate the aforementioned system using the PyIT2FLS would be as below:

>>> domain = linspace(0., 1., 100)
>>> 
>>> Small = IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1, 1.])
>>> Medium = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.15, 0.1, 1.])
>>> Large = IT2FS_Gaussian_UncertStd(domain, [1., 0.15, 0.1, 1.])
>>> IT2FS_plot(Small, Medium, Large, legends=["Small", "Medium", "large"])
>>> 
>>> myIT2FLS = IT2FLS()
>>> myIT2FLS.add_input_variable("x1")
>>> myIT2FLS.add_input_variable("x2")
>>> myIT2FLS.add_output_variable("y1")
>>> myIT2FLS.add_output_variable("y2")
>>> 
>>> myIT2FLS.add_rule([("x1", Small), ("x2", Small)], [("y1", Small), ("y2", Large)])
>>> myIT2FLS.add_rule([("x1", Medium), ("x2", Medium)], [("y1", Medium), ("y2", Small)])
>>> myIT2FLS.add_rule([("x1", Large), ("x2", Large)], [("y1", Large), ("y2", Small)])
>>> 
>>> it2out, tr = myIT2FLS.evaluate({"x1":0.9, "x2":0.9}, min_t_norm, max_s_norm, domain)
>>> it2out["y1"].plot()
>>> TR_plot(domain, tr["y1"])
>>> print(crisp(tr["y1"]))
>>> 
>>> it2out["y2"].plot()
>>> TR_plot(domain, tr["y2"])
>>> print(crisp(tr["y2"]))
>>> 

Notes

While using the PyIT2FLS the user must take care of the items listed below:

  • The UMF defined for an IT2FS must be greater than or equal to the LMF at all points of the discrete universe of discourse.

  • The inputs and outputs defined must be compatible while adding the rules and evaluating the IT2FLS.

pyit2fls.IT2FLS.__repr__(self)

Return repr(self).

pyit2fls.IT2FLS.add_input_variable(self, name)

Adds new input variable name.

Parameters

name : str

Name of the new input variable as a str.

pyit2fls.IT2FLS.add_output_variable(self, name)

Adds new output variable name.

Parameters

name : str

Name of the new output variable as a str.

pyit2fls.IT2FLS.add_rule(self, antecedent, consequent)

Adds new rule to the rule base of the IT2FLS.

Parameters

antecedent : List of tuples

Antecedent is a list of tuples in which each tuple indicates assignment of a variable to an IT2FS. First element of the tuple must be input variable name as str, and the second element of the tuple must be an IT2FS.

consequent : List of tuples

Consequent is a list of tuples in which each tuple indicates assignment of a variable to an IT2FS. First element of the tuple must be output variable name as str, and the second element of the tuple must be an IT2FS.

pyit2fls.IT2FLS.copy(self)

Returns a copy of the IT2FLS.

pyit2fls.IT2FLS.evaluate_list(self, inputs, t_norm, s_norm, domain, method='Centroid', method_params=[], algorithm='EIASC', algorithm_params=[])

Evaluates the IT2FLS based on list of crisp inputs given by user.

Parameters

inputs : dictionary

Inputs is a dictionary in which the keys are input variable names as str and the values are the list of crisp values corresponded with the inputs to be evaluated.

t_norm : function

Indicates the t-norm operator to be used, and should be chosen between min_t_norm, product_t_norm, or other user defined t-norms.

s_norm : function

Indicates the s-norm operator to be used, and should be chosen between max_s_norm or other user defined s-norms.

domain : numpy (n,) shaped array

Indicates the universe of discourse dedicated to the IT2FS.

method=”Centroid” : str

Indicates the type reduction method name and should be one of the methods listed below:

Centroid, CoSet, CoSum, Height, and ModiHe.

method_params=[] : List

Parameters of the type reduction method, if needed.

algorithm=”EIASC” : str

Indicates the type reduction algorithm name and should be one of the algorithms listed below:

KM, EKM, WEKM, TWEKM, EIASC, WM, BMM, LBMM, and NT.

algorithm_params=[] : List

Parameters of the type reduction algorithm, if needed.

Returns

output : tuple or list

It depends on which method and algorithm for type reduction is chosen. If Centroid type reduction method is chosen the output is a tuple with two elements. First element is the overall IT2FS outputs of the system as a list of dictionaries with output names as keys and sets as values. The second output is outputs of the selected type reduction algorithm as a list of dictionaries with output names as keys and type reduction algorithm function output as value. For other type reduction methods the only output is a list of dictionaries of the type reduction algorithm function outputs for each output variable name as a key.

Notes

While using the evaluate function some cares must be taken by the user himself which are listed as below:

  • The inputs must lie within the defined universe of discourse.

  • The type reduction method and the type reduction algorithm must be selected from the lists provided in docstrings.

pyit2fls.IT2FLS.evaluate(self, inputs, t_norm, s_norm, domain, method='Centroid', method_params=[], algorithm='EIASC', algorithm_params=[])

Evaluates the IT2FLS based on crisp inputs given by user.

Parameters

inputs : dictionary

Inputs is a dictionary in which the keys are input variable names as str and the values are the crisp value of inputs to be evaluated.

t_norm : function

Indicates the t-norm operator to be used, and should be chosen between min_t_norm, product_t_norm, or other user defined t-norms.

s_norm : function

Indicates the s-norm operator to be used, and should be chosen between max_s_norm or other user defined s-norms.

domain : numpy (n,) shaped array

Indicates the universe of discourse dedicated to the IT2FS.

method=”Centroid” : str

Indicates the type reduction method name and should be one of the methods listed below:

Centroid, CoSet, CoSum, Height, and ModiHe.

method_params=[] : List

Parameters of the type reduction method, if needed.

algorithm=”EIASC” : str

Indicates the type reduction algorithm name and should be one of the algorithms listed below:

KM, EKM, WEKM, TWEKM, EIASC, WM, BMM, LBMM, and NT.

algorithm_params=[] : List

Parameters of the type reduction algorithm, if needed.

Returns

output : tuple or dict

It depends on which method and algorithm for type reduction is chosen. If Centroid type reduction method is chosen the output is a tuple with two elements. First element is the overall IT2FS outputs of the system as a dictionary with output names as keys and sets as values. The second output is outputs of the selected type reduction algorithm as a dictionary with output names as keys and type reduction algorithm function output as value. For other type reduction methods the only output is the dictionary of the type reduction algorithm function outputs for each output variable name as a key.

Notes

While using the evaluate function some cares must be taken by the user himself which are listed as below:

  • The inputs must lie within the defined universe of discourse.

  • The type reduction method and the type reduction algorithm must be selected from the lists provided in docstrings.

IT2TSK

class pyit2fls.IT2TSK(t_norm, s_norm)

Interval type 2 TSK fuzzy logic system.

Parameters

Parameters of the constructor function:

t_norm : function

T-norm operator which would be used by FLS.

s_norm : function

S-norm operator which would be used by FLS.

Members

inputs : List of str

List of the inputs name as str.

outputs : List of str

List of the outputs name as str.

rules : List of tuples (antecedent, consequent)

List of rules which each rule is defined as a tuple (antecedent, consequent)

Both antecedent and consequent are lists of tuples. Each tuple of the antecedent list shows assignment of a variable to an IT2FS. First element of the tuple must be the input variable name as a str, and the second element must be an IT2FS.

Each tuple of the consequent indicates assignment of a variable to an output state. First element of the tuple must be output variable name as str, and the second element of the tuple must be a dictionary. This dictionary shows the output polynomial in the case of the rule. For example let an output polynomial be as 2 x1 + 4 x2 + 5. Then the dictionary for this case would be {“const”:5., “x1”:2., “x2”:4.}. Note that this is written for an IT2 TSK FLS with two inputs, named x1 and x2.

Functions

add_input_variable:

Adds an input variable to the inputs list of the IT2 TSK FLS.

add_output_variable:

Adds an output variable to the outputs list of the IT2 TSK FLS.

add_rule:

Adds a rule to the rules list of the IT2 TSK FLS.

copy:

Returns a copy of the interval type 2 tsk fuzzy logic system.

evaluate:

Evaluates the IT2 TSK FLS based on the crisp inputs given by the user.

Notes

While using the IT2TSK class the user must take care of the items listed below:

  • The UMF defined for an IT2FS must be greater than or equal to the LMF at all points of the discrete universe of discourse.

  • The inputs and outputs defined must be compatible while adding the rules and evaluating the IT2FLS.

pyit2fls.IT2TSK.__repr__(self)

Return repr(self).

pyit2fls.IT2TSK.add_input_variable(self, name)

Adds new input variable name.

Parameters

name : str

Name of the new input variable as a str.

pyit2fls.IT2TSK.add_output_variable(self, name)

Adds new output variable name.

Parameters

name : str

Name of the new output variable as a str.

pyit2fls.IT2TSK.add_rule(self, antecedent, consequent)

Adds new rule to the rule base of the IT2FLS.

Parameters

antecedent : List of tuples

Antecedent is a list of tuples in which each tuple indicates assignment of a variable to an IT2FS. First element of the tuple must be the input variable name as str, and the second element of the tuple must be an IT2FS.

consequent : List of tuples

Consequent is a list of tuples in which each tuple indicates assignment of a variable to an output state. First element of the tuple must be output variable name as str, and the second element of the tuple must be a dictionary. This dictionary shows the output polynomial in the case of the rule. For example let an output polynomial be as 2 x1 + 4 x2 + 5. Then the dictionary for this case would be {“const”:5., “x1”:2., “x2”:4.}. Note that this is written for an IT2 TSK FLS with two inputs, named x1 and x2.

Example

Assume that we are going to simulate an IT2 TSK FLS with two inputs named x1 and x2. Our rule base is defined as below:

  • IF x1 is Small and x2 is Small THEN y1 = x1 + x2 + 1 and y2 = 2 x1 - x2 + 1

  • IF x1 is Small and x2 is Big THEN y1 = 1.5 x1 + 0.5 x2 + 0.5 and y2 = 1.5 x1 - 0.5 x2 + 0.5

  • IF x1 is Big and x2 is Small THEN y1 = 2. x1 + 0.1 x2 - 0.2 and y2 = 0.5 x1 + 0.1 x2

  • IF x1 is Big and x2 is Big THEN y1 = 4. x1 -0.5 x2 - 1 and y2 = -0.5 x1 + x2 - 0.5

Then these rules can be added to the system using the codes below:

>>> myIT2FLS.add_rule([("x1", Small), ("x2", Small)], 
                      [("y1", {"const":1., "x1":1., "x2":1.}), 
                       ("y2", {"const":1., "x1":2., "x2":-1.})])
>>> myIT2FLS.add_rule([("x1", Small), ("x2", Big)], 
                      [("y1", {"const":0.5, "x1":1.5, "x2":0.5}), 
                       ("y2", {"const":0.5, "x1":1.5, "x2":-0.5})])
>>> myIT2FLS.add_rule([("x1", Big), ("x2", Small)], 
                      [("y1", {"const":-0.2, "x1":2., "x2":0.1}), 
                       ("y2", {"const":0., "x1":0.5, "x2":0.1})])
>>> myIT2FLS.add_rule([("x1", Big), ("x2", Big)], 
                      [("y1", {"const":-1., "x1":4., "x2":-0.5}), 
                       ("y2", {"const":-0.5, "x1":-0.5, "x2":1.})])
pyit2fls.IT2TSK.copy(self)

Returns a copy of the IT2FLS.

pyit2fls.IT2TSK.evaluate(self, inputs)

Evaluates the IT2 TSK FLS based on the crisp inputs given by the user.

Parameters

inputs : dictionary

Inputs is a dictionary, which the keys are input variable names as str and the values are the crisp value of the inputs to be evaluated.

Returns

output : dictionary

The output is a dictionary, which the keys are output variable names as str and the values are the crisp output of the system.

IT2Mamdani

class pyit2fls.IT2Mamdani(t_norm, s_norm, method='Centroid', method_params=[], algorithm='EIASC', algorithm_params=[])

Interval Type 2 Mamdani Fuzzy Logic System.

Parameters

Parameters of the constructor function:

t_norm : function

T-norm operator which would be used by FLS.

s_norm : function

S-norm operator which would be used by FLS.

method=”Centroid” : str

Indicates the type reduction method name and should be one of the methods listed below: Centroid, CoSet, CoSum, Height, and ModiHe.

method_params=[] : List

Parameters of the type reduction method, if needed.

algorithm=”EIASC” : str

Indicates the type reduction algorithm name and should be one of the algorithms listed below: KM, EKM, WEKM, TWEKM, EIASC, WM, BMM, LBMM, and NT.

algorithm_params=[] : List

Parameters of the type reduction algorithm, if needed.

Members

inputs : List of str

List of the inputs name as str.

outputs : List of str

List of the outputs name as str.

rules : List of tuples (antecedent, consequent)

List of rules which each rule is defined as a tuple (antecedent, consequent)

Both antecedent and consequent are lists of tuples. Each tuple of these lists shows assignment of a variable to an IT2FS. First element of the tuple must be variable name (input or output) as a str, and the second element must be an IT2FS.

Functions

add_input_variable:

Adds an input variable to the inputs list of the IT2 Mamdani FLS.

add_output_variable:

Adds an output variable to the outputs list of the IT2 Mamdani FLS.

add_rule:

Adds a rule to the rules list of the IT2 Mamdani FLS.

copy:

Returns a copy of the interval type 2 mamdani fuzzy logic system.

evaluate:

Evaluates the IT2FLS’s output for a specified crisp input. This function is selected based on the constructor function parameter, method, among 5 private functions below: __Mamdani_Centroid, __Mamdani_CoSet, __Mamdani_CoSum, __Mamdani_Height, and __Mamdani_ModiHe. The only input of the evaluate function is a dictionary named inputs in which the keys are input variable names as str and the values are the crisp value of inputs to be evaluated. The output of the evaluate function depends on the method selected while constructing the class. For more information, please refer to the examples.

Notes

While using the IT2Mamdani class the user must take care of the items listed below:

  • The UMF defined for an IT2FS must be greater than or equal to the LMF at all points of the discrete universe of discourse.

  • The inputs and outputs defined must be compatible while adding the rules and evaluating the IT2FLS.

pyit2fls.IT2Mamdani.add_input_variable(self, name)

Adds new input variable name.

Parameters

name : str

Name of the new input variable as a str.

pyit2fls.IT2Mamdani.add_output_variable(self, name)

Adds new output variable name.

Parameters

name : str

Name of the new output variable as a str.

pyit2fls.IT2Mamdani.add_rule(self, antecedent, consequent)

Adds new rule to the rule base of the IT2FLS.

Parameters

antecedent : List of tuples

Antecedent is a list of tuples in which each tuple indicates assignment of a variable to an IT2FS. First element of the tuple must be input variable name as str, and the second element of the tuple must be an IT2FS.

consequent : List of tuples

Consequent is a list of tuples in which each tuple indicates assignment of a variable to an IT2FS. First element of the tuple must be output variable name as str, and the second element of the tuple must be an IT2FS.

pyit2fls.IT2Mamdani.copy(self)

Returns a copy of the IT2FLS.

pyit2fls.IT2Mamdani.__repr__(self)

Return repr(self).

pyit2fls.IT2Mamdani.__meet(self, domain, it2fs1, l, u, t_norm)
pyit2fls.IT2Mamdani.__join(self, domain, it2fs1, l, u, s_norm)
pyit2fls.IT2Mamdani.__Mamdani_Centroid(self, inputs)
pyit2fls.IT2Mamdani.__Mamdani_CoSet(self, inputs)
pyit2fls.IT2Mamdani.__Mamdani_CoSum(self, inputs)
pyit2fls.IT2Mamdani.__Mamdani_Height(self, inputs)
pyit2fls.IT2Mamdani.__Mamdani_ModiHe(self, inputs)

T1Fuzzy_ML

class pyit2fls.T1Fuzzy_ML(N, M, Bounds=None, algorithm='DE', algorithm_params=[])

A general type fuzzy model for learning from data. T1Mamdani_ML and T1TSK_ML classes are build up based on this class and they only help to provide a linguistic interpretation of the results by the T1Fuzzy_ML class.

Parameters

Parameters of the constructor function:

N : int

The inputs number of the model.

M : int

The rules number of the model.

Bounds : tuple of float

The upper and lower bounds of the parameters of the model.

algorithm : str

Indicates the algorithm to be used for determining the model parameters. It should be one of the strings “DE”, “Nelder-Mead”, “Powell”, “CG”, “PSO”, “GA”, “GWO”, “WOA”, “FFA”, “CSO”, “ICA”. The first four algorithms, which are based on scipy, are not computationally efficient. So, we have provided embedded GA and PSO algorithms for calculating model parameters by optimizing an error function. The users can write their own heuristic optimization solvers as a subclass of Optimizer class.

algorithm_params : list of numbers

The parameters of the selected algorithm. For more details refer to each algorithm’s documentations.

Functions

Functions defined in T1Fuzzy_ML class:

error : The error function utilized for parameter optimization of the model.

fit : Fits the model based on the given input output data.

score : Evaluates the model for desired input data.

pyit2fls.T1Fuzzy_ML.error(self, P, X, y)

The error function for optimizing the model parameters.

Parameters

P : list of float or numpy (n,) shaped array

P provides the list of parameters which the model error would be evaluated based on it.

X : list of 1D numpy array or 2D numpy array

X is the set of data which the model error would be evaluated for them.

y : list of float or numpy (n,) shaped array

y is the set of desired outputs which the model error would be evaluated based on them.

pyit2fls.T1Fuzzy_ML.fit(self, X, y)

Function for finding the best set of parameters fitting the pair of input and output data.

Parameters

X :

X is the set of data which the model error would be evaluated for them.

y :

y is the set of desired outputs which the model error would be evaluated based on them.

pyit2fls.T1Fuzzy_ML.score(self, X)

Function for evaluating the model output for desired set of inputs.

Parameters

X :

X is the set of data which the model would be evaluated for them.

T1Mamdani_ML

class pyit2fls.T1Mamdani_ML(N, M, Bounds=None, algorithm='DE', algorithm_params=[])

Type-1 Mamdani Machine Learning (T1Mamdani_ML) for learning from data using Type-1 Mamdani fuzzy systems.

This class extends the T1Fuzzy_ML class to provide a linguistic interpretation of the results by generating a Type-1 Mamdani fuzzy system based on the learned parameters.

Parameters

Parameters of the constructor function:

N : int

The number of inputs to the fuzzy system.

M : int

The number of rules in the fuzzy system.

Bounds : tuple of float

The lower and upper bounds for the parameters of the model.

algorithm : str

The optimization algorithm to be used for parameter learning. Supported algorithms include “DE”, “Nelder-Mead”, “Powell”, “CG”, “PSO”, and “GA”, “GWO”, “WOA”, “FFA”, “CSO”, “ICA”.

algorithm_params : list of numbers

Parameters for the selected optimization algorithm. The required parameters depend on the chosen algorithm. Please refer to the documentations of the algorithms for more details.

Functions

Functions defined in T1Mamdani_ML class:

get_T1Mamdani:

Generates a Type-1 Mamdani fuzzy system based on the learned parameters.

pyit2fls.T1Mamdani_ML.get_T1Mamdani(self, std=1.0)

Generates a Type-1 Mamdani fuzzy system based on the learned parameters.

Parameters

std : float

The standard deviation for the Gaussian membership functions used in the fuzzy system.

Returns

T1Mamdani:

A Type-1 Mamdani fuzzy system generated based on the learned parameters.

T1TSK_ML

class pyit2fls.T1TSK_ML(N, M, Bounds=None, algorithm='DE', algorithm_params=[])

Type-1 TSK Machine Learning (T1TSK_ML) for learning from data using Type-1 Takagi-Sugeno fuzzy systems.

This class extends the T1Fuzzy_ML class to provide a linguistic interpretation of the results by generating a Type-1 TSK fuzzy system based on the learned parameters.

Parameters

Parameters of the constructor function:

N : int

The number of inputs to the fuzzy system.

M : int

The number of rules in the fuzzy system.

Bounds : tuple of float

The lower and upper bounds for the parameters of the model.

algorithm : str

The optimization algorithm to be used for parameter learning. Supported algorithms include “DE”, “Nelder-Mead”, “Powell”, “CG”, “PSO”, “GA”, “GWO”, “WOA”, “FFA”, “CSO”, and “ICA”.

algorithm_params : list of numbers

Parameters for the selected optimization algorithm. The required parameters depend on the chosen algorithm. Please refer to the documentations of the algorithms for more details.

Functions

Functions defined in T1TSK_ML class:

get_T1TSK:

Generates a Type-1 TSK fuzzy system based on the learned parameters.

pyit2fls.T1TSK_ML.get_T1TSK(self, std=1.0)

Generates a Type-1 TSK fuzzy system based on the learned parameters.

Parameters

std : float

The standard deviation for the Gaussian membership functions used in the fuzzy system.

Returns

T1TSK:

A Type-1 TSK fuzzy system generated based on the learned parameters.

Linear_System

class pyit2fls.Linear_System(A, B, C, D)

A class for representing linear systems.

pyit2fls.Linear_System.__call__(self, t, X, U)

Call self as a function.

Parameters

Parameters of the function:

t : float

The time variable.

X : numpy (n,) shaped array

The system states at time t.

U : function of t and X

A function for calculating the system input(s) at time t and state X.

pyit2fls.Linear_System.Y(self, t, X, U)

A function for calculating the system output based on the current time, systemstates, and system input(s).

Parameters

Parameters of the function:

t : float

The time variable.

X : numpy (n,) shaped array

The system states at time t.

U : function of t and X

A function for calculating the system input(s) at time t and state X.

pyit2fls.Linear_System.__repr__(self)

Return repr(self).

pyit2fls.Linear_System.__str__(self)

Return str(self).

pyit2fls.Linear_System.__add__(self, other)

Simple element-wise addition for all system matrices to form a new linear system.

Parameters

other : Linear_System

The other linear system to be added.

pyit2fls.Linear_System.__sub__(self, other)

Simple element-wise subtraction for all system matrices to form a new linear system.

Parameters

other : Linear_System

The other linear system to be subtracted.

pyit2fls.Linear_System.__neg__(self)

Simple element-wise negation for all system matrices to form a new linear system.

pyit2fls.Linear_System.__mul__(self, other)

Simple element-wise multiplication for all system matrices to form a new linear system.

Parameters

other : int or float

The number to be multiplicated.

pyit2fls.Linear_System.__truediv__(self, other)

Simple element-wise true division for all system matrices to form a new linear system.

Parameters

other : int or float

The number to be used in division.

pyit2fls.Linear_System.__isub__(self, other)

Simple element-wise subtraction for all system matrices to form a new linear system.

Parameters

other : Linear_System

The other linear system to be subtracted.

pyit2fls.Linear_System.__iadd__(self, other)

Simple element-wise addition for all system matrices to form a new linear system.

Parameters

other : Linear_System

The other linear system to be added.

pyit2fls.Linear_System.__imul__(self, other)

Simple element-wise multiplication for all system matrices to form a new linear system.

Parameters

other : int or float

The number to be multiplicated.

pyit2fls.Linear_System.__idiv__(self, other)

Simple element-wise division for all system matrices to form a new linear system.

Parameters

other : int or float

The number to be used in division.

T1_TS_Model

class pyit2fls.T1_TS_Model(mfList, mfParamsList, systemList, R, N, M, P)

Type-1 Takagi-Sugeno (T1_TS) fuzzy model.

This class provides a faster but less general implementation of a Type-1 Takagi-Sugeno fuzzy model. It requires low-level configurations for membership functions, parameters, and system rules.

Parameters

Parameters of the constructor function:

mfList : list of list of membership functions

Membership functions describing each input of the TS system in each rule of the rule base.

mfParamsList : list of list of list of floats

List of parameters corresponded with mmbership functions describing each input of the TS system in each rule of the rule base.

systemList : list of Linear_System

List of antecedent of each rule as a linear system.

R : int

Number of the rules in the rule base of the system.

N : int

Number of the state variables of the systtem.

M : int

Number of the inputs of the system.

P : int

Number of the outputs of the system.

Functions

d0 :

Computes the aggregated linear system based on the states.

__call__ :

Evaluates the TS fuzzy system for a given time, state, and input.

Y :

Computes the output of the fuzzy system for a given time, state, and input.

pyit2fls.T1_TS_Model.d0(self, d0x)

Computes the aggregated linear system based on the states.

Parameters

d0x : numpy array

The state variables for which the aggregated linear system will be computed.

Returns

Linear_System:

The aggregated linear system based on the states.

pyit2fls.T1_TS_Model.__call__(self, t, X, U)

Evaluates the fuzzy system for a given time, state, and input.

Parameters

t : float

The time variable.

X : numpy array

The state variables of the system.

U : function

A function representing the system inputs as a function of time and state.

Returns

numpy array:

The evaluated state derivatives of the fuzzy system.

pyit2fls.T1_TS_Model.Y(self, t, X, U)

Computes the output of the TS system for a given time, state, and input.

Parameters

t : float

The time variable.

X : numpy array

The state variables of the system.

U : function

A function representing the system inputs as a function of time and state.

Returns

numpy array:

The output of the TS system.

IT2TSK_ML_Model

class pyit2fls.IT2TSK_ML_Model(P, N, M, it2fs, c=1.0)

Interval Type-2 TSK Model for representing and evaluating interval type-2 fuzzy TSK systems in machine learning applications.

This class implements an interval type-2 fuzzy TSK model using Gaussian membership functions with uncertainty in either the mean or the standard deviation.

Parameters

Parameters of the constructor function:

P : list of floats or numpy array

The parameters of the model, including antecedent and consequent parameters.

N : int

The number of inputs to the fuzzy system.

M : int

The number of rules in the fuzzy system.

it2fs : class

The interval type-2 fuzzy set class to be used for the antecedents and consequents. It should be either IT2FS_Gaussian_UncertMean or IT2FS_Gaussian_UncertStd.

c : float

Output scaling factor for the model.

Functions

Functions defined in IT2TSK_ML_Model class:

__call__:

Evaluates the fuzzy system for a given input.

pyit2fls.IT2TSK_ML_Model.__call__(self, X)

Evaluates the fuzzy system for a given input.

Parameters

X : numpy array

The input data for which the fuzzy system will be evaluated.

Returns

float:

The output of the fuzzy system for the given input.

IT2TSK_ML

class pyit2fls.IT2TSK_ML(N, M, it2fs, Bounds=None, algorithm='DE', algorithm_params=[], c=1.0)

Interval Type-2 TSK Machine Learning (IT2TSK_ML) for learning from data using interval type-2 fuzzy TSK systems.

Parameters

Parameters of the constructor function:

N : int

Number of inputs to the model.

M : int

Number of rules in the fuzzy system.

it2fs : class

The interval type-2 fuzzy set class to be used for the antecedents and consequents. It should be either IT2FS_Gaussian_UncertMean or IT2FS_Gaussian_UncertStd.

Bounds : tuple of float

The lower and upper bounds for the parameters of the model.

algorithm : str

The optimization algorithm to be used for parameter learning. Supported algorithms include “DE”, “Nelder-Mead”, “Powell”, “CG”, “PSO”, “GA”, “GWO”, “WOA”, “FFA”, “CSO”, and “ICA”. Custom algorithms inheriting from the Optimizer class can also be used.

algorithm_params : list of numbers

Parameters for the selected optimization algorithm. The required parameters depend on the chosen algorithm.

c : float

Output scaling factor for the model.

Functions

Functions defined in IT2TSK_ML class:

error:

The error function used for optimizing the model parameters.

fit:

Fits the model to the given input-output data.

score:

Evaluates the model for a given set of inputs.

pyit2fls.IT2TSK_ML.error(self, P, X, y)

The error function for optimizing the model parameters.

Parameters

P : list of float or numpy (n,) shaped array

The list of parameters for which the model error will be evaluated.

X : list of 1D numpy arrays or 2D numpy array

The input data for which the model error will be evaluated.

y : list of float or numpy (n,) shaped array

The desired outputs for which the model error will be evaluated.

pyit2fls.IT2TSK_ML.fit(self, X, y)

Fits the model to the given input-output data.

Parameters

X : list of 1D numpy arrays or 2D numpy array

The input data for training the model.

y : list of float or numpy (n,) shaped array

The desired outputs for training the model.

pyit2fls.IT2TSK_ML.score(self, X)

Evaluates the model for a given set of inputs.

Parameters

X : list of 1D numpy arrays or 2D numpy array

The input data for which the model will be evaluated.

IT2Mamdani_ML_Model

class pyit2fls.IT2Mamdani_ML_Model(P, N, M, it2fs, c=1.0)

Interval Type-2 Mamdani Model for representing and evaluating interval type-2 Mamdani fuzzy systems in machine learning applications.

This class implements an interval type-2 Mamdani fuzzy model using Gaussian membership functions with uncertainty in either the mean or the standard deviation for both antecedents and consequents.

Parameters

Parameters of the constructor function:

P : list of floats or numpy array

The parameters of the model, including antecedent and consequent parameters.

N : int

The number of inputs to the fuzzy system.

M : int

The number of rules in the fuzzy system.

it2fs : class

The interval type-2 fuzzy set class to be used for the antecedents and consequents. It should be either IT2FS_Gaussian_UncertMean or IT2FS_Gaussian_UncertStd.

c : float

Output scaling factor for the model.

Functions

Functions defined in IT2Mamdani_ML_Model class:

__call__:

Evaluates the fuzzy system for a given input and returns the defuzzified output.

pyit2fls.IT2Mamdani_ML_Model.__call__(self, X)

Evaluates the fuzzy system for a given input and returns the defuzzified output.

Parameters

X : numpy array

The input data for which the fuzzy system will be evaluated.

Returns

float:

The defuzzified output of the fuzzy system for the given input.

IT2Mamdani_ML

class pyit2fls.IT2Mamdani_ML(N, M, it2fs, Bounds=None, algorithm='DE', algorithm_params=[], c=1.0)

Interval Type-2 Mamdani Machine Learning (IT2Mamdani_ML) for learning from data using interval type-2 Mamdani fuzzy systems.

This class provides a framework for training interval type-2 Mamdani fuzzy systems using various optimization algorithms. It supports Gaussian membership functions with uncertainty in either the mean or the standard deviation for both antecedents and consequents.

Parameters

Parameters of the constructor function:

N : int

The number of inputs to the fuzzy system.

M : int

The number of rules in the fuzzy system.

it2fs : class

The interval type-2 fuzzy set class to be used for the antecedents and consequents. It should be either IT2FS_Gaussian_UncertMean or IT2FS_Gaussian_UncertStd.

Bounds : tuple of float

The lower and upper bounds for the parameters of the model.

algorithm : str

The optimization algorithm to be used for parameter learning. Supported algorithms include “DE”, “Nelder-Mead”, “Powell”, “CG”, “PSO”, “GA”, “GWO”, “WOA”, “FFA”, “CSO”, and “ICA”. Custom algorithms inheriting from the Optimizer class can also be used.

algorithm_params : list of numbers

Parameters for the selected optimization algorithm. The required parameters depend on the chosen algorithm.

c : float

Output scaling factor for the model.

Functions

Functions defined in IT2Mamdani_ML class:

error:

The error function used for optimizing the model parameters.

fit:

Fits the model to the given input-output data.

score:

Evaluates the model for a given set of inputs.

pyit2fls.IT2Mamdani_ML.error(self, P, X, y)

The error function used for optimizing the model parameters.

Parameters

P : list of float or numpy (n,) shaped array

The list of parameters for which the model error will be evaluated.

X : list of 1D or 2D numpy array

The input data for which the model error will be evaluated.

y : list of float or numpy (n,) shaped array

The desired outputs for which the model error will be evaluated.

Returns

float:

The computed error value for the given parameters and data.

pyit2fls.IT2Mamdani_ML.fit(self, X, y)

Fits the model to the given input-output data using the selected optimization algorithm.

Parameters

X : list of 1D or 2D numpy array

The input data for training the model.

y : list of float or numpy (n,) shaped array

The desired outputs for training the model.

Returns

float or tuple:

The final error value after optimization, and optionally the convergence history.

pyit2fls.IT2Mamdani_ML.score(self, X)

Evaluates the model for a given set of inputs.

Parameters

X : list of 1D or 2D numpy array

The input data for which the model will be evaluated.

Returns

float or numpy array:

The model output(s) for the given input(s).

IT2_TS_Model

class pyit2fls.IT2_TS_Model(lmfList, lmfParamsList, umfList, umfParamsList, systemList, R, N, M, P)

Interval Type-2 Takagi-Sugeno (IT2_TS) fuzzy model.

This class implements an interval type-2 Takagi-Sugeno fuzzy model, which uses lower and upper membership functions (LMFs and UMFs) to handle uncertainty in the system.

Parameters

Parameters of the constructor function:

lmfList : list of list of functions

A list of membership functions (MFs) for the lower membership functions (LMFs) of each input in each rule of the fuzzy system.

lmfParamsList : list of list of lists of floats

A list of parameters corresponding to the lower membership functions (LMFs) for each input in each rule of the fuzzy system.

umfList : list of list of functions

A list of membership functions (MFs) for the upper membership functions (UMFs) of each input in each rule of the fuzzy system.

umfParamsList : list of list of lists of floats

A list of parameters corresponding to the upper membership functions (UMFs) for each input in each rule of the fuzzy system.

systemList : list of Linear_System objects

A list of linear systems representing the consequent of each rule in the fuzzy system.

R : int

The number of rules in the fuzzy system.

N : int

The number of state variables in the system.

M : int

The number of inputs to the systems.

P : int

The number of outputs of the systems.

Functions

Functions defined in IT2_TS_Model class:

d0:

Computes the aggregated linear system based on the input membership function values.

__call__:

Evaluates the fuzzy system for a given time, state, and input.

Y:

Computes the output of the fuzzy system for a given time, state, and input.

pyit2fls.IT2_TS_Model.d0(self, d0x)

Computes the aggregated linear system based on the states.

Parameters

d0x : numpy array

The state variables for which the aggregated linear system will be computed.

Returns

Linear_System:

The aggregated linear system based on the states.

pyit2fls.IT2_TS_Model.__call__(self, t, X, U)

Evaluates the fuzzy system for a given time, state, and input.

Parameters

t : float

The time variable.

X : numpy array

The state variables of the system.

U : function

A function representing the system inputs as a function of time and state.

Returns

numpy array:

The evaluated state derivatives of the fuzzy system.

pyit2fls.IT2_TS_Model.Y(self, t, X, U)

Computes the output of the fuzzy system for a given time, state, and input.

Parameters

t : float

The time variable.

X : numpy array

The state variables of the system.

U : function

A function representing the system inputs as a function of time and state.

Returns

numpy array:

The output of the fuzzy system.

GA

class pyit2fls.GA(N, M, func, bounds, args=())

Genetic Algorithm (GA) for determining optimal parameters of the fuzzy models.

Parameters

Parameters of the constructor function:

N : int

Number of individuals in the population.

M : int

Number of parameters constructing each individual.

func : function

Objective function of the minimizing optimization problem.

bounds : iterable

Lower and upper bounds of the parameters of the optimization problem solutions.

args : tuple

The extra arguments that can be passed while calling the objective function, func.

Functions

Functions defined in GA class:

tournament_selection:

Returns a list of num indices of individuals selected using the tournament selection method among tp top percent of the individuals in the population.

mutate:

Applies the mutation operator on a specific individual.

crossover:

Produces an offspring using two individuals selected from the population.

iterate:

Advances the GA by one iteration.

pyit2fls.GA.tournament_selection(self, num, tp)

Returns a list of num indices of individuals selected using the tournament selection method among tp top percent of the individuals in the population.

Parameters

num : int

The needed number of indices.

tp : float

A specific percent of population that selection would be among them.

pyit2fls.GA.mutate(self, individual)

Applies the mutation operator on a specific individual.

Parameters

individual : object of type solution

The individual that the mutation would be applied on it.

pyit2fls.GA.crossover(self, parent1, parent2)

Produces an offspring using two individuals selected from the population.

Parameters

parent1 : object of type solution

The first parent for producing the offspring.

parent2 : object of type solution

The second parent for producing the offspring.

pyit2fls.GA.iterate(self, mutation_num, crossover_num, tp)

Advances the GA by one iteration.

Parameters

mutation_num : int

The number of mutation operations that would be applied in each iteration.

crossover_num : int

The number of crossover operations that would be applied in each iteration.

tp : float

The implemented genetic algorithm (GA) applies the mutation and crossover operators exclusively to the elite subset of the population, which represents the fitter solutions. The parameter tp defines the elite group as the fraction 0 < tp < 1 of the population comprising individuals with superior fitness.

PSO

class pyit2fls.PSO(N, M, func, bounds, args=())

Particle Swarm Optimization (PSO) for determining optimal parameters of fuzzy models.

Parameters

Parameters of the constructor function:

N : int

Number of particles in the swarm.

M : int

Number of parameters constructing each particle.

func : function

Objective function of the minimizing optimization problem.

bounds : iterable

Lower and upper bounds of the parameters of the optimization problem solutions.

args : tuple

The extra arguments that can be passed while calling the objective function, func.

Functions

Functions defined in PSO class:

iterate:

Advances the PSO by one iteration.

pyit2fls.PSO.iterate(self, omega=0.3, phi_p=0.3, phi_g=2.1)

Advances the PSO by one iteration.

Parameters

omega : float

Inertia weight controlling the influence of the previous velocity.

phi_p : float

Cognitive coefficient controlling the influence of the particle’s best-known position.

phi_g : float

Social coefficient controlling the influence of the global best-known position.

GWO

class pyit2fls.GWO(population, param_num, obj_func, bounds, args=())

Grey Wolf Optimizer (GWO) for determining optimal parameters of fuzzy models.

Parameters

Parameters of the constructor function:

population : int

Number of wolves in the population.

param_num : int

Number of parameters constructing each wolf.

obj_func : function

Objective function of the minimizing optimization problem.

bounds : iterable

Lower and upper bounds of the parameters of the optimization problem solutions.

args : tuple

The extra arguments that can be passed while calling the objective function, obj_func.

Functions

Functions defined in GWO class:

iterate:

Advances the GWO by one iteration.

pyit2fls.GWO.iterate(self, t, max_iter)

Advances the GWO by one iteration.

Parameters

t : int

Current iteration number.

max_iter : int

Maximum number of iterations.

pyit2fls.GWO._update_leaders(self)

Updates the alpha, beta, and delta wolves based on their fitness values.

WOA

class pyit2fls.WOA(population, param_num, obj_func, bounds, args=())

Whale Optimization Algorithm (WOA) for determining optimal parameters of fuzzy models.

Parameters

Parameters of the constructor function:

population : int

Number of whales in the population.

param_num : int

Number of parameters constructing each whale.

obj_func : function

Objective function of the minimizing optimization problem.

bounds : iterable

Lower and upper bounds of the parameters of the optimization problem solutions.

args : tuple

The extra arguments that can be passed while calling the objective function, obj_func.

Functions

Functions defined in WOA class:

iterate:

Advances the WOA by one iteration.

pyit2fls.WOA.iterate(self, t, max_iter)

Advances the WOA by one iteration.

Parameters

t : int

Current iteration number.

max_iter : int

Maximum number of iterations.

FFA

class pyit2fls.FFA(population, param_num, obj_func, bounds, args=())

Firefly Algorithm (FFA) for determining optimal parameters of fuzzy models.

Parameters

Parameters of the constructor function:

population : int

Number of fireflies in the population.

param_num : int

Number of parameters constructing each firefly.

obj_func : function

Objective function of the minimizing optimization problem.

bounds : iterable

Lower and upper bounds of the parameters of the optimization problem solutions.

args : tuple

The extra arguments that can be passed while calling the objective function, obj_func.

Functions

Functions defined in FFA class:

iterate:

Advances the FFA by one iteration.

pyit2fls.FFA.iterate(self, alpha, beta0, gamma)

Advances the FFA by one iteration.

Parameters

alpha : float

Randomization parameter controlling the randomness of the movement.

beta0 : float

Attractiveness at distance zero.

gamma : float

Light absorption coefficient controlling the decrease in attractiveness with distance.

CuckooSearch

class pyit2fls.CuckooSearch(population_size, solution_size, objective_function, bounds, args=None)

Cuckoo Search (CS) for determining optimal parameters of fuzzy models.

Parameters

Parameters of the constructor function:

population_size : int

Number of nests (solutions) in the population.

solution_size : int

Number of parameters constructing each solution.

objective_function : function

Objective function of the minimizing optimization problem.

bounds : iterable

Lower and upper bounds of the parameters of the optimization problem solutions.

args : tuple

The extra arguments that can be passed while calling the objective function, objective_function.

Functions

Functions defined in CuckooSearch class:

iterate:

Advances the Cuckoo Search by one iteration.

pyit2fls.CuckooSearch.iterate(self, pa=0.25, step_size_factor=0.01)

Advances the Cuckoo Search by one iteration.

Parameters

pa : float

Probability of abandoning a nest.

step_size_factor : float

Step size factor for Levy flight.

pyit2fls.CuckooSearch.get_cuckoo(self, nest, step_size_factor)

Generates a new solution using Levy flight.

Parameters

nest : numpy array

Current solution (nest).

step_size_factor : float

Step size factor for Levy flight.

pyit2fls.CuckooSearch.get_best_solution(self)

Finds the best solution (nest) in the current population.

ICA

class pyit2fls.ICA(population_size, solution_size, objective_function, bounds, args=None)

Imperialist Competitive Algorithm (ICA) for determining optimal parameters of fuzzy models.

Parameters

Parameters of the constructor function:

population_size : int

Number of countries (solutions) in the population.

solution_size : int

Number of parameters constructing each country.

objective_function : function

Objective function of the minimizing optimization problem.

bounds : iterable

Lower and upper bounds of the parameters of the optimization problem solutions.

args : tuple

The extra arguments that can be passed while calling the objective function, objective_function.

Functions

Functions defined in ICA class:

iterate:

Advances the ICA by one iteration.

get_best_solution:

Finds the best solution (country) in the current population.

pyit2fls.ICA.iterate(self, assimilation_coefficient=2, revolution_rate=0.1)

Advances the ICA by one iteration.

Parameters

assimilation_coefficient : float

Coefficient controlling the movement of colonies towards their imperialist.

revolution_rate : float

Probability of a colony randomly changing its position.

pyit2fls.ICA.get_best_solution(self)

Finds the best solution (country) in the current population.