FACTOR_GRAPH

class ComputationsFactorGraph(var_nodes: Iterable[VariableComputationNode], factor_nodes: Iterable[FactorComputationNode])

A ComputationSFactorGraph is a computation graph based on a factor-graph model.

The graph is made of two kind of nodes : * variables nodes * factor nodes

Edges can only exists between a factor node and a variable node.

class FactorComputationNode(factor: RelationProtocol, name: str | None = None)

Factor ComputationNode for factor-graph.

A factor-graph is a bipartite graph made of two kind of nodes, FactorComputationNode and VariableComputationNode.

Parameters:
  • factor (Constraint) – The constraint this computation is responsible for.

  • name (str) – Optional name, if not given the name of the constraint is used as the name of the node.

In Factor Graph, links are binary (FG are not hyper-graphs) and are between a factor node and a variable node.

Parameters:
  • factor_node (str) – The name of the factor node.

  • variable_node (str) – The name of the variable node.

class VariableComputationNode(variable: Variable, constraints_names: Iterable[str], name: str | None = None)

Variable ComputationNode for factor-graph.

A factor-graph is a bipartite graph made of two kind of nodes, FactorComputationNode and VariableComputationNode.

Parameters:
  • variable (Variable) – The Variable this computation is responsible for.

  • constraints_names (Iterable of str) – The name of the constraints this variable is involved in.

  • name (str) – Optional name, if not given the name of the variable is used as the name of the node.

build_computation_graph(dcop: DCOP, variables: Iterable[Variable] | None = None, constraints: Iterable[RelationProtocol] | None = None) ComputationsFactorGraph

Build a Factor graph computation graph for a DCOP.

Parameters:
  • dcop (DCOP) – a DCOP objects containing variables and constraints

  • variables (iterable of Variables objects) – The variables to build the computation graph from. When this parameter is used, the constraints parameter MUST also be given.

  • constraints (iterable of Constraints objects) – The constraints to build the computation graph from. When this parameter is used, the variables parameter MUST also be given.