(int(0.5 / phasta.dt))), numpy.tile(phaseTarget, 20))) #negatively bias transition towards states 2-4 to block transition from state 1: #phasta.updateTransitionTriggerInput(bias) #evolve the system for some time for i in range(int(t1 / phasta.dt)): phasta.step() #set one of the gains to nonzero in order to activate the enslavement gains = [[0, 0., 0.], [80, 0., 0.], [0., 0., 0.]] phasta.updateVelocityEnslavementGain(gains) for i in range(int(t2 / phasta.dt)): phasta.updatePhasesInput(phaseTarget[i]) phasta.step() from matplotlib import pylab as plt plt.figure(figsize=(4, 2)) n = int((t2) / phasta.dt) plt.plot(numpy.linspace(t1, t1 + t2, n), phaseTarget[:n], linestyle=":", color="#AAAAAA") #plt.plot(numpy.linspace(t1, t1+t2, n), phasta.errorHistory[:n]) visualize(phasta, t1 + t2, sectionsAt=[t1], name=os.path.splitext(os.path.basename(__file__))[0], newFigure=False)
phasta.updateBiases([0.0, 0.0, -1e-7]) #alternative: specify the state to block in and project a blocking bias on all successors with the phasta.stateConnectivityMap phasta.updateBiases( numpy.dot(phasta.stateConnectivity, numpy.array([ 0.0, -1e-7, 0.0, ]))) #evolve the system for some time for i in range(int(t1 / phasta.dt)): phasta.step() #un-freeze the state by setting the bias back to non-negative values. # positive values will reduce the dwell-time considerably: phasta.updateBiases([0.0, 0.0, 1e-1]) # t2a = 0.1 for i in range(int(t2a / phasta.dt)): phasta.step() phasta.updateBiases([0.0, 0.0, 0.0]) # for i in range(int((t2 - t2a) / phasta.dt)): phasta.step() visualize(phasta, t1 + t2, sectionsAt=[t1, t1 + t2a], name=os.path.splitext(os.path.basename(__file__))[0])
predecessors = [ [17], #restart cycle from last state [0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0], #states that branch out from state 0 [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] #last state aggregates all branches ] phasta = phasestatemachine.Kernel( numStates = 18, predecessors = predecessors, recordSteps=100000, ) #set up biases so that we favor one out the 16 possible branches: import collections bias = collections.deque([0.0]*16) bias[0] = 1e-4 phasta.updateBiases([1e-4] + list(bias) + [0.0]) # endtime = 34.0 #run the kernel for some time: triggered=False for i in range(int(endtime/phasta.dt)): phasta.step() if phasta.statevector[-1] > 0.9 and not triggered: triggered = True bias.rotate(1) phasta.updateBiases([1e-4] + list(bias) + [0.0]) elif phasta.statevector[0] > 0.9: triggered = False visualize(phasta, endtime, name=os.path.splitext(os.path.basename(__file__))[0])
phasta.updateBiases([bias, bias, bias, bias]) phaseVelocityExponentsMatrix = [[0., 0., 0., 0.], [0., 0., -3., 0.], [0., 0., 0., 0.], [0., 0., -3., 0.]] phasta.updateTransitionPhaseVelocityExponentInput(phaseVelocityExponentsMatrix) timesToMark = [] #evolve the system for some time phasta.step(t1) timesToMark.append(phasta.t) phasta.updateBiases([bias, -100 * bias, bias, 100 * bias]) phasta.step(tspike) phasta.updateBiases([bias, bias, bias, bias]) timesToMark.append(phasta.t) phasta.step(t2) timesToMark.append(phasta.t) phasta.updateBiases([bias, -100 * bias, bias, 100 * bias]) phasta.step(tspike) phasta.updateBiases([bias, bias, bias, bias]) timesToMark.append(phasta.t) phasta.step(t3) visualize(phasta, phasta.t, sectionsAt=timesToMark, name=os.path.splitext(os.path.basename(__file__))[0])
epsilon=epsilon, recordSteps=100000, ) endtime = 50.0 #Variation: negatively bias transition towards states 2-4 to block transition from state 1: #phasta.updateTransitionTriggerInput([0, 1*epsilon, 0, 0]) Gamma = numpy.array([ [0, 1e-9, 0, 1e-9], [0, 0, 0, 0], [1e-4, 0, 0, 0], [0, 0, 0, 0], ]) noiseScale = 1e-4 * numpy.sqrt(dt) / dt #evolve the system for some time for i in range(int(endtime / phasta.dt)): Gamma[1, 2] = 3 * numpy.random.normal(scale=noiseScale) Gamma[3, 2] = 1 * numpy.random.normal(scale=noiseScale) bias = numpy.dot(Gamma, phasta.statevector) phasta.updateBiases(Gamma) phasta.step() visualize(phasta, endtime, name=os.path.splitext(os.path.basename(__file__))[0], clipActivations=0.05)