69
CONSTRAINT LOGIC PROGRAMMING FOR GRAPH ANALYSIS MATTHEW CARSON

Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CONSTRAINT LOGIC PROGRAMMING FOR GRAPH

ANALYSISMATTHEW CARSON

Page 2: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

OVERVIEW

Constraint logic programming is a popular interpretation of logic programming, focused on using constraint

satisfaction to provide a declarative approach to otherwise intractable problems.

This presentation will focus on providing an overview of constraint logic programming and efforts to apply it to

graphs and graph problems, as well as an overview of some alternative logic programming approaches to graph

problems.

Page 3: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CONSTRAINT LOGIC PROGRAMMING OVERVIEW

Goal: Find the solution to a problem, subject to a set of constraints.

Problems are divided up into:

Variables, which must be assigned values to reach a solution.

Domains for the variables, which their values are taken from,

Constraints on the values that the variables can be assigned.

Page 4: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CONSTRAINT SATISFACTION PROBLEM DEFINITIONS

A constraint satisfaction problem is defined by sets <X, D, C>:

A set of variables, {X1…Xn}

A set of corresponding domains for each variable, {D1…Dn}

A set of constraints C, each of which applies to a subset of the variables and implies a relation between their domains.

A solution therefore assigns values to all variables from their domains, without violating any of the constraints.

Page 5: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

EXAMPLE

Variables A, B, C

Domains of [1, 2, 3] for each.

Constraints:

A != B

A != C

B > C

Page 6: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CONSTRAINT NETWORKS

Constraints are represented by an undirected graph

Nodes for each variable.

Edges representing the constraints between them.

The constraint network for the [A, B, C] example:

Page 7: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SEARCH SPACES

We can show the range of possible assignments in a directed graph for our search space.

Nodes are possible sets of assignments

Edges show assignments that can be reached by assigning values to unassigned variables.

Page 8: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SEARCH SPACES, CONT.

Notice that the search space for even a tiny problem can become very large very quickly. Additionally,

notice that starting with an assignment of {C=3}, on the far right, can never lead to a solution.

Possible satisfying assignments:

A=3, C=1, B=2

A=2, C=1, B=3

A=1, C=2, B=3

Page 9: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

VARIABLE AND DOMAIN TYPES

Integer variables: Values from a finite domain of integer values.

Real variables: Values from a range of real numbers.

Both allow for constraints using mathematical comparisons (eg. less than, greater than, or more complicated

algebraic expressions.)

Set variables: Domains based on sets (eg. ‘all subsets of this set’ as possible values)

Constraints can take the form of things like subset and superset relations.

Page 10: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

APPLYING CONSTRAINTS

Unary constraints apply to a single variable.

Can be applied in a single pass.

Constraints that apply to two or more variables are more complex.

We apply these constraints and reduce the domains of a variable in the filtering step,

Domain reduction then affects the domains of every variable linked to that one via constraints.

Page 11: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

BACKTRACKING

Repeatedly try different combinations.

Backtrack on hitting a point where it's no longer possible to make an assignment.

But this can lead to repeatedly attempting similar combinations of assignments

If, for instance a choice was made early on which could not lead to a correct answer.

Page 12: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

LOCAL CONSISTENCY

We resolve this with the concept of local consistency.

Keep every variable consistent with its neighbors in the constraint network.

This allows constraints to propagate through the entire network until the whole thing is consistent.

Mackworth, 1977

Page 13: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CONSTRAINT PROPAGATION

Reduce the domains of adjacent variables to remove values that won’t be part of a valid solution.

Types of local consistency this enforces:

Node consistency: Every variable is consistent with its unary constraints.

Arc consistency: All variables connected by multi-variable constraints (‘arcs’) are consistent with those constraints.

Path consistency: For a given pair of nodes, there exists assignments for them which satisfy their constraints while also

satisfying their constraints with any third variable.

Mackworth, 1977

Page 14: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

LOCAL CONSISTENCY, CONT

For nodes i and j, unary predicates Px and binary predicates Px,y:

Mackworth, 1977

Page 15: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

ARC CONSISTENCY: AC-1

AC-1: Iterate over all binary constraints and remove any values which lacked a possible value on the other side

