Menu

IndexError: list index out of range

Help
2014-08-21
2014-08-22
  • Maurizio De Pitta'

    Dear all,
    I launched over the night a long continuation of an EP-C type backward up to the lower bound of the free bifurcation parameter.

    Once checking the result in the morning I got the following error.
    I am not sure it is a bug or I set MaxNumPoints in my PyCont args too high.

    It is perhaps informative to know that the message:

    "Test function going crazy:  class Hopf_Bor(BorderMethod, BiAltMethod)"
    
    (was printed about 9 times before the warning and error were issued)
    
    /usr/lib64/python2.7/site-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the 
      improvement from the last ten iterations.
      warnings.warn(msg, RuntimeWarning)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 540, in runfile
        execfile(filename, namespace)
      File "/home/maurizio/Downloads/chain3.py", line 76, in <module>
        PC['EQ1'].backward()
      File "PyDSTool/PyCont/Continuation.py", line 1337, in backward
        self._compute(v0=self.initdirec, direc=-1)
      File "PyDSTool/PyCont/Continuation.py", line 1192, in _compute
        if self.BifPoints != {} and self._checkForBifPoints():
      File "PyDSTool/PyCont/Continuation.py", line 532, in _checkForBifPoints
        found = bfinfo.process(Xval, Vval, self)
      File "PyDSTool/PyCont/BifPoint.py", line 219, in process
        V1 = real(VR[:,W0[0]])
    IndexError: list index out of range
    

    It seems that there is an internal control mechanism that prevents the continuation from running to infinity without getting convergence. But then this would conflict with an MX point...

    I am afraid I don't understand the cause.
    Thanks for your patience.

    M

     

    Last edit: Maurizio De Pitta' 2016-09-22
  • Drew LaMar

    Drew LaMar - 2014-08-21

    Hi, Maurizio. I know EXACTLY where this error is coming from. Essentially, to calculate normal form coefficients for bifurcation points, we need to find zero eigenvalues. The issue here is that numerically we need a threshold to define what zero really means. This is currently hard-coded to 5e-5 (BifPoint.py, line 218, right above the error - don't ask me why 5e-5 :). Note that once a bifurcation point is detected between two continuation points, a separate routine using optimize.fsolve is called to converge closer to the detected point. This routine does not have a threshold based on the eigenvalues, however, so the resulting bifurcation point might have a "zero" eigenvalue that is an undetermined amount away from 0. Hope that made sense.

    There are a couple of ways to deal with this, but the fact that your continuation is taking a long time to compute makes (1) a little less feasible:

    (1) (Hack fix #1) I usually set a breakpoint at line 218 in BifPoint.py and look at the eigenvalues, adjusting the threshold so an exception is not thrown.
    (2) (Hack fix #2) I could implement a "double the threshold until it works" type approach.
    (3) (Sad fix) You could turn off branch points. These have caused trouble in the past, and I haven't revisited the algorithm to be confident that it is working properly (see notes in beginning of Continuation.py) If you don't need to be detecting branch points, the easiest thing to do is just remove them from your locating list.
    (4) (Happy short-term proper fix) Based on the "The iteration is not making good progress..." output, it sounds like optimize.fsolve is having trouble. In this case, it should "abandon ship" and ignore this potential bifurcation point (throwing a warning, of course), and therefore not call the process method.
    (4) (Happy long-term proper fix) The longer term solution is for me to go over the code again and make sure branch point detection is working as it should.

    Sorry for the wall of text! I'm just getting back to being active with PyCont development, so I'm having to "talk" a lot of this out. By the way, I have a rather active fork of PyDSTool where all of the PyCont development is being done. Feel free to clone that fork and work with it if you feel brave enough. I'm not sure how long it will take between my fixes and merging with the main repo, so if you want up-to-the-minute bug fixes and enhancements, clone away.

    EDIT: BTW, when I say the code "should" do something in my text above, I mean that it currently doesn't but it should, not that it does and it currently isn't.

    Drew

     

    Last edit: Drew LaMar 2014-08-21
  • Maurizio De Pitta'

    Hi Drew,
    thanks for the nice explanation :)
    In my case the "sad" fix is not an option, because, indeed my curve is expected to have some branch points and I will need to continue further branches from these latter eventually.

    I will try for now to use a less stringent threshold (... perhaps providing the user the option to set this threshold could also be a temporary fast workaround before the "happy long-term fix").

    I would be glad to help with PyCont dev, but right now I am afraid that my Python skills are still limited and I bet that the best contribution I can give for now, is to provide you with a "flow" of questions while I am testing PyDSTool.

    M

     

    Last edit: Maurizio De Pitta' 2014-08-22
  • Drew LaMar

    Drew LaMar - 2014-08-22

    Your "flow" of questions have been invaluable! So thank you for that.

    I wasn't implying that you ought to be contributing to the code, just that I'm actively working on a different fork that you might want to use since it will be updated most frequently with PyCont bug fixes and enhancements. Feel free to contribute if you want, however! :) Rob just pulled my most recent fixes into the main repo on github, so right now the main fork has all fixes that my fork has.

    I will keep you posted on any changes to this portion of the code.

    Drew

     

Log in to post a comment.