Section for working with fuzzy analytical networks

class fuzzyops.fan.fan.Edge(start_node: Node, end_node: Node, weight: float)[source]

Bases: object

Represents an edge in a fuzzy analytical network

start_node

The initial node of the edges

Type:

Node

end_node

The end node of the edge

Type:

Node

weight

The weight of the edge, representing its degree of feasibility

Type:

float

Parameters:
  • start_node (Node) – The initial node of the edge

  • end_node (Node) – The end node of the edge.

  • weight (float) – The weight of the edge, representing its degree of feasibility

class fuzzyops.fan.fan.Graph[source]

Bases: object

It represents a directed graph, a fuzzy analytical network The algorithm is implemented according to the article https://cyberleninka.ru/article/n/nechetkaya-alternativnaya-setevaya-model-analiza-i-planirovaniya-proekta-v-usloviyah-neopredelennosti

nodes

Dictionary of nodes in a graph

Type:

dict

edges

A list of edges in a graph

Type:

List[Edge]

add_edge(start_node_name: Node, end_node_name: Node, weight: float) None[source]

Adds an edge to the graph

Parameters:
  • start_node_name (Node) – The name of the initial node

  • end_node_name (Node) – Destination Node Name

  • weight (float) – Weight

add_node(node_name: str) Node[source]

Adds a node to the graph and returns it

Parameters:

node_name (str) – The name of the initial node

calculate_path_fuzziness(path: List[Node]) float[source]

Calculates the fuzziness of a given path

Parameters:

path (List[Node]) – A path represented as a list of node names

Returns:

Estimation of path fuzziness

Return type:

float

Raises:

ValueError – If the path is invalid (i.e. there are no edges between nodes)

find_most_feasible_path(start_node_name: Node, end_node_name: Node) List[str][source]

Finds the most feasible path between two nodes based on fuzziness

Parameters:
  • start_node_name (Node) – The name of the initial node

  • end_node_name (Node) – The name of the destination node

Returns:

The most feasible path is represented as a list of node names

Return type:

List[str]

get_paths_from_to(start_node_name: Node, end_node_name: Node) List[Node][source]

Returns a list of all possible paths from the start node to the end node

Parameters:
  • start_node_name (Node) – The name of the initial node

  • end_node_name (Node) – Destination Node Name

Returns:

A list of paths representing lists of node names

Return type:

List[Node]

macro_algorithm_for_best_alternative() List[str] | float[source]

Performs a macro algorithm to determine the best alternative in the network model

Returns:

The best alternative path and its feasibility assessment

Return type:

Union[List[str], float]

class fuzzyops.fan.fan.Node(name: str)[source]

Bases: object

Represents a node in a fuzzy analytical network

name

Node name

Type:

str

in_edges

The list of incoming edges for this node

Type:

List[Edge]

out_edges

The list of outgoing edges from this node

Type:

List[Edge]

Parameters:

name (str) – Node name

add_in_edge(edge: ['Edge']) None[source]

Adds an incoming edge to a node

Parameters:

edge (Edge) – Edge

add_out_edge(edge: ['Edge']) None[source]

Adds an outgoing edge from the node

Parameters:

edge (Edge) – Edge

fuzzyops.fan.fan.calc_final_scores(f_nums: List[FuzzyNumber]) float[source]

Calculates the final score from a list of fuzzy numbers

Parameters:

f_nums (List[FuzzyNumber]) – List of fuzzy numbers

Returns:

The result of defuzzification of fuzzy numbers

Return type:

float