Author | Message |
---|---|
rmedina0531
Posts: 19
|
Posted 20:56 Apr 26, 2020 |
From what I can gather minimum_spanning_tree_links() returns a list of links that define the minimum spanning tree. It is a method what needs no arguments. Is anyone else having trouble calling the method? I am getting TypeError: minimum_spanning_tree_links() missing 1 required positional argument: 'self' when encountering the following line of code: spanning_tree = TSP_World.minimum_spanning_tree_links() |
tkitcha
Posts: 19
|
Posted 22:36 Apr 26, 2020 |
I believe that the error occurs when you are trying to call the method outside of its class. You can only access class variables when doing classname.varName, but to access class method, the class has to be instantiated like in this case x = TSP_World(). |
rabbott
Posts: 1649
|
Posted 22:48 Apr 26, 2020 |
The method |
rmedina0531
Posts: 19
|
Posted 23:38 Apr 26, 2020 |
Since we need to use the minimum spanning tree to find the tree path, and the path methods are in TSP_Chromosome, shouldn't we be able to access it from TSP_Chromosome by making minimum_spanning_tree_links() static? |
rabbott
Posts: 1649
|
Posted 08:17 Apr 27, 2020 |
You can change your copy if you prefer. Here's the current version. It's defined in
def minimum_spanning_tree_links(self):
if not self.msp_links:
self.msp_links = minimum_spanning_tree(list(GA_World.gene_pool))
return self.msp_links
The code that does the actual MSP computation is the Last edited by rabbott at
12:09 Apr 27, 2020.
|