Skip to content

Commit

Permalink
Upgraded tests for timelines and delete the generate landscape for bi…
Browse files Browse the repository at this point in the history
…g graphs
  • Loading branch information
vanoha01 committed Mar 25, 2024
1 parent 3c61a39 commit b663bf1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions experiments/genetic_landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def run_test(args):
# Number of iterations for each graph size
total_iters = 1
# Number of graph sizes
graphs = 10
graphs = 1
# Graph sizes
sizes = [30 * i for i in range(1, graphs + 1)]
sizes = [100 * i for i in range(1, graphs + 1)]
total_results = []
# Seed for random number generator can be specified here
# seed = 1
Expand Down
2 changes: 1 addition & 1 deletion sampo/generator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def set_materials_for_wg(self, wg: WorkGraph, materials_name: list[str] = None,
if top_border is None:
top_border = len(materials_name)

if bottom_border >= len(materials_name) or top_border >= len(materials_name):
if bottom_border > len(materials_name) or top_border > len(materials_name):
raise ValueError('The borders are out of the range of materials_name')

for node in wg.nodes:
Expand Down
8 changes: 3 additions & 5 deletions sampo/schemas/landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def dijkstra(node_ind: int):
continue
d = dist + road.weight
finish_ind = self._node2ind[road.finish]
if d < distances[finish_ind] and road.id in roads_available_set:
if d < distances[finish_ind]:
distances[finish_ind] = d
path_mx[node_ind][finish_ind] = v
heapq.heappush(prior_queue, (d, finish_ind))
Expand All @@ -184,13 +184,11 @@ def dijkstra(node_ind: int):
if path_mx[to_ind][from_ind] == -1:
return []

path_tmp = []
fr = from_ind
path = [from_ind]
while path_mx[to_ind][fr] != to_ind:
path_tmp.append(path_mx[to_ind][fr])
path.append(path_mx[to_ind][fr])
fr = path_mx[to_ind][fr]
path = [from_ind]
path.extend(path_tmp)
path.append(to_ind)
return [self.road_mx[path[v]][path[v + 1]] for v in range(len(path) - 1)]

Expand Down

0 comments on commit b663bf1

Please sign in to comment.