of the constraint that would make them consistent.

Every time a domain was reduced, iterate over all of them again.

Mackworth, 1977

Page 16: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

ARC CONSISTENCY: AC-2

Iterating over all constraints every time wastes a great deal of effort re-checking binary constraints whose

variables were not affected by the removal.

AC-2 fixes this by only re-examining binary constraints that include the variable which had its domain reduced,

rather than all of them.

This requires a queue to track the nodes we want to examine.

When examining a node i, we note the nodes in the constraint network one step away from it, and enqueuer

them all if the domain of i is revised.

Mackworth, 1977

Page 17: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

ARC CONSISTENCY: AC-3

AC-2 can sometimes have a variable in the queue multiple times at once.

To fix this, AC-3 retains a queue of arcs rather than nodes. When a variable from an arc that has already been

examined has its domain reduced, that arc is re-inserted into the queue.

AC-3 has a worst-case time of O(ea3); its queues give it a space complexity of O(ea2).

Mackworth, 1977

Page 18: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

ARC CONSISTENCY: AC-4

AC-4 works by tracking the support a value has.

Potential values are removed from a domain when they have no way of satisfying a particular constraint.

For each constraint, the values in linked variables that allow a given value to satisfy that constraint are called

supports for it on that constraint.

The number of supports a value has are tracked, and every time a value is removed, all the other values it

supported have their supports decremented by one.

When a value has no support on a given constraint, that value is removed from its domain.

Mohr and Henderson, 1986

Page 19: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

EXAMPLE

With constraints A < B and B < C, and domains of [1, 2, 3]

Unsupported nodes are in red.

Mohr and Henderson, 1986

Page 20: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

EXAMPLE

After removing unsupported values once.

Mohr and Henderson, 1986

Page 21: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

EXAMPLE

After removing unsupported values again.

Mohr and Henderson, 1986

Page 22: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

AC-5

AC-5 refines AC-3 by having each entry in the queue consist of not just an arc, but an arc and the value that was

removed.

Each removal causes a new entry to be placed in the queue for each value that was removed from that arc.

Hentenryck et al, 1992

Page 23: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

AC-6

AC-6 functions similarly to AC-4, but it tracks only a single support for each constraint rather than all of them.

Values are only removed when they run out of constraints; therefore, it can just track one support per value, and

search for another only if that one is removed.

If no other supports are found, the value is removed from its domain.

Later refined into AC-7, which exploits the bi-directionality of constraints.

Bessiere, 1994

Page 24: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

PATH CONSISTENCY

Sometimes, you have two variables with values in their domains that satisfy all binary constraints between them,

but which fail to satisfy a ‘path’ between them through the constraint network.

Establishing consistency for paths of length 2 is sufficient to establish larger path consistency.

Montanari, 1974

Page 25: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

PATH CONSISTENCY: PC-1

Iterate over the entire set of length-2 paths, repeatedly removing invalid combinations until it is path-consistent.

Comparable to AC-1.

Montanari, 1974

Page 26: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

PATH CONSISTENCY: PC-2

Maintain a queue of length-2 paths that must be examined, and re-enque any paths that were potentially

invalidated by a removal if they are not already in the queue.

Comparable to AC-3.

Montanari, 1974

Page 27: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SYMMETRY

Equivalence class: Multiple solutions that represent the same basic concept with a trivial difference (for example, a

different ordering.)

This can cause us to repeatedly find trivial permutations of the same answer;.

We only want one solution from each equivalence class.

Preventing such symmetric solutions from coming up again and again is called symmetry breaking.

Page 28: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CLP ON GRAPHS

Graph Matching & Graph Isomorphism

Pathfinding and Reachability

Trees

Graph Labeling

Page 29: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

GRAPH MATCHING & GRAPH ISOMORPHISM

Finding similarities between graphs.

Retrieving subgraphs that match a specific pattern.

Page 30: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CP(GRAPH)

Dooms et al wrote CP(Graph), a general-purpose computation domain for graphs focused on finding subgraphs

using constraints

Broad applications, but primarily intended for biochemical network analysis.

Graph domain variables use finite sets, with graphs represented by sets of nodes, arcs, and arcnodes (connections

between nodes and arcs.)

