#' @tags pkg-TSP
if (requireNamespace("TSP") && requireNamespace("doFuture")) {
library(futurize)
library(TSP)
options(future.rng.onMisuse = "error")

plan(multisession)

data("USCA50")

RNGkind("L'Ecuyer-CMRG")

set.seed(42)
y_truth <- solve_TSP(USCA50, method = "nn", rep = 10L)
print(y_truth)

set.seed(42)
y <- solve_TSP(USCA50, method = "nn", rep = 10L) |> futurize_and_verify()
print(y)

set.seed(42)
y2 <- solve_TSP(USCA50, method = "nn", rep = 10L) |> futurize_and_verify()
print(y2)
stopifnot(all.equal(y2, y))

plan(sequential)

set.seed(42)
y3 <- solve_TSP(USCA50, method = "nn", rep = 10L) |> futurize_and_verify()
print(y3)
stopifnot(all.equal(y3, y))

} ## if (requireNamespace("TSP"))
