GINsim / GINsim-python

Python bindings for GINsim and bioLQM
3 stars 2 forks source link

`ginsim.to_nusmv` fails with models with input nodes and initial state #6

Closed pauleve closed 3 years ago

pauleve commented 4 years ago

With v0.4.2 and ginsim 3.0.0b-12

import ginsim
lrg = ginsim.load("http://ginsim.org/sites/default/files/SuppMat_Model_Master_Model.zginml")
smv = ginsim.to_nusmv(lrg)

results in

---------------------------------------------------------------------------
Py4JError                                 Traceback (most recent call last)
<ipython-input-3-db31ebfcae7d> in <module>
----> 1 smv = ginsim.to_nusmv(lrg)

~/orga/projects/colomoto/GINsim-python/ginsim/__init__.py in to_nusmv(lrg, update_mode)
    183     sinit = japi.gs.associated(lrg, "initialState", True)
    184     for inputNode in sinit.getInputNodes():
--> 185         cfg.addFixedInput(str(inputNode))
    186 
    187     smvfile = new_output_file("smv")

~/.local/lib/python3.8/site-packages/py4j/java_gateway.py in __call__(self, *args)
   1302 
   1303         answer = self.gateway_client.send_command(command)
-> 1304         return_value = get_return_value(
   1305             answer, self.gateway_client, self.target_id, self.name)
   1306 

~/.local/lib/python3.8/site-packages/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
    328                     format(target_id, ".", name), value)
    329             else:
--> 330                 raise Py4JError(
    331                     "An error occurred while calling {0}{1}{2}. Trace:\n{3}\n".
    332                     format(target_id, ".", name, value))

Py4JError: An error occurred while calling o24.addFixedInput. Trace:
py4j.Py4JException: Method addFixedInput([class java.lang.String]) does not exist
    at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
    at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
    at py4j.Gateway.invoke(Gateway.java:274)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.lang.Thread.run(Thread.java:748)

The method addFixedInput is missing (disappeared?); moreover the behaviour of this NuSMV export with an initialState or input nodes should be documented (and possibly parameterised if relevant).

aurelien-naldi commented 3 years ago

I'm looking at this now, I see that indeed the method does not exist but it's not just a typo.

As the code does not set the initial state and the NuSMV export should already be capable of encoding the input nodes all by itself, it looks like this block of code is completely useless, but I miss the knowledge about why it was added in the first place.

@ptgm: do you know what happens here?

aurelien-naldi commented 3 years ago

Looking at GINsim's code history, it seems related to a refactoring of the NuSMV export 2 years ago.

I would propose to remove the failing code block for now and look for a way to set the initial state, preferably in bioLQM rather than GINsim but this would require some refactoring and we have little time for it in the near future.

pauleve commented 3 years ago

I'm all for removing code :-) So in case of input nodes, by default, the NuSMV export does not fix any value for them, right? It is fine if the export do not allow fixing some value for some variables in the NuSMV export, as soon as it is documented. Thus removing the code and adding a minimal docstring would do the job I think.

aurelien-naldi commented 3 years ago

Input nodes should have a positive self-regulation: they will keep their initial value. We may still need a way to set this initial value.