CONSTRAINTS_HYPERGRAPH

class ComputationConstraintsHyperGraph(nodes: Iterable[VariableComputationNode])

A ComputationConstraintsHyperGraph represents computation graph that have the same extract structure as the constraint hyper of the underlying optimization problem. The vertices of the graph represents the decisions variable and edges represents constraints.

This type of graph is used with algorithms that work directly on the constraints hyper graph (without any preprocessing step) and define one computation for each decision variable (e.g. DSA, MGM, etc).

Link between nodes in a constraint hyper-graph

Parameters:
  • name (str) – the name of the constraint represented by this edge.

  • nodes (Iterable of nodes names, as str) – the names of the VariableComputationNode corresponding to the variables in the scope of the constraint represented by the edge.

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

A VariableComputationNode represent a computation responsible for selecting the value of one variable, in a computation constrains hyper-graph.

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

  • constraints (Iterable of constraints) – The Constraints the variable depends on

  • name (str) – The name of the node. If given given, the name of the variable is used as the node name.

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

Build a computation hyper graph for the DCOP.

A computation graph is generally built from a DCOP, however it is also possible to build a sub-graph of the computation graph by simply passing the variables and constraints.

Parameters:
  • dcop (DCOP) – DCOP object to build the computation graph from.When this parameter is used, the constraints and variables parameters MUST NOT be used.

  • 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.

Returns:

In hyper-graph for the variables and constraints

Return type:

ComputationConstraintsHyperGraph

Raises:

ValueError – If both dcop and one of the variables or constraints arguments have been used.