picos.constraints.con_flow

Implementation of FlowConstraint.

Classes

class picos.constraints.con_flow.FlowConstraint(G, f, source, sink, flow_value, capacity=None, graphName='')[source]

Bases: Constraint

Network flow constraint.

Note

Unlike other Constraint implementations, this one is instanciated by the user (via a wrapper function), so it is raising exceptions instead of making assertions.

class Conversion[source]

Bases: ConstraintConversion

Network flow constraint conversion.

classmethod convert(con, options)[source]

Implement convert.

classmethod predict(subtype, options)[source]

Implement predict.

__init__(G, f, source, sink, flow_value, capacity=None, graphName='')[source]

Construct a network flow constraint.

Parameters
  • G (networkx DiGraph.) – A directed graph.

  • f (dict) – A dictionary of variables indexed by the edges of G.

  • source – Either a node of G or a list of nodes in case of a multi-source flow.

  • sink – Either a node of G or a list of nodes in case of a multi-sink flow.

  • flow_value – The value of the flow, or a list of values in case of a single-source/multi-sink flow. In the latter case, the values represent the demands of each sink (resp. of each source for a multi-source/single-sink flow). The values can be either constants or AffineExpression.

  • capacity – Either None or a string. If this is a string, it indicates the key of the edge dictionaries of G that is used for the capacity of the links. Otherwise, edges have an unbounded capacity.

  • graphName (str) – Name of the graph as used in the string representation of the constraint.

draw()[source]

Draw the graph.

replace_mutables(mapping)[source]

Make the constraint concern a different set of mutables.

See replace_mutables for more.

property mutables[source]

All mutables referenced by the constraint.