Weights are represented by constraints rather than variables.

Designed for directed graphs, but can also support undirected graphs.

Dooms et al, 2004

Page 31: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CP(GRAPH): VARIABLES

Graphs are defined as a set of nodes, SN, and a set of edges, SA.

The edges are defined from pairs of node to node within SN:

𝑆𝐴 ⊆ 𝑆𝑁 × 𝑆𝑁

Graphs have a partial ordering based on graph inclusion:

A graph is a subset of another graph if its nodes and edges are both subsets of that graph’s nodes and edges.

Given 𝑔1 = (𝑠𝑛1, 𝑠𝑎1) and 𝑔2 = (𝑠𝑛2, 𝑠𝑎2), 𝑔1 ⊆ 𝑔2 iff 𝑠𝑛1 ⊆ 𝑠𝑛2 and 𝑠𝑎1 ⊆ 𝑠𝑎2.

Dooms et al, 2004

Page 32: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CP(GRAPH): VARIABLES, CONT

Graphs have a domain bounded by the greatest lower bound and least upper bound within this ordering.

Least upper bound: All nodes and edges that could possibly be part of the graph.

Greatest lower bound: All nodes and edges that must be part of the graph.

Dooms et al, 2004

Source: Dooms

Page 33: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CP(GRAPH): KERNEL CONSTRAINTS

‘kernel’ constraints: Define the structure of a graph by constraining the sets that define it.

Can be composed with finite domain and finite set constraints to make more complex constraints.

Arcs(G, SA): Defines SA as the set of edges for graph G.

Nodes(G, SN): Defines SN as the set of nodes for G.

ArcNode(A, N1, N2): Defines A as an edge from nodes N1 to N2.

Dooms et al, 2004

Page 34: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

CP(GRAPH): USING THE KERNEL CONSTRAINTS

The kernel constraints can be used to construct other constraints.

For instance, the subgraph constraint:

“A graph’s nodes and arcs are subsets of the nodes and arcs of another graph.”

Subgraph(G1, G2): G1 is a subset of G2:

𝑆𝑢𝑏𝑔𝑟𝑎𝑝ℎ 𝐺1, 𝐺2 ≡ 𝑁𝑜𝑑𝑒𝑠 𝐺1 ⊆ 𝑁𝑜𝑑𝑒𝑠 𝐺2 , 𝐴𝑟𝑐𝑠 𝐺1 ⊆ 𝐴𝑟𝑐𝑠 𝐺2

Dooms et al, 2004

Page 35: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SOLNON: GRAPH MATCHING

A constraint-based modeling language for graph matching.

The goal is to match nodes in one graph to nodes in a second graph

Nodes in the first graph are assigned integer variables indicating which graph-two node they’re paired with.

Alternatively, it can be set up to allow nodes in the first graph to pair up with groups of nodes in the second.

In this case, the domains are sets of integers.

Solnon et al, 2009

Page 36: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SOLNON: VARIABLES

Graphs are sets of nodes, edges, and labels:

G1 = (N1E1L1) and G2 = (N2E2L2)

Edges are defined according to the nodes they connect:

𝐸 ⊆ 𝑁 × 𝑁

Labels assign integers to nodes and edges:

𝐿: 𝑁 ∪→ ℕ

The goal is to find a labeling that matches every node of G1 to a node or set of nodes in G2.

Solnon et al, 2009

Page 37: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SOLNON: CONSTRAINTS

Their first set of constraints (MinMatch, MaxMatch) define the maximum and minimum number of nodes a given

node (or set of nodes) can be matched to in a matching.

They use an Injective constraint to ensure that nodes in a given set are matched to distinct nodes in the other

graph.

Their third set of constraints is for pairs of nodes which must be matched to nodes connected by an edge;

MatchedToSomeEdges ensures that there exists a pair of matched nodes that have an edge between them, while

Matched-ToAllEdges ensures that all pairs of matched nodes have edges between them.

Solnon et al, 2009

Page 38: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

GAY: SUBGRAPH ISOMORPHISMS

Gay et al described a system for finding subgraph isomorphisms intended for use in studying biochemical reactions.

