Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config setting causes RuntimeError: bad variant access #991

Open
kirichoi opened this issue Apr 20, 2022 · 4 comments
Open

Config setting causes RuntimeError: bad variant access #991

kirichoi opened this issue Apr 20, 2022 · 4 comments

Comments

@kirichoi
Copy link

Hi all,

Today I have been fiddling with the latest libroadrunner release and found that whenever I try to configure parameters using something like:

roadrunner.Config.setValue(roadrunner.Config.ROADRUNNER_DISABLE_WARNINGS, 3)

it raises RuntimeError: bad variant access.
Any call that uses roadrunner.Config.setValue() cause this problem.
This error is specifically evoked by steadyState() for some reason.
Any thoughts?

Here's a minimal example:

import tellurium as te
import roadrunner

roadrunner.Config.setValue(roadrunner.Config.ROADRUNNER_DISABLE_WARNINGS, 3)

testModel = """
var S1, S2, S3;
const S0, S4;
J0: S0 -> S1; Kf0*S0/(1 + S0);
J1: S1 -> S2; Kf1*S1/(1 + S1);
J2: S2 -> S3; Kf2*S2/(1 + S2);
J3: S3 -> S4; Kf3*S3/(1 + S3);
J4: S1 -> S3; Kf4*S1/(1 + S1);

Kf0 = 0.285822003905
Kf1 = 0.571954691013
Kf2 = 0.393173236422
Kf3 = 0.75830845241
Kf4 = 0.148522702962

S0 = 3
S4 = 5
S1 = 1
S2 = 1
S3 = 1
"""

r = te.loada(testModel)
r.steadyState()

and here's my version info:

[('tellurium', '2.2.2.1'),
 ('roadrunner', '2.2.0'),
 ('rrplugins', '2.2.0'),
 ('antimony', '2.12.0.3'),
 ('libsbml', '5.19.4'),
 ('libsedml', '2.0.30'),
 ('phrasedml', '1.1.1')]
@kirichoi
Copy link
Author

I found that this only happens to a subset of configuration parameters.
ROADRUNNER_DISABLE_WARNINGS is one, STEADYSTATE_APPROX_MAX_STEPS is another, but STEADYSTATE_APPROX works fine when I tried to run steadyState() with approximation routine.

@luciansmith
Copy link

I've investigated and discovered that ROADRUNNER_DIABLE_WARNINGS is supposed to be a Boolean value, and will throw an error if you set it to something else and then try to get it as a Boolean. So you can fix your most immediate problem by changing:

roadrunner.Config.setValue(roadrunner.Config.ROADRUNNER_DISABLE_WARNINGS, 3)

to:

roadrunner.Config.setValue(roadrunner.Config.ROADRUNNER_DISABLE_WARNINGS, True)

However, we clearly need to do some type checking if this sort of error is the result, so I'm leaving this issue open until we can do that.

@luciansmith
Copy link

luciansmith commented Apr 23, 2022

Further investigation shows that the option used to be a bitfield/int, but later was changed to a bool, perhaps out of ignorance. I have to say that the option is very confusing, and that bitfield options seem hard to follow from a user's perspective.

Do you know what the option was originally supposed to do, and how it worked?

@kirichoi
Copy link
Author

Thanks for looking into this issue.
ROADRUNNER_DISABLE_WARNINGS used to accept intergers from 1 to 3, each corresponding to different levels of disabling warnings and notices. You can find more from the old libroadrunner documentation.
I'm guessing something similar happened to STEADYSTATE_APPROX_MAX_STEPS, which should take an integer.
I think the documentation on the config parameters should be updated and perhaps we can implement some tests along with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants