Menu

Bifurcation Diagram Using Aux Variables

Help
Danny Wood
2016-06-24
2016-06-28
  • Danny Wood

    Danny Wood - 2016-06-24

    I'm trying to plot a bifurcation diagram for a single neuron recurrent neural network. At the moment, I'm plotting the diagram of b against x, but really want to plot b against y (a non-linear but monotonic transformation of x). When I try changing "PC.display(['b','x'], stability=True, figure=3) " to 'y' instead of 'x' I get a key error saying "Coordinate y is not defined". Is there an easy solution to this?

    import PyDSTool as dst
    import numpy as np
    from matplotlib import pyplot as plt
    
    DSargs = dst.args(name="Single Neuron Network")
    
    DSargs.pars = {
        'b' : -1,
        'w1' : 5
        }
    DSargs.fnspecs = {'sigm': (['t'], '1 / (1 + exp(-t))')}
    DSargs.varspecs = {'x': '-x + w1 * sigm(x) + b', 'w': 'x-w', 'y': 'sigm(x)'}
    DSargs.auxvars = ['y']
    DSargs.ics = {'x': -10, 'w':0}
    
    DSargs.tdomain = [-5,5]
    ode = dst.Generator.Vode_ODEsystem(DSargs)
    traj = ode.compute('polarization')
    pts = traj.sample(dt=0.1)
    
    plt.plot(pts['t'], pts['x'])
    plt.xlabel('time')                              
    plt.ylabel('voltage')                          
    plt.ylim([0,15])                              
    plt.title(ode.name)                          
    plt.show()
    
    ode.set(pars = {'b': -6} )  
    
    PC = dst.ContClass(ode)            
    
    PCargs = dst.args(name='EQ1', type='EP-C')    
    PCargs.freepars     = ['b']                  
    PCargs.MaxNumPoints = 250                   
    PCargs.MaxStepSize  = 1e-1
    PCargs.MinStepSize  = 1e-4
    PCargs.StepSize     = 1e-3
    PCargs.LocBifPoints = 'LP'                
    PCargs.SaveEigen    = True                 
    
    PC.newCurve(PCargs)
    PC['EQ1'].forward()
    PC.display(['b','x'], stability=True, figure=3)        
    
    plt.show()
    
     
  • Danny Wood

    Danny Wood - 2016-06-28

    The solution I have at the moment is to apply the sigmoid function to X[1,:] inside the continuation class (and apply it to the special points too). However, this is a pretty hacky solution, even after I clean it up a bit. Is there a way of doing this without having to change any PyDSTool files?

     

    Last edit: Danny Wood 2016-06-28
  • Drew LaMar

    Drew LaMar - 2016-06-28

    Hi, Danny. It's been awhile since I've taken a look at the code, but I'm pretty sure that auxvars are not updated during continuation, at least in a way that they are accessible. Your solution is in effect something similar to what I would do to add this functionality, i.e. evaluate auxvars during continuation and bifurcation point detection.

    Drew

     
  • Rob Clewley

    Rob Clewley - 2016-06-28

    Maybe what's best here, given our lack of resources, is for Danny to submit a PR for his code (with enough documentation for us to follow it) and we can attempt to clean it up as best as we can and make use of it.

     
  • Danny Wood

    Danny Wood - 2016-06-28

    Thanks both. I'll try to submit a PR in the next day or so.

     

Log in to post a comment.