File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,10 @@ def step(self):
151
151
self ._traveled_distance = 0
152
152
153
153
154
+ # Don't create the TSPGraph.from_random as argument default: https://docs.astral.sh/ruff/rules/function-call-in-default-argument/
155
+ TSP_GRAPH = TSPGraph .from_random (20 )
156
+
157
+
154
158
class AcoTspModel (mesa .Model ):
155
159
"""The model class holds the model-level attributes, manages the agents, and generally handles
156
160
the global level of our model.
@@ -161,16 +165,12 @@ class AcoTspModel(mesa.Model):
161
165
162
166
def __init__ (
163
167
self ,
164
- tsp_graph : TSPGraph | None ,
165
168
num_agents : int = 20 ,
166
169
max_steps : int = int (1e6 ),
167
170
ant_alpha : float = 1.0 ,
168
171
ant_beta : float = 5.0 ,
172
+ tsp_graph : TSPGraph = TSP_GRAPH ,
169
173
):
170
- # Don't create the TSPGraph.from_random as argument default: https://docs.astral.sh/ruff/rules/function-call-in-default-argument/
171
- if tsp_graph is None :
172
- tsp_graph = TSPGraph .from_random (20 )
173
-
174
174
super ().__init__ ()
175
175
self .num_agents = num_agents
176
176
self .tsp_graph = tsp_graph
You can’t perform that action at this time.
0 commit comments