You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ERROR:
In tsp.py, the Hill Climbing algorithm, which is implemented by the method hill_climbing(self, problem, map_canvas) on line 281 attempts to reference an unknown method, argmax_random_tie(arg1, arg2) from the numpy module on line 297.
OUTPUT:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1884, in __call__
return self.func(*args)
File ".../aima-python/gui/tsp.py", line 112, in run_traveling_salesman
self.create_canvas(tsp_problem)
File ".../aima-python/gui/tsp.py", line 187, in create_canvas
self.hill_climbing(problem, map_canvas)
File ".../aima-python/gui/tsp.py", line 297, in hill_climbing
neighbor = np.argmax_random_tie(neighbors, key=lambda node: problem.value(node.state))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/__init__.py", line 315, in __getattr__
raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'argmax_random_tie'
EXPECTED BEHAVIOR:
When selecting the Hill Climbing algorithm in the GUI and starting the run, it should model the algorithm and provide the cost of the current route that is displayed on the Romanian map.
ACTUAL BEHAVIOR:
When selecting the Hill Climbing algorithm in the GUI and starting the run, nothing occurs and an error is thrown in the Python interpreter.
PROPOSED SOLUTION:
On line 297, change it from: neighbor = np.argmax_random_tie(neighbors, key=lambda node: problem.value(node.state))
to: neighbor = argmax_random_tie(neighbors, key=lambda node: problem.value(node.state))
so that it may reference the argmax_random_tie(seq, key) method in the utils.py package.
The text was updated successfully, but these errors were encountered:
k-le
changed the title
tsp.py | Hill climbing algorithm AttributeError - attempts to reference a method from numpy instead of utils.py
tsp.py | Hill climbing algorithm AttributeError - attempts to reference an unknown method from numpyMay 1, 2022
PYTHON VERSION:
Python 3.9
ERROR:
In
tsp.py
, the Hill Climbing algorithm, which is implemented by the methodhill_climbing(self, problem, map_canvas)
on line281
attempts to reference an unknown method,argmax_random_tie(arg1, arg2)
from thenumpy
module on line297
.OUTPUT:
EXPECTED BEHAVIOR:
When selecting the Hill Climbing algorithm in the GUI and starting the run, it should model the algorithm and provide the cost of the current route that is displayed on the Romanian map.
ACTUAL BEHAVIOR:
When selecting the Hill Climbing algorithm in the GUI and starting the run, nothing occurs and an error is thrown in the Python interpreter.
PROPOSED SOLUTION:
On line
297
, change it from:neighbor = np.argmax_random_tie(neighbors, key=lambda node: problem.value(node.state))
to:
neighbor = argmax_random_tie(neighbors, key=lambda node: problem.value(node.state))
so that it may reference the
argmax_random_tie(seq, key)
method in theutils.py
package.The text was updated successfully, but these errors were encountered: