Skip to content

[Bug] HC → StackerCrane reduction produces incorrect result #789

@isPANN

Description

@isPANN

Summary

The reduction HamiltonianCircuit → StackerCrane → ILP returns Or(false) on the prism graph, which has a valid Hamiltonian circuit. All other 2-step HC→ILP paths return Or(true).

Reproduction

pred create --example HamiltonianCircuit -o hc.json
pred reduce hc.json --to StackerCrane | pred solve -
# Returns Or(false) — should be Or(true)

The prism graph (6 vertices, 9 edges) has Hamiltonian circuit [0, 1, 4, 3, 5, 2].

Root cause

The StackerCrane solver returns Min(6) with solution [1, 2, 3, 0, 5, 4]. After extract_solution maps it back to HC, the same config [1, 2, 3, 0, 5, 4] is returned. However, this is not a valid Hamiltonian circuit — edges 2→3 and 0→5 do not exist in the prism graph:

  1 → 2  ✅
  2 → 3  ❌  (not an edge in prism graph)
  3 → 0  ✅
  0 → 5  ❌  (not an edge in prism graph)
  5 → 4  ✅
  4 → 1  ✅

This means either HC → StackerCrane reduce_to() constructs an incorrect StackerCrane instance, or extract_solution() incorrectly maps the StackerCrane solution back to HC.

Comparison with other paths

Path Result Solution Valid HC?
HC → HamiltonianPath → ILP Or(true) [0, 1, 4, 3, 5, 2]
HC → TravelingSalesman → ILP Or(true) [0, 1, 2, 5, 4, 3]
HC → RuralPostman → ILP Or(true) [0, 3, 5, 4, 1, 2]
HC → QuadraticAssignment → ILP Or(true) [0, 1, 2, 5, 4, 3]
HC → StrongConnectivityAugmentation → ILP Or(true) [0, 3, 5, 4, 1, 2]
HC → BottleneckTravelingSalesman → ILP Or(true) [0, 1, 2, 5, 4, 3]
HC → BiconnectivityAugmentation → ILP Or(true) [0, 2, 1, 4, 5, 3]
HC → StackerCrane → ILP Or(false) [1, 2, 3, 0, 5, 4]

Files to investigate

  • src/rules/hamiltoniancircuit_stackercrane.rsreduce_to() and extract_solution()
  • src/rules/stackercrane_ilp.rs — StackerCrane → ILP reduction

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions