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

read_xmile error #198

Closed
paulusm opened this issue Oct 15, 2018 · 17 comments
Closed

read_xmile error #198

paulusm opened this issue Oct 15, 2018 · 17 comments

Comments

@paulusm
Copy link

paulusm commented Oct 15, 2018

Trying to read in an xmile exported from Vensim

model = pysd.read_xmile("test.xml")

..gives the error:

parsimonious.exceptions.ParseError: Rule 'expr' didn't match at '
Error generati' (line 1, column 1).

But the same model loads ok as .mdl with read_vensim. I'm on Anaconda, python 3.6.6

@JamesPHoughton
Copy link
Collaborator

That's interesting. Did the xmile export from vensim work properly? If you open the xmile file in a text editor, do you see properly formatted XML? It looks to me like the xmile file starts with an error message, just from what you've posted.

@paulusm
Copy link
Author

paulusm commented Oct 16, 2018

As far as I can see it is valid and as exported successfully..

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xmile version="1.0" xmlns="http://docs.oasis-open.org/xmile/ns/XMILE/v1.0"> <header> <product version="1.0" lang="en">Vensim</product> <vendor>Ventana Systems, Inc.</vendor> <created> </created> <modified> </modified> <name> </name> <caption> </caption> </header> <sim_specs method="RK4" time_units="Day"> <start>0</start> <stop>1000</stop> <dt>1</dt> </sim_specs> <model> <variables> <stock name="Discovered_rework"> <units></units> <doc></doc> <eqn> 0 </eqn> <inflow> Error generation rate </inflow> </stock> <stock name="Scope_growth"> <units></units> <doc></doc> <eqn> 0 </eqn> <inflow> Scope growth rate </inflow> </stock> <stock name="work_done"> <units></units> <doc></doc> <eqn> 0 </eqn> <inflow> Progress rate </inflow> </stock> <aux name="Commnunication_channels"> <units></units> <doc></doc> <eqn>Team_size*(Team_size-1)/2 </eqn> </aux> <aux name="Error_fraction"> <units></units> <doc></doc> <eqn>LN(Morale/10)+LN(Commnunication_channels/10) </eqn> </aux> <aux name="Error_generation_rate"> <units></units> <doc></doc> <eqn>Error_fraction </eqn> </aux> <aux name="Morale"> <units></units> <doc></doc> <eqn>Pay*0.05-LN(0.0001+Discovered_rework) </eqn> </aux> <aux name="Productivity"> <units></units> <doc></doc> <eqn>LN(Team_size*2)+LN(Morale)-LN(10+ Commnunication_channels) </eqn> </aux> <aux name="Progress_rate"> <units></units> <doc></doc> <eqn>Productivity </eqn> </aux> <aux name="Scope_growth_rate"> <units></units> <doc></doc> <eqn>Client_involvement </eqn> </aux> <aux name="Work_to_do"> <units></units> <doc></doc> <eqn>Initial_scope+Discovered_rework+Scope_growth-work_done </eqn> </aux> <aux name="Client_involvement"> <units></units> <doc></doc> <eqn>0 </eqn> </aux> <aux name="Initial_scope"> <units></units> <doc></doc> <eqn>1000 </eqn> </aux> <aux name="Pay"> <units></units> <doc></doc> <eqn>1000 </eqn> </aux> <aux name="Team_size"> <units></units> <doc></doc> <eqn>3 </eqn> </aux> </variables> </model> </xmile>

@stefano-romano
Copy link

Same here – I can't seem to be able to read any xmile file (from Stella), generally same error. Any advice?

@wzh1895
Copy link

wzh1895 commented Nov 17, 2018

Hi, my case is slightly different - after one time successfully reading .stmx file, the file itself gets overwritten to the translated .py file and can't be read in anymore (and the Stella model is therefore lost)

@wzh1895
Copy link

wzh1895 commented Nov 17, 2018

Hi again, I guess I found where the problem (in my last post) comes from:

in the end of the file "pysd/pysd/py_backend/xmile/xmile2py.py", a line writes:

outfile_name = xmile_file.replace('.xmile', '.py')

