Flex.System (FLex v0.2.2)

View Source

An interface to create a Fuzzy Logic Control System (FLS).

The Fuzzy controllers are very simple conceptually. They consist of an input stage (fuzzification), a processing stage (inference), and an output stage (defuzzification).

Summary

Types

t()

Fuzzy Logic System state.

Functions

Adjust the premise free parameters of the FIS (only avaliable with ANFIS engine), using the following methods

Returns a specification to start this module under a supervisor.

Computes the Fuzzy Logic System output for a given input vector.

Adjust the consequent free parameters of the FIS (only avaliable with ANFIS engine), using the following methods

Gets the current system state.

Adjust the free parameters of the FIS (only avaliable with ANFIS engine), using the following methods

Adjust the free parameters of the FIS (only avaliable with ANFIS engine), using the following methods

Callback implementation for GenServer.init/1.

Sets the Inference Engine type.

Sets the Learning rate (etha).

Spawns a Fuzzy Logic System.

Types

t()

@type t() :: %Flex.System.State{
  antecedent: [Flex.Variable.t(), ...],
  consequent: Flex.Variable.t(),
  engine_output: Flex.EngineAdapter.engine_state(),
  engine_type:
    Flex.EngineAdapter.Mamdani
    | Flex.EngineAdapter.TakagiSugeno
    | Flex.EngineAdapter.ANFIS,
  initial_gamma: number(),
  learning_rate: number(),
  rules: [Flex.Rule.t(), ...],
  sets_in_rules: list()
}

Fuzzy Logic System state.

  • :rules - (list) A list of rules that defines the behavior of the Fuzzy logic systems.
  • :consequent - Output variable.
  • :antecedent - a list of the input variables.
  • :engine_type - defines the inference engine behavior (default: Mamdini).
  • :sets_in_rules - list of sets involve in the rules (optional, required by ANFIS).
  • :learning_rate - is the speed at which the system parameters are adjusted (ANFIS only).
  • :initial_gamma - is the speed at which the system parameters are adjusted (LSE, ANFIS only).

Functions

backward_pass(pid, desired_output)

@spec backward_pass(
  atom() | pid() | {atom(), any()} | {:via, atom(), any()},
  number()
) ::
  {:ok, number()} | {:error, :einval}

Adjust the premise free parameters of the FIS (only avaliable with ANFIS engine), using the following methods:

  • Learning method: Steepest gradient Backpropagation.
  • Energy function: 0.5 * (target - output)^2

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

compute(pid, input_vector)

@spec compute(atom() | pid() | {atom(), any()} | {:via, atom(), any()}, list()) ::
  any()

Computes the Fuzzy Logic System output for a given input vector.

forward_pass(pid, desired_output)

@spec forward_pass(atom() | pid() | {atom(), any()} | {:via, atom(), any()}, number()) ::
  {:ok, number()} | {:error, :einval}

Adjust the consequent free parameters of the FIS (only avaliable with ANFIS engine), using the following methods:

  • Learning method: Steepest gradient Backpropagation.
  • Energy function: 0.5 * (target - output)^2

get_state(pid)

@spec get_state(atom() | pid() | {atom(), any()} | {:via, atom(), any()}) :: t()

Gets the current system state.

hybrid_offline_learning(pid, inputs, targets, epochs)

@spec hybrid_offline_learning(
  atom() | pid() | {atom(), any()} | {:via, atom(), any()},
  list(),
  list(),
  number()
) :: {:ok, number()} | {:error, :einval}

Adjust the free parameters of the FIS (only avaliable with ANFIS engine), using the following methods:

  • Forward method: Least Square Estimate.
  • Learning method: Steepest gradient Backpropagation.
  • Energy function: 0.5 * (target - output)^2 Note: this functions fires both forward and backward passes with a batch of data.

hybrid_online_learning(pid, desired_output)

@spec hybrid_online_learning(
  atom() | pid() | {atom(), any()} | {:via, atom(), any()},
  number()
) ::
  {:ok, number()} | {:error, :einval}

Adjust the free parameters of the FIS (only avaliable with ANFIS engine), using the following methods:

  • Learning method: Steepest gradient Backpropagation.
  • Energy function: 0.5 * (target - output)^2 Note: this functions fires both forward and backward passes.

init(params)

Callback implementation for GenServer.init/1.

set_engine_type(pid, type)

@spec set_engine_type(
  atom() | pid() | {atom(), any()} | {:via, atom(), any()},
  atom()
) ::
  :ok | {:error, :einval}

Sets the Inference Engine type.

set_learning_rate(pid, learning_rate)

@spec set_learning_rate(
  atom() | pid() | {atom(), any()} | {:via, atom(), any()},
  number()
) ::
  :ok | {:error, :einval}

Sets the Learning rate (etha).

start_link(params, opt \\ [])

Spawns a Fuzzy Logic System.

The following options are require:

  • :rules - Defines the behavior of the system based on a list of rules.
  • :antecedent - (list) Defines the input variables.
  • :consequent - Defines the output variable.

stop(pid)