It turns an 'antecedent' graph into a reduced version via the application of transformation rules.

The goal graph is represented by morphism variables.

One variable per edge or node in the goal graph.

Domain: Sets of edges or nodes, accordingly.

These represent the edges or nodes from the antecedent graph combined into it.

The antecedent graph is a graph to be transformed.

One variable per edge or node in the antecedent graph.

Domain are edges or nodes in the goal graph respectively.

Values here indicate which goal-graph object corresponds to this one.

Not one-to-one; multiple antecedent nodes / edges can be paired to one in the goal graph.

Gay et al, 2013

Page 39: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

GAY: SUBGRAPH ISOMORPHISMS

Constraints between the antecedent and goal graphs define the valid transformations.

Nodes can be deleted or merged according to the rules of biochemical reactions.

For instance, some nodes can only be merged with nodes of the same type.

Some nodes can be deleted, and others can’t.

In the above graph, d and F are deleted, and c is merged with p to produce r. (E becomes the node labeled C.)

Source: Gay

Gay et al, 2013

Page 40: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

FROMHERTZ AND MAHONEY:

SLOPPY STICK FIGURE MATCHING

Fromherz and Mahoney applied constraint-based graph matching to image analysis.

Their algorithm analyzed images of stick figures and converted it into graphs representing the lines that formed

the figure and the connections between them.

Fromherz and Mahoney, 2001

Page 41: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

FROMHERZ AND MAHONEY:

VARIABLES

The sloppy stick figure is parsed into a data graph to a model graph representing an ideal stick figure, composed of

limb statements (some of which are optional) and combined with linked statements.

The variables are the nodes in the model graph, with values from the domain of the data graph.

Model variables marked as optional can be assigned to null, indicating that that part isn’t in the data graph.

Limbs consist of a pair of nodes linked by a bond.

A node can only be bonded to one other node; if two limbs are connected, they have endpoints close together

(or on top of each other) connected by linked statement.

Fromherz and Mahoney, 2001

Page 42: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

FROMHERZ AND MAHONEY:

CONSTRAINTS

Link support: If two model nodes have a link or bond between them, then any two data nodes they are matched

to must share that connection.

Unique interpretation: Matching must be one-to-one.

Minimal total link length: Minimizes the total distance between all links used in the matching.

Optimal part proportions: Constrains matches closest to the proportions defined by their minimize statements

Maximal part count: Minimizes number of optional model variables assigned to null, and therefore the number of

unmatched optional limbs.

Fromherz and Mahoney, 2001

Page 43: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

QUESADA ET AL:

CONSTRAINED PATHFINDING

Quesada et al approached the problem of constrained pathfinding, in which the goal is to find a path between two

nodes subject to certain constraints, such as making it mandatory for the path to visit certain nodes.

Work based on Dooms.

Quesada et al, 2005

Page 44: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

QUESADA ET AL:

VARIABLES AND REPRESENTATION

The graph variable g is based on Dooms’; domains are all subsets of a given set of nodes.

They also define variables for:

A source node and a destination node in g.

A set of nodes in g reachable from the source node.

A set of bridge edges and cut nodes appearing in all possible paths from the source to the destination.

Quesada et al, 2005

Page 45: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

QUESADA ET AL:

CUT NODES AND REACHABILITY

All paths from 1 to 9 go through 5.

Therefore, node 5 must be part of the graph, 5 must be reachable from 1, and 9 must be reachable from 5.

Source: Quesada

Quesada et al, 2005

Page 46: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SELLMANN ET AL:

FINDING THE SHORTEST PATH VIA GAP-CLOSING

Applied a similar focus on bridges to finding the shortest path.

Directed, weighted, acyclic graph

Uses a gap-closing approach: Begin with upper and lower bounds and narrow them by finding improved solutions.

This refines the best-known or incumbent solution.

Works through a minimization / optimization constraint on the path length

Starting with one destination, repeatedly determine which edges cannot be part of the shortest path, and which

edges serve as bridges that must be part of the shortest path.

Sellmann et al, 2003

Page 47: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

LORCA ET AL:

PARTITIONING GRAPHS INTO ANTI-ARBORESENCES

