#import the phase-state-machine package
import phasestatemachine

#import code shared across all examples
from common_code import visualize

#Set up the state transition map as a list of predecessors for each state:
predecessors = [
    [2],
    [0],
    [1],
]

phasta = phasestatemachine.Kernel(
    numStates=3,
    predecessors=predecessors,
    recordSteps=100000,
)

#phasta.updateTransitionTriggerInput(1e-10)

#phaseVelocityExponentsMatrix = [[0., 0., -2.],[-2,0,0.],[0., -2., 0.]]
#phasta.updateTransitionPhaseVelocityExponentInput(phaseVelocityExponentsMatrix )

t1 = 3.5
t2 = 11.5
phaseTarget = numpy.linspace(0, 1.0, int(2.0 / phasta.dt))
phaseTarget = numpy.hstack((numpy.zeros(
    (int(0.5 / phasta.dt))), numpy.tile(phaseTarget, 20)))

#negatively bias transition towards states 2-4 to block transition from state 1:
예제 #2
0
alpha= 10.0
n_streamlines=20
streamline_length=151
spread=0.1
startpoint = array([1.0, 0.0, 0.0, 0.0])

urgency = 0.0
plot_dt = 0.01 #time base of plots
cull = 2  #how many steps to simulate in between plot points / within plot_dt?

phasta = phasestatemachine.Kernel(
    alpha = alpha,
    nu=1.0,
    numStates = 4,
    dt=plot_dt / cull,
    epsilon=0e-5,
    successors = successors,
    inputFilterTimeConstant=0.0, #important, so that state doesn't leak across plots...
    recordSteps = 10000,
)

combinations = (('p_pp',1,1,1),('p_pn',1,1,-1),('p_np',1,-1,1),('p_nn',1,-1,-1),('n_pp',-1,1,1),('n_pn',-1,1,-1),('n_np',-1,-1,1),('n_nn',-1,-1,-1))
#combinations = (('p_pn',1,1,-1),)
greedinesses_totest = ([1.0,0.17,0.17,1.0],[1.0,3.2,0.37,1.0])

for i, greedinesses in enumerate(greedinesses_totest):
  for name, sign0, sign1, sign2 in combinations:
  
    #enforce certain transition signs:
    phasta.stateConnectivitySignMap[1,0] = sign1*sign0
    phasta.stateConnectivitySignMap[2,0] = sign2*sign0
                name))
        plt.savefig(
            "./figures/bidirectionaledges_streamlines_{}_filled.png".format(
                name),
            dpi=600)
        print("plotted {}".format(name))
        plt.close()


#import the phase-state-machine package
import phasestatemachine

phasta = phasestatemachine.Kernel(
    alpha=20.0,
    numStates=2,
    dt=0.01,
    epsilon=1e-3,
    successors=[[1], [0]],
    recordSteps=10000,
)

#phasta.rhoDelta[0,1] =  phasta.rhoDelta[1,0]
#phasta.stateConnectivity[0,1] = 1
#phasta.stateConnectivity[1,0] = -1

#print(phasta.rhoDelta)
#print(phasta.stateConnectivity)
#print(phasta.stateConnectivityGreedinessTransitions)
#print(phasta.stateConnectivity+phasta.stateConnectivityGreedinessTransitions)

plot_streamlines_2d(phasta, name="pos1")
#import code shared across all examples
from common_code import visualize

#Set up the state transition map as a list of predecessors for each state:
predecessors = [
    [1, 3],
    [2],  #state to stop in
    [0],
    [2],
]
epsilon = 1e-6

phasta = phasestatemachine.Kernel(
    numStates=4,
    predecessors=predecessors,
    epsilon=epsilon,
    nu=7.,
    recordSteps=100000,
)

t1 = 4.0
tspike = 1.0
t2 = 3.5
t3 = 2.0

#Variation: negatively bias transition towards states 2-4 to block transition from state 1:
bias = 1e-3
phasta.updateBiases([bias, bias, bias, bias])

phaseVelocityExponentsMatrix = [[0., 0., 0., 0.], [0., 0., -3., 0.],
                                [0., 0., 0., 0.], [0., 0., -3., 0.]]
from common_code import *

from numpy import *
from matplotlib.pylab import *
from mpl_toolkits.mplot3d import Axes3D

#import the phase-state-machine package
import phasestatemachine

predecessors = [[2], [0], [1]]
phasta = phasestatemachine.Kernel(
    alpha=10.0,
    nu=1.0,
    numStates=3,
    dt=0.01,
    epsilon=1e-6,
    predecessors=predecessors,
    recordSteps=10000,
)

visualizeWithStreamlines(phasta,
                         "example_3states",
                         spread=0.08,
                         n_streamlines=100,
                         azimut=20,
                         elevation=30,
                         streamline_width=0.3,
                         streamline_alpha=0.3,
                         streamline_length=60,
                         coloration_strides=1)