-
Notifications
You must be signed in to change notification settings - Fork 88
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
MESA example #102
Comments
are you trying to extend an AbstractModel class, or are you simply wrapping the mesa model run within a python function? if you have some code to share, I am happy to take a look. In fact, I have been meaning to write some documentation on how to write your own connectors by using MESA as an example. |
Hi, thanks for the answer. |
Hi Alessandro, @quaquel I can add this as an MVP example for EMA and mesa if you would like, connected just through Python. |
Hi, thanks, that is great! |
Unfortunately, there were some technical issues on ESSA's side, so the recording is not available. |
Okay thanks. I managed to connect my model to EMA. Yet it is very slow, I remembered there was an option for multiprocessing, is there any example of how to implement that? Also, which SA (that in in EMA workbench), would you recommend for a non-ergodic model? (2 final possible equilibria) Thanks in advance! |
depends a bit on whether your model needs access to the file system and how you made it work with MESA. If done correctly, all you need to do is from ema_workbench import MultiprocessingEvaluator
with MultiprocessingEvaluator(model) as evaluator:
experiments, outcomes = evaluator.perform_experiments(100) |
Thanks. I actually did adapt my model to be the same as the tutorial: This is my code:
Importantly, if i test it like this it works fine:
Outputs: However I get some issues when I run the experiments:
I get this error: File "/usr/local/anaconda3/lib/python3.8/site-packages/ema_workbench/em_framework/callbacks.py", line 230, in _store_outcomes KeyError: 'TIME' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 25, in File "/usr/local/anaconda3/lib/python3.8/site-packages/ema_workbench/em_framework/evaluators.py", line 468, in perform_experiments File "/usr/local/anaconda3/lib/python3.8/site-packages/ema_workbench/em_framework/evaluators.py", line 230, in evaluate_experiments File "/usr/local/anaconda3/lib/python3.8/site-packages/ema_workbench/em_framework/callbacks.py", line 265, in call File "/usr/local/anaconda3/lib/python3.8/site-packages/ema_workbench/em_framework/callbacks.py", line 244, in _store_outcomes ValueError: cannot convert float NaN to integer Any clue? |
which version of the workbench are you using? I recently addressed a bug related to this. |
I am using 2.0.9 |
the problem is presently TIME is a range of integers. If this were a range of floats, the problem would be gone. more fundamentally, this is a bug that needs fixing on the workbench side. |
I have changed time in: Then I changed also the other variables into floats and it works. So the bottom line is: only outcomes with float. |
and the fact that outcomes need to be floats is indeed the bug that needs fixing |
I see, perfect! |
regarding the parallel running a few questions because the code seems fine.
A fix is being tested for the other bug, so hopefully it will be more permanently fixed in the future. |
At the bottom of the code I have added:
[MainProcess/INFO] pool started Traceback (most recent call last):
And then it starts again... ....and so on |
hmmmm.... You are using brew for your python distribution if I am not mistaken. And python 3.9 as well. I am on a Mac as well, Big Sur also, but anaconda distribution and python 3.8. I have not seen your error before. |
Interesting. I think it might be something wrong with brew. I have to test |
Hi guys, just a follow-up. I made the general ema workbench working (I had a problem with brew and conda directory mixed up). However I can't make it work with the multiprocessor. It does not give any error yet it nevers finish the run. (it basically says "n experiments running sequentially". Anyone noticed that before (the code is the same as before)? |
if it says running sequentially, you are not using multiprocessing. Can you try one of the pure python examples that come with the workbench (e.g., the lake problem)? |
I am sorry, it says 'pool started' not running sequentially. I tried to copy and paste the sobol lake problem, it stayed like this the for 3 hours: (I am running in spyder, in a server that has 40 CPUs so it is usually very fast) C:\Users\TabernaA\Anaconda3\lib\site-packages\ema_workbench\em_framework\optimization.py:48: ImportWarning: platypus based optimization not available |
I closed by mistake sorry |
you really need to provide much more context. For example, are you using notebooks, a normal script, can you show the exact code? Also why not try to make it work on your Mac first. |
Hey thanks for the quick reply. def model_EEG_ABM(F1=5,
Outputs:
If I do individual run it works:
While if I do:
I get:
But it stays like this forever, without never finishing...I would like to run in the server because with MESA batch run I can 40 in parallel while in my mac only 12 and the server can run overnight without problems. Also if I try with the lake model (the sobol one), just copy and paste in a .py file in spyder, I get the same problem. |
please show the full code, not snippets. My hunch is that you miss if __name__ == '__main__':
# model definition and run code needs to go here |
@quaquel I think we should try not to rescope this one again, but get it in 2.5. If not a tutorial on connectors, just a simple example. |
Don't have a computer at hand so just writing this thought down: Can we make the EMAworkbench leverage or interface with the Mesa batchrunner? |
I'm unsure what that would mean or why you would want to do that. The batch runner, in my understanding, specifies a full factorial over the provided parameter values. The workbench offers you much more flexibility. |
Dear all,
I am trying to connect the EMA workbench framework to my MESA model. I have followed the tutorial for python. Yet, I encounter some errors and I cannot make it run ('Simple model' object is not subscriptable- when running perform_experiment). Is there any chance you could upload an example with a known MESA model (like the MESA version of Wolf Sheep https://github.com/projectmesa/mesa/tree/main/examples/wolf_sheep ). Since I am still a beginner in Python I am pretty sure it is a very stupid mistake that I am doing to not run the model.
Thanks in advance
A
The text was updated successfully, but these errors were encountered: