Skip to content

Commit aa69b2e

Browse files
authored
Merge pull request #29 from perrygeo/0.5release
0.5 release
2 parents 5405975 + be72c9c commit aa69b2e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 0.5.0
2+
- Allow move function to return energy delta for efficiency gains in some cases (#28)
3+
14
### 0.4.2
25
- Fix bug in load_state (#23)
36

examples/salesman.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import print_function
23
import math
34
import random
@@ -28,6 +29,8 @@ def move(self):
2829
a = random.randint(0, len(self.state) - 1)
2930
b = random.randint(0, len(self.state) - 1)
3031
self.state[a], self.state[b] = self.state[b], self.state[a]
32+
# no efficiency gain, just proof of concept
33+
return self.energy()
3134

3235
def energy(self):
3336
"""Calculates the length of the route."""
@@ -37,7 +40,6 @@ def energy(self):
3740
return e
3841

3942

40-
4143
if __name__ == '__main__':
4244

4345
# latitude and longitude for the twenty largest U.S. cities
@@ -79,7 +81,7 @@ def energy(self):
7981
distance_matrix[ka][kb] = distance(va, vb)
8082

8183
tsp = TravellingSalesmanProblem(init_state, distance_matrix)
82-
tsp.steps = 100000
84+
tsp.set_schedule(tsp.auto(minutes=0.2))
8385
# since our state is just a list, slice is the fastest way to copy
8486
tsp.copy_strategy = "slice"
8587
state, e = tsp.anneal()
@@ -89,5 +91,4 @@ def energy(self):
8991

9092
print()
9193
print("%i mile route:" % e)
92-
for city in state:
93-
print("\t", city)
94+
print(" ➞ ".join(state))

simanneal/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .anneal import Annealer
33

44
__all__ = ['Annealer']
5-
__version__ = "0.4.2"
5+
__version__ = "0.5.0"

0 commit comments

Comments
 (0)