We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
D = [[ 0, 60, 66, 258, 256, 682, 770, 888], [ 60, 0, 50, 225, 213, 630, 719, 832], [ 66, 50, 0, 275, 260, 618, 707, 829], [258, 225, 275, 0, 52, 689, 772, 840], [256, 213, 260, 52, 0, 637, 719, 789], [682, 630, 618, 689, 637, 0, 88, 245], [770, 719, 707, 772, 719, 88, 0, 181], [888, 832, 829, 840, 789, 245, 181, 0]]
from tspy import TSP tsp = TSP()
tsp.read_mat(D)
from tspy.solvers import TwoOpt_solver two_opt = TwoOpt_solver(initial_tour='NN', iter_num=100) two_opt_tour = tsp.get_approx_solution(two_opt)
The code does not exceute and gives the following error: TypeError: list indices must be integers or slices, not tuple
The text was updated successfully, but these errors were encountered:
The problem is that read_mat takes a numpy matrix as argument (this is mentioned in the docs). If you replace the first line by
read_mat
import numpy as np D = np.array([[...],...,[...]], np.float64)
the code runs as expected.
Sorry, something went wrong.
No branches or pull requests
D = [[ 0, 60, 66, 258, 256, 682, 770, 888],
[ 60, 0, 50, 225, 213, 630, 719, 832],
[ 66, 50, 0, 275, 260, 618, 707, 829],
[258, 225, 275, 0, 52, 689, 772, 840],
[256, 213, 260, 52, 0, 637, 719, 789],
[682, 630, 618, 689, 637, 0, 88, 245],
[770, 719, 707, 772, 719, 88, 0, 181],
[888, 832, 829, 840, 789, 245, 181, 0]]
from tspy import TSP
tsp = TSP()
tsp.read_mat(D)
from tspy.solvers import TwoOpt_solver
two_opt = TwoOpt_solver(initial_tour='NN', iter_num=100)
two_opt_tour = tsp.get_approx_solution(two_opt)
The code does not exceute and gives the following error:
TypeError: list indices must be integers or slices, not tuple
The text was updated successfully, but these errors were encountered: