Skip to content

Division by zero in update_edge_distance() within tsp_gls_2O #59

@EricZheng1024

Description

@EricZheng1024

In gls.py, the penalty matrix is initialized to zero within the _guided_local_search() and _guided_local_search_with_time() functions.

However, when the default update_edge_distance() function (located in template.py and evaluation.py) is called, this penalty (passed as edge_n_used) is used as a denominator:

combined_factor = (1 / edge_n_used) + (1 / edge_n_used)

Since NumPy is used for these operations, it triggers the following warning:
RuntimeWarning: divide by zero encountered in divide

Perhaps the default update_edge_distance() function should handle cases where edge_n_used is zero to avoid these division-by-zero warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions