Menu

#16 Invalid firing of random transition

closed
None
5
2007-05-03
2007-04-12
derbeth
No

Firing a random transition in a Petri net containing one place (without any tokens) with a self loop causes IndexOutOfBoundsException.

The cause is error in DataLayer.java. First of all, transitionNo is used both as loop iteration variable and control variable - which is violation of basic programming rules. Even if it weren't used in for loop in line 1307, it would not work. transitionNo variable is initialized to 0, whereas in line 1349 it is compared with value -1. When there are no active transitions in initial markup, program would not enter if statement in line 1334 and therefore transitionNo will always have value equal number of all transitions plus one (value after exiting for-loop).

Discussion

  • Dave Patterson

    Dave Patterson - 2007-04-30
    • assigned_to: nobody --> patterd
     
  • Dave Patterson

    Dave Patterson - 2007-05-03
    • status: open --> closed
     
  • Dave Patterson

    Dave Patterson - 2007-05-03

    Logged In: YES
    user_id=1609637
    Originator: NO

    This bug is now fixed. Three source files were corrected -- Animator.java, DataLayer.java, and Simulation.java. The error described in this bug report (no tokens in a net) leads to an IndexOutOfBounds. The code now handles this kind of situation in both Animation and Simulation modes. Another way to have no transitions available to fire is caused by having a rate on a transition that is less than one. In this case, the code did not throw an exception, but it looped forever in the Simulation mode. Now, error messages are placed into the StatusBar at the bottom of the screen. In the case where the rate is less than one, a RuntimeException is thrown since a net like this is unusable for analysis given the current state of the code.

     

Log in to post a comment.

Auth0 Logo