create_tsp_qubo

create_tsp_qubo(cost_matrix, start_city=0, constraint_penalty=4.0, objective_weight=1.0, reduced=True)[source]

Generate a QUBO for TSP with a fixed start city.

Uses the standard node-ordering (assignment) encoding where binary variable x_{i,t} indicates that city i is visited at time step t. The start city is fixed, reducing the problem from to (n-1)² qubits.

By default the reduced phase operator from CE-QAOA (arXiv:2511.14296, Eq. 13) is used: row constraints (each time step has exactly one city) are omitted because they are enforced structurally by the W-state initialization and XY mixer. Only column constraints and the objective remain.

Parameters:
  • cost_matrix (ndarray[tuple[Any, ...], dtype[floating]]) – Symmetric (n × n) distance/cost matrix.

  • start_city (int) – Index of the fixed start/end city. Defaults to 0.

  • constraint_penalty (float) – Penalty strength for constraint violations.

  • objective_weight (float) – Weight for the objective function.

  • reduced (bool) –

    If True (default), omit row penalties — the correct choice when using CE-QAOA (W-state + XY mixer) since row one-hot constraints are enforced by the ansatz.

    Set to False only if you are using this QUBO with a standard QAOA ansatz (Hadamard init + X mixer) or any other method that does not structurally enforce row constraints. In that case both row and column penalties are included so the Hamiltonian alone encodes feasibility.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Returns:

Upper-triangular QUBO matrix of shape (m², m²) where m = n - 1, compatible with QUBOProblemTypes.

Raises:

ValueError – If cost_matrix is not square or start_city is out of range.