Lorca et al applied constraint logic programming to partitioning a directed graph into anti-arborescences, directed

trees with no overlapping nodes and all edges directed towards the root node.

Lorca et al, 2011

Page 48: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

LORCA ET AL:

DEFINITIONS

A connected component is a maximal subgraph where all nodes have a chain of edges which, ignoring direction,

connect them to another node in the component.

A strongly connected component is a maximal subgraph where all nodes have a directed path to each other node in

the component.

A strong articulation point is a node that would break a strongly connected component in two if removed.

A sink component is a strongly-connected component with no edges leading out of it.

A door node is a node with an edge leading out of a strongly-connected component.

Lorca et al, 2011

Page 49: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

LORCA ET AL:

REPRESENTATION

Each node has an associated variable for its successor; since these are anti-arboresences (trees with edges pointing

to the root), each non-root node has one successor, and a root has a null successor.

Lorca et al, 2011

Page 50: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

LORCA ET AL:

DETERMINING ROOT NODES

Number of roots L:

Lower bound equal to the number of sink components

Upper bound equal to the number of potential roots.

Note that this is also the number of trees to divide the graph into.

Additionally, each sink component must always contain a potential root.

When L’s domain is empty, we know we’ve hit an unsolvable assignment.

Lorca et al, 2011

Page 51: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

LORCA ET AL:

REMOVING UNUSED EDGES

The structural filtering propagator removes edges that cannot be part of any tree.

It is defined using door nodes, which have an edge leading to a different strongly-connected component, and winner

nodes, which are either a potential root or a door.

From there they define three rules:

If a sink component contains only one potential root, then all outgoing non-loop edges from that root must be removed.

Roots cannot have outgoing edges.

Second, if a strongly connected component has no potential root and just one door, then all edges leading from that door

into the component must be removed; in other words, we must go ‘through’ the door’.

Finally, for each strong articulation point, any outgoing edges from that point that lead to a subgraph whose only paths to a

winner go through that point must be removed; this is because including such an edge would deny that subgraph any path

to a winner, turning it to a subgraph with no potential roots.

Lorca et al, 2011

Page 52: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SMITH:

GRAPH LABELING FOR GRACEFUL GRAPHS

Smith applied constraint programming to determining if graphs have a graceful labeling and finding one if it exists.

A graceful labeling is one where each node has a unique integer label from 0 to q, and where each edge can be

uniquely labeled with the absolute difference between its two node labels, such that the label edges are the set 1

to q.

Smith produced two CP models for this, a traditional one and one based on the edge-label model to refine it.

Smith, 2006

Page 53: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SMITH:

TRADITIONAL MODEL

Each node has an associated variable for its label, with a domain from 0 to q.

Each edge is likewise given a variable for its label, with a domain 1 to q.

The edge labels are constrained to be the absolute value of the difference between their associated node labels.

Two potential sources of symmetry that need to be broken:

The graph itself may be symmetric (such as a path, where the order of the node labels can be reversed.)

Broken by imposing an ordering on the variables representing symmetric parts of the graph.

Each node variable can have its label v replaced with its complement, |v – q|.

Broken by taking any node that is not symmetrically equivalent to another node and constraining its value to less than the ‘halfway’ point

from 0 to q.

Smith, 2006

Page 54: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SMITH:

EDGE-LABEL MODEL

In this model, variables are assigned to the edge labels {1…q}

These variables have values equal to the smaller of the two nodes that that label connects.

For example, if we assign edge label 1 to node 3, we know that it connects nodes 3 and 3 + 1 = 4, because an

edge is labeled with the absolute value of the nodes it connects.

Nodes labels have similar variables, with the value representing the node assigned to that label, or n + 1 for labels

that are not used.

Smith, 2006

Page 55: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SMITH:

EDGE-LABEL MODEL, SYMMETRY BREAKING

Complement symmetry can be broken by examining the edge label, q-1; it must have a value of either 0 or 1, so

we arbitrarily reduce it to 1.

Graph symmetry can be broken by mapping the node label variables to the node variables from the first model

and applying the constraints described there.

Smith, 2006

Page 56: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

OTHER APPROACHES

Page 57: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SAT: DPLL

