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

Not implemented function 'delay' #433

Closed
CarineAVieira opened this issue Jan 8, 2024 · 7 comments
Closed

Not implemented function 'delay' #433

CarineAVieira opened this issue Jan 8, 2024 · 7 comments
Assignees
Labels

Comments

@CarineAVieira
Copy link

The function delay is not implemented on pysd...
Is there a way to come around this problem?

@enekomartinmartinez
Copy link
Collaborator

Hi @CarineAVieira

Thank you for opening the PR! You mean the delay function from XMILE or any other kind of delay?

It seems that the workflow of that function is the same as Vensin's DelayFixed.

If that is so, it will be very easy to modify the translation process to make it work. However, I would ask you if you can provide an XMILE test model with some examples of that function and the output that produces, to check that everything works as should in PySD. I cannot do it because I currently don't have Stella or Vensim working. You can replicate this model with Stella https://github.com/SDXorg/test-models/tree/master/tests/delay_fixed

@CarineAVieira
Copy link
Author

CarineAVieira commented Jan 9, 2024

Hi @enekomartinmartinez ,

Yes, I meant the DELAY function of XMILE...
I don't understand vensin very well, but this is an example of the function that does not work on PySD.
The error: "NotImplementedError: Not implemented function 'delay'"

image

Equations:
Stock_1(t) = Stock_1(t - dt) + (Flow_2) * dt
INIT Stock_1 = 100
INFLOWS:
Flow_2 = Converter_1*Stock_1
Converter_1 = 0,02
Converter_2 = (((Stock_1/DELAY(Stock_1; 1))-1)*100)

The exemple you asked for:
https://drive.google.com/file/d/175wF5660xJf0f9OAyn1MNXBhnzejhkSm/view?usp=sharing

Thank you :)

@enekomartinmartinez
Copy link
Collaborator

Thank you @CarineAVieira

Could you also please provide the output that this model produces, a .csv o .tab file would work

Here is explained how to do it to make it comparable with our test-suite https://github.com/SDXorg/test-models#result-formatting

@enekomartinmartinez
Copy link
Collaborator

Hi @CarineAVieira it is already solved in version 3.13.2. It should be already available in PyPI and in some hours in conda-forge.

Note that some of the functions implemented in XMILE are not tested as we miss XMILE users currently, it would be nice if you could provide sample test for any of them.

@CarineAVieira
Copy link
Author

Hi @enekomartinmartinez, thank you very much!

I can provide some samples of some functions that are not tested.
How can I do? Send a sample and the output ?

@enekomartinmartinez
Copy link
Collaborator

If you prefer, you can open a pull request in the test-models repo. You can look at some examples inside the tests folder. In some cases, you could simply replicate some existing Vensim models with Stella.

For example, this model is only in Vensim and includes some functions that are not tested with XMILE (STEP, DELAYN), in this case, reproducing the same model with Stella will be enough as we would expect the same outputs
https://github.com/SDXorg/test-models/blob/master/tests/delay_pipeline/test_pipeline_delays.mdl

It can be done similarly for some other models. In some cases, creating a new folder with the new model and outputs may be necessary as it may not be there. Note that some parameters could change their order in Stella compared to Vensim, but generally, the functions have the same name.

If you prefer to simply send me the model with the output as done with the previous one, this will also be useful. However, I would prefer to reuse existing models.

Any help will be very useful as the XMILE translator is not fully tested, which could lead to bugs.

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

No branches or pull requests

2 participants