thouska / spotpy

A Statistical Parameter Optimization Tool
https://spotpy.readthedocs.io/en/latest/
MIT License
247 stars 149 forks source link

Truth value of an array is ambiguous in demcz.py #310

Open Richteny opened 10 months ago

Richteny commented 10 months ago

Hi,

I am trying to run the differential evolution Markov Chain in a cluster environment coupled to a dask-parallelised model. I am running 5 DEMCZ Chains in Parallel, but I do not allow for any MPI parallelisation. My idea was that it runs each chain after another but after 25 successful simulations, my model setup crashes with the error code:

_Traceback (most recent call last): File "/data/scratch/richteny/thesis/cosipy_test_space/spotpy_multobj_full.py", line 199, in mcmc = psample(obs=(tsla_obs,geod_ref), count=1, rep=10000, algorithm='demcz') File "/data/scratch/richteny/thesis/cosipy_test_space/spotpy_multobjfull.py", line 196, in psample sampler.sample(rep, nChains=5) File "/home/richteny/miniconda3/envs/cspy/lib/python3.10/site-packages/spotpy/algorithms/demcz.py", line 295, in sample if decisions[curchain]: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Do you have any idea why this happens? Since the coupled model setup is quite intensive, it's difficult for me to provide an example. I am using numpy==1.23.5 and spotpy==1.6.2

Thank you very much!

philippkraft commented 10 months ago

decisions should be a 1D numpy array of bool and curchain an int. It seems that for some reason this is not the case. Can you check the types in a debugger? I would suggest to test this in a simpler setup - smaller model, sequential chains and see if the error is still there.