The foundation of modern SAT checking is the DPLL (Davis-Putnam-Logemann-Loveland) algorithm.

This operates using what is now called the splitting rule:

For a formula in conjunctive normal form with clauses joined by ^ containing a given variable λ, we can split the process of

solving it into two subproblems, one in which the positive-polarity λ is removed from all clauses that contained it, and one

in which ¬λ is removed from all clauses that contain it.

The formula is solvable only if one of these two subproblems is solvable.

Page 58: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SAT: DPLL

Pure literal rule: If a variable appears only as X or ¬X, all clauses containing it can be made true by assigning it the

necessary value, and therefore all clauses containing it can immediately be removed.

Unit clause rule / Unit propagation:

For any clause containing just one literal to be true, that literal's value must be true.

Conversely, for any clause containing just the negation of one literal to be true, that literal's value must be false.

We can immediately assign the necessary values to such literals on encountering them.

Page 59: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SAT: DPLL REFINEMENTS

Shortest clause rule: Selects variables from clauses with the fewest unassigned literals.

Other approaches:

Eliminating smaller clauses earlier

Making inferences early in the search

Eliminating areas of the search space as soon as possible

Page 60: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SAT: CDCL SOLVERS

Conflict-Driven Clause Learning (CDCL) SAT solvers have proven highly effective at implementing many of these

improvements and have therefore seen considerable practical use.

They are based on DPLL, but refine it in several ways, including:

Adding new clauses based on conflicts they encounter,

Exploiting the structure of conflicts,

Lazy data structures, and

Random restarts.

Page 61: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

SAT: GRAPH ANALYSIS

Gay applied an SAT model to their subgraph epimorhism problems.

They expressed their subgraph epimorphism problem as a partial surjective function; that is, one where every

result in the target graph is paired with exactly one result in the source graph.

In their tests, with a timeout of 20 minutes, they found that the set of solutions they would find for most types of

problems using CLP was a subset of what they would find with SAT.

Gay et all, 2013

Page 62: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

ANSWER SET PROGRAMMING

Answer Set Programming is a form of declarative programming that relies on what is called answer set or stable

model semantics.

The goal in Answer Set Programming is to find the answer set or stable model for some variables and constraints

- the set of minimal assignments to those variables that match the given constraints.

A possible satisfying assignment is called a Herbrand model, and a minimal Herbrand model is one such that none

of its subsets are valid Herbrand models.

This model adds default statements, which are treated as true unless their negation is true; and negations, which

remove such statements from the stable model (that is, the answer set.)

This focus on removing statements from the stable model allows answer set programming to employ strong

negation and disjunction in a Prolog-like environment.

Page 63: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

APPLICATIONS FOR CLP GRAPH ANALYSIS

Dooms et al: Biochemical network analysis, graphs of genes, molecules, reactions, and controls

Using known reactions in a cell to map out additional ones, finding them as paths in a directed graph.

Can be modeled as a constrained search for shortest paths.

Solnon et al: Pattern recognition in images

Convert points of interest in an image into a graph.

Search the resulting graph for subgraph isomorphisms.

Fromherz and Mahoney: Sloppy stick figure analysis, another form of image pattern-recognition.

Produced an 'ideal' graph of the image they were looking for.

Used this to search for specic patterns in images (stick figures, in this case).

Page 64: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

APPLICATIONS: XML ANALYSIS

Mamoulis et al applied constraint satisfaction to analyzing XML

They converted XML to graphs, then searched it using constraint satisfaction.

Generating large graphs at random, which they termed rooted node-labeled graphs, they used intermediate nodes

to represent the set of possible labels, and leaf nodes to store text.

Page 65: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

APPLICATIONS:

OPTIMIZING ELECTRIC VEHICLE TRAVEL

Monreal et al applied soft constraint logic programming to the problem of optimizing electric vehicle travel in soft

CLP.

Each constraint is given a cost for violations, and if a solution that satises all constraints cannot be found, solutions

that violate the progressively lower-ranked constraints are used instead.

Graph represents the network over which vehicles travel

Directed and double-weighted, with weights for both time and energy consumption.

Variables: Sets of paths, with each being a sequence of nodes, plus a total time and energy cost for that path

Domain: The set of all possible paths.

Constraints enforce the road network and sets of appointments the vehicles must keep, as well as defining the

optimizations necessary for the best path.

Page 66: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

APPLICATIONS:

OPTIMAL VALVE PLACEMENT

Catta et al used CLP(FD) to determine optimal valve placement in water distribution network.

Valves: Disposable maintenance tools attached to a network of pipes

Each valve has a cost; the goal is to minimize this

It is also important to be able to disable specific areas for maintenance while disabling as few other areas as possible.

This is an optimization problem where they seek to minimize the number of valves and the maximum possible

disruption.

Page 67: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

APPLICATIONS:

OPTIMAL VALVE PLACEMENT (CONT.)

Variables: A list of booleans for each possible valve location, indicating whether a valve is present or not;

Solutions are tested as a two-player game, with one player trying to maximize disruption and the other trying to

minimize it.

Player 1 attempts to assign an optimal valve placement

Player 2 attempts to maximize the disruption caused by broken pipes

Player 1 tries to close valves to handle this by closing valves in a way that minimizes disruption.

Constraints determine the pipe graph and impose the minimization and maximization constraints for each player

at each step.

They implemented their algorithm in ECLiPSe, testing graphs with five to thirteen valves, and found that

computing time grows sub-exponentially with the number of valves.

Page 68: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

BIBLIOGRAPHY

