; Copyright (C) 2026 Postquant Labs Incorporated
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Affero General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU Affero General Public License for more details.
;
; You should have received a copy of the GNU Affero General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
;
; SPDX-License-Identifier: AGPL-3.0-or-later
; TSP decoder: extracts the ordered tour from an NxN sample.
;
; Input slots: [0] = sample (Model NxN), [1] = N (Int)
; Output slots: [0] = tour (VecInt, tour[p] = city at position p)
PUSH 0
INPUT r0
PUSH 1
INPUT r1
VECI r2
PUSH 0
LOAD r1
RANGE
LVAL r10
LOAD r10
PUSH 1
COLFIND r0
VECPUSH r2
NEXT
PUSH 0
OUTPUT r2
HALT