Section for working with fuzzy linear optimization methods

class fuzzyops.fuzzy_optimization.fuzzy_metaevristic_optimization.optimization.AntOptimization(data: ndarray, k: int, epsilon: float, q: float, n_iter: int, n_ant: int, ranges: list[FuzzyBounds], r: ndarray, n_terms: int, mf_type: str, base_rules_ind: ndarray)[source]

Bases: object

Ant colony optimization algorithm for fuzzy systems identification The algorithm is based on the article: И.А. Ходашинский, П.А. Дудин. Идентификация нечетких систем на основе непрерывного алгоритма муравьиных колоний. Автометрия. 2012. Т. 48, № 1.

Parameters:
  • data (np.ndarray) – Input data for creating a model (matrix of objects and features with a target variable)

  • k (int) – The size of the solution archive

  • epsilon (float) – A parameter that has the effect of evaporating pheromone in the discrete version of the algorithm

  • q (float) – A parameter for loss normalization

  • n_iter (int) – The number of iterations of the algorithm

  • n_ant (int) – The total number of ants (agents)

  • ranges (List[FuzzyBounds]) – Boundaries for fuzzy values

  • r (np.ndarray) – Input data for calculating losses (the value of consequents is a target variable)

  • n_terms (int) – The number of terms (usually equal to the number of observations)

  • mf_type (str) – The type of membership function for the created fuzzy numbers (Only triangular numbers, ‘triangular’)

  • base_rules_ind (np.ndarray) – An array of indices from 0 to n_terms

n

The number of input variables

Type:

int

p

The number of observations

Type:

int

N

The total number of parameters

Type:

int

R

Number of rules in the rule base

Type:

int

X

A data frame containing input variables (matrix objects features)

Type:

pd.DataFrame

t

Target values (target variable in the matrix of objects and features)

Type:

np.ndarray

r

Input data for calculating losses

Type:

np.ndarray

base_rules_ind

An array of indices from 0 to n_terms

Type:

np.ndarray

ranges

Boundaries for fuzzy values

Type:

List[FuzzyBounds]

k

Number of initial solutions

Type:

int

theta

The structure of the parameters

Type:

np.ndarray

storage

Storage for loss archive and parameters

Type:

List[Archive]

eps

A parameter that has the effect of evaporating pheromone in the discrete version of the algorithm

Type:

float

q

Parameter for loss normalization

Type:

float

n_iter

Number of iterations of the algorithm

Type:

int

n_ant

Total number of ants (agents)

Type:

int

n_colony

Ant colony size

Type:

int

Properties:
best_result() -> Archive:

Returns the best solution at the moment

Raises:

ValueError – If a different type of membership function is passed, it is not a triangular function

property best_result: Archive

Returns the best solution at the moment

Returns:

The best solution with the least losses

Return type:

Archive

continuous_ant_algorithm() ndarray[source]

Starts a continuous ant colony algorithm

Returns:

Final parameters after optimization

Return type:

np.ndarray

class fuzzyops.fuzzy_optimization.fuzzy_metaevristic_optimization.optimization.Archive(k: int, params: ndarray, loss: float)[source]

Bases: object

Stores parameters and results for one optimization iteration

k

Archive index

Type:

int

params

Parameters of the fuzzy model

Type:

np.ndarray

loss

Loss (error) for this iteration

Type:

float

k: int
loss: float
params: ndarray
class fuzzyops.fuzzy_optimization.fuzzy_metaevristic_optimization.optimization.FuzzyBounds(start: int | float, end: int | float, step: int | float, x: str)[source]

Bases: object

Defines boundaries for fuzzy values

start

The initial value of the boundaries

Type:

Union[int, float]

end

The final value of the boundaries

Type:

Union[int, float]

step

A step for boundaries

Type:

Union[int, float]

x

A list of placemarks or border names

Type:

list[str]

end: int | float
start: int | float
step: int | float
x: str