However, if the original file is a '.stmx' file instead of a '.xmile' file, this line won't do anything and the original filename is therefore passed back to write out. That is what happened to me, because I found '.stmx' file can actually be directly read in. Luckily I had a backup for this model.

Please could you do something with this? It is a 'dangerous' issue since people could just try their Stella model with PySD without a backup.

@JamesPHoughton @alexprey

Thanks

@meuseky
Copy link

meuseky commented Nov 29, 2018

I'm having a similar issue when trying to parse Macro expressions in xmile format:

Rule 'expr' didn't match at 'EXPRESSION MACRO(mac' (line 1, column 1).

As well as:
Rule 'expr' didn't match at 'SECOND MACRO(macro_i' (line 1, column 1).

@alexprey
Copy link
Collaborator

@meuseky, i'm sorry, but for now macro expressions is not supported by xmile :(

@meuseky
Copy link

meuseky commented Nov 29, 2018

@alexprey By XMile or by PySD? The XMile spec seems to support them: http://docs.oasis-open.org/xmile/xmile/v1.0/cs01/xmile-v1.0-cs01.html#_Toc403385655

@alexprey
Copy link
Collaborator

@meuseky, i mean in pysd implementation :)

@aclarkData
Copy link

Same here. I cannot open any xmile files from Stella.

@alexprey
Copy link
Collaborator

alexprey commented Dec 19, 2018

Hi @aclarkData, can you please provide example of you model, that is not work :)


Alexey, sdCloud.io dev. Team

@aclarkData
Copy link

aclarkData commented Dec 19, 2018

Yes sir! Below is a link to an official Stella model example from IEEE Systems. Very simple models appear to import, but when the equations become more involved, the parser breaks down. https://github.com/aclarkData/PublicTransfer/blob/master/Headcount-Strategy.xmile

@peterhovmand
Copy link

peterhovmand commented Jan 22, 2019

I stumbled upon what I think is a related error in parsing XMILE from a Stella file XMILE. Having a stock without a flow seems to cause all kinds of problems. In some ways, it's a trivial situation, but problematic nonetheless since one might have stocks without flows as a placeholder while one is building a model.

Here's the chunk of a model without a stock that fails to import:

	<variables>
		<stock name="Stock">
			<eqn>50</eqn>
			<non_negative/>
		</stock>
	</variables>

Here's the chunk of a model with a flow that does work:

	<variables>
		<stock name="Stock">
			<eqn>50</eqn>
			<inflow>Flow_1</inflow>
			<non_negative/>
		</stock>
		<flow name="Flow 1">
			<eqn>0</eqn>
			<non_negative/>
		</flow>
	</variables> 

@mbafrani
Copy link

Hi, I'm facing the same error, does anybody know how to deal with that?
Thanks in advance

@ecreager
Copy link

ecreager commented Jul 8, 2021

I'm also encountering the "Rule 'expr' didn't match" error, for what its worth. So any workaround would be appreciated.

@JamesPHoughton
Copy link
Collaborator

We probably should have some more explicit error messaging here. This is the generic error that is thrown when the XMILE translator encounters something it doesn't recognize. Unfortunately the workarounds aren't very satisfying. If you have access to Vensim, you might try translating the model to Vensim format first and then loading with PySD. PySD's Vensim translator is much more well-established. If it's a simple feature, you might try modifying the XMILE parser and submitting a pull request - we love contributions. =) The least satisfying solution is to rework the model so it only uses the currently supported features. =/

@enekomartinmartinez do you think it would be worth including something in the docs about common errors? This would be top of the list...

@enekomartinmartinez
Copy link
Collaborator

Hi @JamesPHoughton

I think it would be useful to add a FAQs, Common errors, or Troubleshooting section in the documentation to include information about common parsing and runtime errors and the possible solutions. we can describe error, their solutions and also link them to already solved issues. We should start by making a list of these errors. I don't think I'll have time to work on this in the next few weeks, but we can start by listing the issues we want to include.

Moreover, in order to make xmile translator errors more readable maybe something similar to vensim could be done, printing the full expression when an error is found after the parsimonious error (see vensim2py parsing error in get equation components and vensim2py parsing error in general expression)

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