Skip to content

[Model] MinimumStackerCrane #245

@isPANN

Description

@isPANN

name: Problem
about: Propose a new problem type
title: "[Model] MinimumStackerCrane"
labels: model
assignees: ''

Motivation

STACKER-CRANE (P102) from Garey & Johnson, A2 ND26. A classical NP-hard problem on mixed graphs (containing both directed arcs and undirected edges). It generalizes the Traveling Salesman Problem to settings where certain traversals must follow a prescribed direction, modeling pickup-and-delivery routing scenarios. The problem is a target of the following reduction:

  • R47: HAMILTONIAN CIRCUIT → MINIMUM STACKER-CRANE (ND26, Frederickson, Hecht, and Kim, 1978)

Definition

Name: MinimumStackerCrane
Canonical name: STACKER-CRANE (also: Stacker Crane Problem, SCP)
Reference: Garey & Johnson, Computers and Intractability, A2 ND26

Mathematical definition:

INSTANCE: Mixed graph G = (V, A, E), length l(e) ∈ Z₀⁺ for each e ∈ A ∪ E.
OBJECTIVE: Find a closed walk in G that includes each directed arc in A at least once, traversing such arcs only in the specified direction, and that has minimum total length.

Variables

  • Count: The solution is encoded as a walk sequence of length L = |A| + |E|. Each variable selects the next vertex to visit from the current position.
  • Per-variable domain: Each variable ranges over {0, 1, ..., |V| − 1}, selecting the next vertex in the walk.
  • Dims: [num_vertices; num_arcs + num_edges]
  • Meaning: The variable assignment encodes a closed walk (cycle) in the mixed graph. A valid walk (1) traverses every directed arc in A at least once, respecting arc directions, (2) uses only existing edges/arcs between consecutive vertices, and (3) returns to the starting vertex. The objective is to minimize the total traversal length.
  • evaluate(): For a given vertex sequence, check that each consecutive pair is connected by an edge or arc (respecting arc direction), all directed arcs are covered, and the walk is closed. If valid, return SolutionSize::Valid(total_length). If invalid (missing connection, uncovered arc, or not closed), return SolutionSize::Invalid.

Schema (data type)

Type name: MinimumStackerCrane
Variants: variant_params![] (no type parameters — mixed graph is a unique input structure)

Field Type Description
vertices usize Number of vertices |V|
arcs Vec<(usize, usize)> Directed arcs A: list of (from, to) pairs
edges Vec<(usize, usize)> Undirected edges E: list of {u, v} pairs
arc_lengths Vec<i32> Length of each directed arc (non-negative)
edge_lengths Vec<i32> Length of each undirected edge (non-negative)

Size fields:

  • num_vertices → number of vertices |V|
  • num_arcs → number of directed arcs |A|
  • num_edges → number of undirected edges |E|

Notes:

  • This is an optimization problem: Metric = SolutionSize<i32>, Direction = Minimize, implementing OptimizationProblem.
  • The mixed graph structure distinguishes it from pure undirected (TSP, Chinese Postman) or pure directed problems.
  • Specializations: remains NP-complete even with all edge lengths equal to 1 (GJ comment). Also NP-hard on trees (Frederickson and Guan, 1993).

Complexity

  • Best known exact algorithm: Held-Karp-style dynamic programming tracking (current vertex, set of arcs covered so far). The DP state space depends on |A|: O(|V| · 2^|A|) states, each taking O(|V|) time, giving O(|V|² · 2^|A|) total time and O(|V| · 2^|A|) space. When |A| ≈ |V|, this is O(num_vertices² · 2^num_arcs).
  • Complexity expression: num_vertices^2 * 2^num_arcs
  • NP-completeness: NP-complete (Frederickson, Hecht, and Kim, 1978, via transformation from Hamiltonian Circuit).
  • Approximation: 9/5-approximation algorithm based on the Christofides algorithm (Frederickson, Hecht, and Kim, 1978).
  • Special cases: Polynomial-time solvable when the underlying graph is a path. NP-hard on trees (Frederickson and Guan, 1993).
  • References:
    • G. N. Frederickson, M. S. Hecht, C. E. Kim (1978). "Approximation algorithms for some routing problems." SIAM Journal on Computing 7(2):178–193.
    • G. N. Frederickson (1979). "Approximation algorithms for some postman problems." JACM 26(3):538–554.
    • G. N. Frederickson, D. J. Guan (1993). "Nonpreemptive ensemble motion planning on a tree." Journal of Algorithms 15(1):29–60.

