Abcbc / CAS

0 stars 0 forks source link

recursion depth #25

Closed llueder closed 5 years ago

llueder commented 5 years ago

NewEdgesRule sometimes triggers a Recursion Error

2018-11-21 10:20:35,623:Rules -> DEBUG:applying AdaptationRule with parameters {} and internals {'opinionPair': {'edgeId': (1, 2), 'opinionIndex': 0}, 'nodePosToAdapt': 1, 'adaptionDecision': False}
2018-11-21 10:20:35,624:Rules -> DEBUG:applying OrientationConfirmationRule with parameters {'fallbackProbability': 0.5} and internals {'fallbackDecision': [True, True, True], 'fallbackSelection': [0, 0, 0], 'edgeId': (0, 2)}
2018-11-21 10:20:35,624:Rules -> DEBUG:NewNodeRule create internals
2018-11-21 10:20:35,624:Rules -> DEBUG:Community [0, 1, 2] was not selected. isDense: True, hasHighOrientation: False
2018-11-21 10:20:35,625:Rules -> DEBUG:NewEdgeRule add edges []
2018-11-21 10:20:35,625:Rules -> DEBUG:NewEdgeRule add edges []
2018-11-21 10:20:35,625:Rules -> DEBUG:applying AdaptationRule with parameters {} and internals {'opinionPair': {'edgeId': (0, 1), 'opinionIndex': 0}, 'nodePosToAdapt': 0, 'adaptionDecision': False}
2018-11-21 10:20:35,625:Rules -> DEBUG:applying AdaptationRule with parameters {} and internals {'opinionPair': {'edgeId': (1, 2), 'opinionIndex': 0}, 'nodePosToAdapt': 0, 'adaptionDecision': False}
2018-11-21 10:20:35,625:Rules -> DEBUG:applying OrientationConfirmationRule with parameters {'fallbackProbability': 0.5} and internals {'fallbackDecision': [True, False, False], 'fallbackSelection': [0, 1, 0], 'edgeId': (0, 2)}
2018-11-21 10:20:35,626:Rules -> DEBUG:NewEdgeRule add edges []
2018-11-21 10:20:35,626:Rules -> DEBUG:Found no edge with low orientation
2018-11-21 10:20:35,627:Rules -> DEBUG:applying OrientationConfirmationRule with parameters {'fallbackProbability': 0.5} and internals {'fallbackDecision': [True, True, True], 'fallbackSelection': [1, 0, 0], 'edgeId': (1, 2)}
2018-11-21 10:20:35,627:Rules -> DEBUG:Removing edge (1, 2) with low orientation
2018-11-21 10:20:35,627:Rules -> DEBUG:applying AdaptationRule with parameters {} and internals {'opinionPair': {'edgeId': (0, 1), 'opinionIndex': 0}, 'nodePosToAdapt': 0, 'adaptionDecision': False}
2018-11-21 10:20:35,627:Rules -> DEBUG:applying AdaptationRule with parameters {} and internals {'opinionPair': {'edgeId': (0, 1), 'opinionIndex': 0}, 'nodePosToAdapt': 0, 'adaptionDecision': True}
2018-11-21 10:20:35,627:Rules -> DEBUG:NewEdgeRule add edges []
2018-11-21 10:20:35,628:Rules -> DEBUG:Removing edge (0, 2) with low orientation
Traceback (most recent call last):
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/simulation.py", line 123, in <module>
    updater.update()
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/Updater.py", line 23, in update
    self.applyRule(ruleName)
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/Updater.py", line 32, in applyRule
    self.graph = self.rules[ruleName].apply(self.graph)
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/Rules.py", line 345, in apply
    self._prepareApply(graph, _parameters, _internals)
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/Rules.py", line 78, in _prepareApply
    self.internals = _internals if _internals is not None else  self._createInternals(graph)
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/Rules.py", line 332, in _createInternals
    edgeCandidates = self._addUnconnected(graph, nodeToConnect, [fixedNode])
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/Rules.py", line 320, in _addUnconnected
    edgesToAdd = self._addUnconnected(graph, nodeToConnect, checkedNeighbours)
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/Rules.py", line 320, in _addUnconnected
    edgesToAdd = self._addUnconnected(graph, nodeToConnect, checkedNeighbours)
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/Rules.py", line 320, in _addUnconnected
    edgesToAdd = self._addUnconnected(graph, nodeToConnect, checkedNeighbours)
  [Previous line repeated 988 more times]
  File "/home/lasse/Dokumente/Studium/CAS_WS1819/simulation/Rules.py", line 312, in _addUnconnected
    if len(list(nx.neighbors(graph,nodeToConnect))) == len(list(graph.nodes))-1:
  File "/usr/lib/python3.7/site-packages/networkx/classes/function.py", line 64, in neighbors
    return G.neighbors(n)
  File "/usr/lib/python3.7/site-packages/networkx/classes/graph.py", line 1249, in neighbors
    return iter(self._adj[n])
RecursionError: maximum recursion depth exceeded while calling a Python object

Process finished with exit code 1
llueder commented 5 years ago

Idea: recursion base cases not complete?

llueder commented 5 years ago

Supposed problem: In a disconnected graph, the recursion base case that the nodeToConnect is connected to all other nodes in the graph, never occurs. Solution: reimplement the function in f504ca18b04dab2f16f5dc64be5a779b0f6c4582