Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 10, 2024
1 parent 9876862 commit d4f2bb5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions examples/aco_tsp/aco_tsp/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from mesa.spaces import CellAgent, Network


@dataclass
class NodeCoordinates:
city: int
Expand Down Expand Up @@ -108,10 +109,11 @@ def calculate_pheromone_delta(self, q: float = 100):
def move_to(self, cell) -> None:
self._cities_visited.append(cell)
if self.cell:
self._traveled_distance += self.graph[self.cell.coordinate][cell.coordinate]["distance"]
self._traveled_distance += self.graph[self.cell.coordinate][
cell.coordinate
]["distance"]
super().move_to(cell)


def decide_next_city(self):
# Random
# new_city = self.random.choice(list(self.model.all_cities - set(self.cities_visited)))
Expand All @@ -125,8 +127,10 @@ def decide_next_city(self):
results = []
for city in candidates:
val = (
(self.graph[self.cell.coordinate][city.coordinate]["pheromone"]) ** self.alpha
* (self.graph[self.cell.coordinate][city.coordinate]["visibility"]) ** self.beta
(self.graph[self.cell.coordinate][city.coordinate]["pheromone"])
** self.alpha
* (self.graph[self.cell.coordinate][city.coordinate]["visibility"])
** self.beta
)
results.append(val)

Expand Down

0 comments on commit d4f2bb5

Please sign in to comment.