Extra Remark

Full book text:

INSTANCE: Mixed graph G = (V,A,E), length l(e) ∈ Z_0^+ for each e ∈ A ∪ E, bound B ∈ Z^+.
QUESTION: Is there a cycle in G that includes each directed edge in A at least once, traversing such edges only in the specified direction, and that has total length no more than B?
Reference: [Frederickson, Hecht, and Kim, 1978]. Transformation from HAMILTONIAN CIRCUIT.
Comment: Remains NP-complete even if all edge lengths equal 1. The analogous path problem (with or without specified endpoints) is also NP-complete.

Note: The original G&J formulation is a decision problem with bound B. This codebase models the optimization version (minimize total cycle length) since the optimization formulation subsumes the decision version and is more natural for reductions.

How to solve

  • It can be solved by (existing) bruteforce — enumerate all walk sequences and check feasibility + total length.
  • It can be solved by reducing to integer programming.
  • Other: Held-Karp-style DP in O(|V|² · 2^|A|) time tracking (current vertex, covered arcs). The 9/5-approximation of Frederickson et al. is practical for larger instances. The standard ILP formulation uses edge/arc multiplicity variables with flow-conservation constraints.

Example Instance

Instance (5 vertices, 3 arcs, 4 edges):

Mixed graph G with 5 vertices {0, 1, 2, 3, 4}:

  • Directed arcs A: (0→1) len=2, (3→2) len=3, (4→0) len=1
  • Undirected edges E: {1,2} len=1, {1,3} len=4, {2,4} len=2, {0,3} len=5
    arc(0→1, len=2)    edge{1,3, len=4}
  0 ─────────→ 1 ─────────── 3
  ↑                          │
  │ arc(4→0, len=1)    arc(3→2, len=3)
  │                          ↓
  4 ──────────────────────── 2
       edge{2,4, len=2}

  (also: edge{1,2, len=1} and edge{0,3, len=5})

Dims: [5; 7] — walk sequences of length 7, each step choosing from 5 vertices.
BF search space: 5⁷ = 78,125 configurations.

Optimal walk (length 12):

  • Config: [0, 1, 3, 2, 4, 0, 0]
  • Walk: 0 →(arc,2)→ 1 →(edge,4)→ 3 →(arc,3)→ 2 →(edge,2)→ 4 →(arc,1)→ 0
  • Total length: 2 + 4 + 3 + 2 + 1 = 12
  • All 3 directed arcs traversed in correct direction ✓
  • Closed walk (returns to vertex 0) ✓

Suboptimal walk (length 17):

  • Walk: 0 →(arc,2)→ 1 →(edge,1)→ 2 →(edge,2)→ 4 →(arc,1)→ 0 →(edge,5)→ 3 →(arc,3)→ 2 →(edge,2)→ 4 →(arc,1)→ 0
  • Total length: 2 + 1 + 2 + 1 + 5 + 3 + 2 + 1 = 17
  • The detour through edge {0,3} (len=5) to reach vertex 3 costs much more than the direct edge {1,3} (len=4) from vertex 1.

Key insight: At vertex 1, there is a routing choice — go directly to vertex 3 via edge {1,3} (len=4), or go through vertex 2 first via edge {1,2} (len=1), which forces a costly detour through edge {0,3} (len=5) to eventually reach the mandatory arc (3→2). The optimal route takes the direct path to vertex 3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoodAn issue passed all checks.modelA model problem to be implemented.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions