Skip to content
New issue

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

copy_state() returns None #18

Closed
matsulib opened this issue Aug 17, 2017 · 1 comment
Closed

copy_state() returns None #18

matsulib opened this issue Aug 17, 2017 · 1 comment

Comments

@matsulib
Copy link
Contributor

copy_state() returns None when self.copy_strategy is mistakenly set up.
Then the error message is not easy to understand.

For example, when I set tsp.copy_strategy = "copy" instead of "slice" in example/salesman.py,
the output was like this.

$ python examples/salesman.py
 Temperature        Energy    Accept   Improve     Elapsed   Remaining
Traceback (most recent call last):                 0:00:00
  File "examples/salesman.py", line 88, in <module>
    state, e = tsp.anneal()
  File "../simanneal/simanneal/anneal.py", line 192, in anneal
    self.move()
  File "examples/salesman.py", line 31, in move
    a = random.randint(0, len(self.state) - 1)
TypeError: object of type 'NoneType' has no len()

It took time to know where the 'NoneType' came from.

It would be useful if we can see the cause is tsp.copy_strategy.

@perrygeo
Copy link
Owner

fixed by #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants