[ library(gfd) | Reference Manual | Alphabetic Index ]
# <ConsistencyModule:> ham_path_offset(?Start,?End,+Succ,+Offset,++CostMatrix,+ArcCosts,?Cost)

Constrains elements in Succ (offset by Offset) to
form a Hamiltonian path from Start to End with cost Cost.
*Start*
- An integer or (domain) variable (array notation accepted)
*End*
- An integer or (domain) variable (array notation accepted)
*Succ*
- A collection of N different (domain) variables or integers
*Offset*
- Offset for Succ (An integer)
*CostMatrix*
- A NxN matrix collection of integers
*ArcCosts*
- A collection of N (domain) variables or integers.
*Cost*
- A (domain) variable or integer (array notation accepted).

## Description

Succ is a collection of N elements presenting a digraph of N nodes, where the
i'th element of (Succ - Offset) represents the successor to node i. The
constraint enforces Succ to form a Hamiltonian path, a path through every
node in the graph, visiting each node once, with Start giving the first node
of the path, and End giving the last node of the path. Note that the
Succ of the last node will be N+1, i.e. a dummy node not in the graph.
Additionally, CostMatrix specifies the cost for traversing between
each pair of nodes: CostMatrix[i,j] represents the cost of
travelling from node i to j, and Cost is constrained to the total cost
for the path. The i'th element of ArcCosts is constrained to the cost of
the arc in the path from node i.

Note that the Gecode implementation of this constraint has index (node id)
starting from 0, rather than 1. The value of Offset is incremented by 1
when the constraint is posted to Gecode. A version of this constraint with
native Gecode indexing, i.e. without adjusting Offset, is available
as ham_path_offset_g/5.

This constraint can be embedded in a constraint expression in its
functional form (without the last argument).

ConsistencyModule is the optional module specification to give the
consistency level for the propagation for this constraint:
gfd_gac for generalised arc consistency (domain consistency),
and gfd_vc for value consistency.

This constraint is implemented by Gecode's path() constraint (variant with
cost and arc costs), using an offset of Offset + 1.

## See Also

ham_path_offset / 4, ham_path_offset / 6, ham_path_offset_g / 7