LEMS / jLEMS

Java Interpreter for the Low Entropy Model Specification language
https://docs.neuroml.org/Userdocs/Software/jLEMS.html
MIT License
8 stars 10 forks source link

EventPorts without EventOut not regarded #86

Open kperun opened 7 years ago

kperun commented 7 years ago

I am not quite sure if it is a bug or intended behavior, but whenever we utilize an out EventPort in our model without the corresponding EventOut directive, this port seems not to be further regarded during the simulation. For example, if we define an explicit input (e.g. ), it is required to have an output port in the target model. If this model provides an out-port, but without a corresponding eventout directive, this port can not be further used. By debugging jLEMS I somehow tried to locate the problem: In core/run/WithBuilder, there is a method called postBuild() which is used to retrieve the source and target by the path. However, the component returned as source/target does not contain any output ports (if no out directive is stated), therefore the overall process stops with an nullpoint exception given the fact, that no output port can be found.

I am fully aware that we can avoid this problem by simply stating an event-out directive, but this can result in other problems, e.g. when components communicate between each other.

pgleeson commented 7 years ago

Thanks for that @kosti1992. I think this error is related to these issues in Inputs.xml: https://github.com/NeuroML/NeuroML2/blob/development/NeuroML2CoreTypes/Inputs.xml#L321, where an <EventPort> is required on a non event based input ComponentType. Again here it's not preventing correct behaviour having these extra statements here, bu may cause trouble for others wishing to use LEMS.

Do you have some example code that can help to see what the underlying issue is?

kperun commented 7 years ago

Hello Padraig, sorry for the quite delayed response. I have tried to debug it once more to identify the problem. The parsing and building of the model seems to work fine, however, somehow the attribute "firstOut" located in the StateInstance class is never assigned if no EventOut directive is located in the model, which results from the fact that the "newInstance()" method of the StateType class, where a for-each loop iterates over an array of "outPorts", does not have any out ports. This, again, results from the fact that in the "fix()" method of the StateType class, in lines 685-688, a loop iterates over all conditional blocks. If no EventOut directive is found in some of these blocks, no out-port is added, which consequently leads to problems in "postBuild()" method of the EventConnectionBuilder class (35-141), where in lines 86-94 the routine tries to find an output port. However, since no port is set, it is not possible to determine the target, which results in an exception.

A possible fix can be to use all out-eventports regardless if there is a event out directive or not, i.e. by not only iterating over the action blocks, but also inspect ports defined in the model. However,
I do not have a in-depth understanding of the system, therefore this fix is just a guess.

I tried to create a fix on model level (i.e. by modifying the explicitInput connection type , link ) but nothing came out of it, therefore I think this problem can only be solved in the interpreter implementation.

Greetings,

Konstantin