File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,10 @@ def step(self):
151151 self ._traveled_distance = 0
152152
153153
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+
154158class AcoTspModel (mesa .Model ):
155159 """The model class holds the model-level attributes, manages the agents, and generally handles
156160 the global level of our model.
@@ -161,16 +165,12 @@ class AcoTspModel(mesa.Model):
161165
162166 def __init__ (
163167 self ,
164- tsp_graph : TSPGraph | None ,
165168 num_agents : int = 20 ,
166169 max_steps : int = int (1e6 ),
167170 ant_alpha : float = 1.0 ,
168171 ant_beta : float = 5.0 ,
172+ tsp_graph : TSPGraph = TSP_GRAPH ,
169173 ):
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-
174174 super ().__init__ ()
175175 self .num_agents = num_agents
176176 self .tsp_graph = tsp_graph
You can’t perform that action at this time.
0 commit comments