Skip to content

solve_tsp_record_to_record reachers Infinite loop with a simple example #53

Closed

Description

@yang-tsao

When I try to run the following code, it just keeps running and won't give me a result.

from python_tsp.heuristics import solve_tsp_record_to_record
import numpy as np

dis = np.array([[0, 1], [1, 0]])
[order, dist] = solve_tsp_record_to_record(dis)
print(order)
print(dist)

Activity

  1. added
    bug
    on Apr 5, 2024
  2. fillipe-gsm commented on Apr 5, 2024

    @fillipe-gsm
    Owner

    Hey, @yang-tsao , thanks for reporting it.

    The bug actually happens in the solve_tsp_lin_kernighan solver, which the Record to Record uses as internal solver.

    I opened a draft pull request with a test replicating the problem, and I'll leave the fix for @luanleonardo.

    Since this is a veeery corner case (a TSP with only two nodes), if he cannot take it I'll just put an early return.

  3. luanleonardo commented on Apr 8, 2024

    @luanleonardo
    Collaborator

    @yang-tsao @fillipe-gsm, the Lin-Kernighan heuristic assumes the existence of at least 4 nodes (named a, b, c, d) that play important roles in defining the neighborhood of a solution. If the problem is small, with less than 4 nodes, the heuristic does not apply.

  4. added a commit that references this issue on Apr 8, 2024
  5. fillipe-gsm commented on Jul 12, 2024

    @fillipe-gsm
    Owner

    Sorry for the long delay, but the issue should be fixed now in version 0.4.2.

    Thanks for reporting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions