climateinteractive / SDEverywhere

SDEverywhere translates System Dynamics models from Vensim to C, JavaScript, and WebAssembly
http://sdeverywhere.org/
MIT License
54 stars 21 forks source link

XMILE input support #468

Open filipesmedeiros opened 2 months ago

filipesmedeiros commented 2 months ago

Hello! First of all, let me say that this is an amazing project. Thank you so much for your contributions and for making this openly available.

I thought it would be a good create an issue to track XMILE support. Also, to ask if there are any tasks that you need help with? I'm currently an SD student (use Stella a lot) with a past in web dev and software in general.

Thanks!

chrispcampbell commented 2 months ago

Hi @filipesmedeiros, thanks for filing this issue and for offering your support. I am very much in favor of having first-class support for XMILE in SDEverywhere (specifically for Stella compatibility). The main reason I haven't prioritized working on that feature is that the modelers at Climate Interactive primarily use Vensim, so I haven't been able to justify spending day job / work hours on XMILE support since we likely won't be using it ourselves any time soon, and I'm already over-committed on work tasks as it is (though I have made some progress on XMILE support in my non-work / free time just out of intellectual curiosity, more on that below).

I made some progress on an initial XMILE branch a few months ago but that branch needs to be brought up to date with other changes that have since been merged to the main branch. The XMILE work was wrapped up with other changes I had going at the time (reimplementing the parse and code gen phases of the compiler), so the diff above is not as minimal as it should be.

But since you expressed interest, I would be happy to spend a little time in the next week or two to get that branch up to date, which would make it easier to see what work remains. If I recall correctly, I had gotten as far as updating the compile package to read simple XMILE files, but more work will be needed in the cli package, which currently assumes that input files are in Vensim format only. (Not a ton of work, but will need some thought.)

It would be great if you and/or others would be willing to help out with this effort. As mentioned, it will be easier for me to provide more guidance once I get the initial branch up to date. Let me know at what level you think you might be able to help, like testing things out in Stella once things are farther along, or getting your hands dirty in the implementation of SDEverywhere to help finish up the branch I was working on.

travisfranck commented 2 months ago

@filipesmedeiros Glad we crossed paths yesterday and thanks for your interest in SDE. It would be great to have the help and make the tool more useful for the community!

filipesmedeiros commented 2 months ago

Hey @chrispcampbell! I think that would be ideal. If there is a branch with a minimal diff that I can look through so I get used to the codebase, etc, that would be amazing. Of course, anyone else that might want to help :) As for my exact help, I think I can slowly work on implementation as I know more about the codebase, but testing would of course be much easier for me since I'd probably be able to do that fast and easy!

@travisfranck I'm glad too! Hopefully more again someday :)

chrispcampbell commented 2 months ago

Hi @filipesmedeiros, I brought the XMILE branch up to date last week but forgot to reply here about that. You can find the diff here. If you're interested in learning more about the details of parsing and transpilation, check out the Transpiler Architecture wiki page.

Re: the current state of XMILE support, I've got most of the parsing work completed, which includes new parsing functions exposed in the @sdeverywhere/parse package and tests (all passing) for that new code. I think it covers most of the subset of XMILE that is needed by SDEverywhere, but I won't know for sure until I get to the next phase, which includes:

That last item would be one good way for you to get involved, if you are up for it. I think it would involve opening each mdl file in Stella then saving in stmx format in the same directory. Also need to run the model in Stella and save the resulting values in csv format in that directory, similar to how we save Vensim outputs in dat format. Once the sample models are converted to stmx or vanilla xmile format it will be easier for me (or someone else) to make progress on the remainder of the testing and implementation work.

chrispcampbell commented 2 months ago

Hi @filipesmedeiros, just this week another developer offered to help out with that last item (converting existing Vensim test models to xmile format). I'm assuming that you haven't dug into that already, but let me know if you have. If I don't hear from you in the next couple days, I'll tell that other developer they can proceed. Or if you do want to get involved, I can put the two of you in touch to coordinate.

In any case, I just want to avoid anyone stepping on toes, or doing work that's already been started elsewhere. If you don't have time to help out with this particular task, I completely understand, and I'm sure there are other ways you can get involved as the work proceeds.

filipesmedeiros commented 1 month ago

Hey @chrispcampbell! Yeah I haven't had the time, please go ahead and tell them to do it :) I will help later with other tasks!

chrispcampbell commented 1 month ago

@filipesmedeiros: Sounds good, thanks for confirming! I'll post updates here as the work proceeds.