[1] N. Beldiceanu, P. Flener, and X. Lorca. The tree constraint. In CPAIOR, volume 3524 of Lecture Notes in Computer Science, pages 64{78. Springer, 2005.

[2] C. Bessire. Arc-consistency and arc-consistency again. Articial Intelligence, 65:179{190, 1994.

[3] C. Bessire, E. C. Freuder, and J.-C. Rgin. Using inference to reduce arc consistency computation. In IJCAI (1), pages 592{599. Morgan Kaufmann, 1995.

[4] A. Biere, M. J. H. Heule, H. van Maaren, and T. Walsh, editors. Handbook of Satisfiability, volume 185 of Frontiers in Artificial Intelligence and Applications. IOS Press, February 2009. ISBN 978-1-58603-929-5.

[5] M. Catta, M. Gavanelli, M. Nonato, S. Alvisi, and M. Franchini. Optimal placement of valves in a water distribution network with CLP(FD). CoRR, 1248, 2011.

[6] R. Y. Chuan. A constraint logic programming framework for constructing dna restriction maps. Artificial Intelligence in Medicine, 5(5):447{464,1993.

[7] V. L. Clment, Y. Deville, and C. Solnon. Constraint-based graph matching, 2009.

[8] M. Davis, G. Logemann, and D. W. Loveland. A machine program for theorem-proving. Commun. ACM, 5(7):394{397, 1962. 21

[9] M. Davis and H. Putnam. A computing procedure for quantication theory. J. ACM, 7(3):201{215, July 1960.

[10] M. D. Davis, R. Sigal, and E. J. Weyuker. Computability, Complexity, and Languages (2nd Ed.): Fundamentals of Theoretical Computer Science. Academic Press Professional, Inc., San Diego, CA, USA, 1994. ISBN 0-12- 206382-1.

[11] G. Dooms, Y. Deville, and P. Dupont. Constrained pathfinding in bio- chemical networks. In IN 5EMES JOUREES OUVERTES BIOLOGIE INFORMATIQUE MATHEMATIQUES, page 40. 2004.

[12] G. Dooms, Y. Deville, and P. Dupont. CP(graph): Introducing a graph computation domain in constraint programming. In In CP2005 Proceedings, pages 211{225. Springer-Verlag, 2005.

[13] J.-G. Fages and X. Lorca. Revisiting the tree constraint. volume 6876 of Lecture Notes in Computer Science, pages 271{285. Springer, 2011.

[14] M. P. J. Fromherz and J. V. Mahoney. Interpreting sloppy stick figures with constraint-based subgraph matching. volume 2239 of Lecture Notesin Computer Science. Springer, 2001.

[15] M. Gavanelli and F. Rossi. Constraint logic programming. In A. Dovier and E. Pontelli, editors, A 25-Year Perspective on Logic Programming: Achievements of the Italian Association for Logic Programming, GULP, pages 64{86. Springer, 2010.

[16] S. Gay, F. Fages, F. Santini, and S. Soliman. Solving subgraph epimor- phism problems using clpand sat. In Proceedings of the ninth Workshop on Constraint Based Methods for Bioinformatics WCB'13, colocated with CP 2013, pages 67{74. September 2013.

[17] M. Gelfond. Answer sets. pages 285{316, 2008.

[18] M. Gelfond and V. Lifschitz. The stable model semantics for logic programming. pages 1070?{1080. 1988.

[19] M. Gelfond and V. Lifschitz. The stable model semantics for logic programming. In R. Kowalski, Bowen, and Kenneth, editors, Proceedings of International Logic Programming Conference and Symposium, pages 1070{1080. MIT Press, 1988.

[20] M. Gelfond and V. Lifschitz. Classical negation in logic programs and disjunctive databases. New Generation Computing, 9:365{385, 1991.

Page 69: Constraint Logic Programming for Graph Analysis · 2015-09-25 · CONSTRAINT LOGIC PROGRAMMING OVERVIEW Goal: Find the solution to a problem, subject to a set of constraints. Problems

BIBLIOGRAPHY

[21] P. V. Hentenryck, Y. Deville, and C. man Teng. A generic arc-consistency algorithm and its specializations. Articial Intelligence, 57:291{321, 1992. 22

[21] R. Haralick and G. L. Elliott. ArticialIntelligence, 14:263{313, 1980.

[23] J. Jaar, S. Michaylov, P. J. Stuckey, and R. H. C. Yap. The clp(r) language and system. ACM Trans. Program. Lang. Syst., 14(3):339{395, May 1992. ISSN 0164-0925.

[24] A. K. Mackworth. Consistency in networks of relations. Articial Intelligence, 8(1):99{118, 1977.

[25] N. Mamoulis and K. Stergiou. Constraint satisfaction in semi-structured data graphs. In CP. Volume 3258 of Lecture Notes in Computer Science, pages 393{407. Springer, 2004.

[26] R. Mohr and T. C. Henderson. Arc and path consistency revisited. Artificial Intelligence, 28(2):225{233, 1986.

[27] G. V. Monreale, U. Montanari, and N. Hoch. Soft constraint logic programming for electric vehicle travel optimization. CoRR, 2056, 2012.

[28] U. Montanari. Networks of constraints: Fundamental properties and applications to picture processing. Inf. Sci., 7:95{132, 1974.

[29] M. Perlin. Arc consistency for factorable relations. Artif. Intell., 53(2-3):329{342, 1992.

[30] G. Pesant. A constraint programming primer. EURO Journal on Computational Optimization, 2014.

[31] L. Quesada, P. V. Roy, and Y. Deville. Speeding up constrained path solvers with a reachability propagator. In P. van Beek, editor, CP, volume 3709 of Lecture Notes in Computer Science, page 866. Springer, 2005. ISBN 3-540-29238-1.

[32] J.-C. Rgin. Global constraints: A survey. volume 45 of Optimization and Its Applications, pages 63-134.

[33] M. Sellmann, T. Gellermann, and R. Wright. Cost-based ltering for shorter path constraints. In In proceedings CP03, pages 694{708. 2003.

[34] A. Shankar, D. Gilbert, and M. Jampel. Transient analysis of linear circuits using constraint logic programming. Technical report, In Proceedings of the International Conference on Practical Applications of Constraint Technology, 221-247, 1996.

[35] B. M. Smith. Constraint programming models for graceful graphs. In F. Benhamou, editor, CP, volume 4204 of Lecture Notes in Computer Science, pages 545{559. Springer, 2006. ISBN 3-540-46267-8. 23

[36] R. J.Wallace. Why AC-3 is almost always better than AC-4 for establishing arc consistency in csps. pages 239{245. 1993. 24

[37] J. Jaar and J.-L. Lassez. Constraint logic programming. In Proceedings of the 14th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL '87, pages 111{119. ACM, New York, NY, USA, 1987. ISBN 0-89791-215-2. doi:10.1145/41625.41635.