totalTime = dt.timedelta(0) totalNumberNodes = 0 N = 10 for i in range(N): numberNodes = 0 # Try 20 times to solve the problem and stop at first success t1 = dt.datetime.now() for i in range(20): try: subgoals = generateSubGoals(q0=q0, edges=edges) ps.clearRoadmap() ps.setInitialConfig(subgoals[0]) q_goal = subgoals[-1] ps.resetGoalConfigs() ps.addGoalConfig(q_goal) solve() ps.solve() n = ps.numberNodes() numberNodes += n solutions.append(ps.numberPaths() - 1) break except RuntimeError: n = ps.numberNodes() numberNodes += n t2 = dt.datetime.now() totalTime += t2 - t1 print(t2 - t1) print("Number nodes: " + str(n)) totalNumberNodes += numberNodes
import datetime as dt totalTime = dt.timedelta (0) totalNumberNodes = 0 N = 20 for i in range (N): numberNodes = 0 # Try 20 times to solve the problem and stop at first success t1 = dt.datetime.now () for i in range (20): try: subgoals = generateSubGoals (q0 = q0, edges = edges) ps.clearRoadmap () ps.setInitialConfig (subgoals [0]) q_goal = subgoals [-1] ps.resetGoalConfigs () ps.addGoalConfig (q_goal) solve () ps.solve () n = ps.numberNodes () numberNodes += n solutions.append (ps.numberPaths () -1) break; except RuntimeError: n = ps.numberNodes () numberNodes += n t2 = dt.datetime.now () totalTime += t2 - t1 print (t2-t1) print ("Number nodes: " + str(n)) totalNumberNodes += numberNodes