# Add nodes net.add_node(name='a') net.add_node(name='b') net.add_node(name='c') net.add_node(name='d') # Add edges net.add_edge(Edge(start='a', end='b', phase=1, attenuation=0.8, delay=1)) net.add_edge(Edge(start='b', end='c', phase=2, attenuation=0.6, delay=2)) net.add_edge(Edge(start='b', end='d', phase=3, attenuation=0.4, delay=3)) # Add input net.add_input(name='a', amplitude=1.0, phase=0) # Visualize the network net.visualize(path='./visualizations/feedforward', format='svg') # Evaluate the network net.evaluate(amplitude_cutoff=1e-3) # Compute output and show results print('paths leading to c:', net.get_paths('c')) print('paths leading to d:', net.get_paths('d')) print('waves arriving at c:', net.get_result('c')) print('waves arriving at d:', net.get_result('d')) print('latex string for waves arriving at c:', net.get_latex_result('c')) # render output in a html file net.get_html_result(['c', 'd'], precision=2, path='./visualizations/feedforward.html')
net.add_node(node) for edge in edges: net.add_edge(edge) net.add_input('a', amplitude=1.0) for edge in net.edges: edge.attenuation = 0.75 edge.phase = np.random.uniform(0, 2 * np.pi) net.visualize(path='./visualizations/mediumexample') #### # Evaluate Network #### net.evaluate(amplitude_cutoff=1e-3, max_endpoints=1e6) #### # Print and plot #### for node in net.nodes: print('number of paths to ' + node + ':', len(net.get_paths(node))) print('final path to a added:', net.get_paths('a')[-1]) net.print_stats() phases = np.asarray([val[1] for val in net.get_result('a')]) phases = phases % 2 * np.pi amplitudes = np.asarray([val[0] for val in net.get_result('a')]) plt.hist(phases, weights=amplitudes, bins=30) plt.title("amplitude weighted, binned phase contributions to a") plt.ylabel('amplitude') plt.xlabel('phase') plt.show()
for node in nodes: net.add_node(node) for edge in edges: net.add_edge(edge) net.add_input('a', amplitude=1.0) net.visualize(path='./visualizations/symbolicrecurrent') #### # Evaluate Network #### net.evaluate(amplitude_cutoff=1e-2, max_endpoints=1e6, use_shared_default=False) print('paths leading to a:', net.get_paths('a')) waves = [ tuple([w.eval() if hasattr(w, 'eval') else w for w in inner]) for inner in net.get_result('a') ] print('waves arriving at a:', waves, '\n') net.print_stats() #### # Inserting variable values ### waves = [ tuple([ w.eval(feed_dict={ 'amp1': .5, 'ph1': .2