thouska / spotpy

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

index 120 is out of bounds for axis 0 with size 120 #263

Closed Guochaoer closed 3 years ago

Guochaoer commented 3 years ago

I have used SCE-UA to optimize my own model. When I tried to optimize 40 parameters, the program ran successfully. However, when I tried to optimize 120 parameters, the program raised an error. It seems that the parallel part went wrong.

The error information is like:

Traceback (most recent call last):

File "", line 1, in runfile('Y:/0.5_WindField/pkgs/opencyclone/optimize/optimize_snapshots_spot.py', wdir='Y:/0.5_WindField/pkgs/opencyclone/optimize')

File "C:\Users\f\Anaconda3\envs\nc_env\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile execfile(filename, namespace)

File "C:\Users\f\Anaconda3\envs\nc_env\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "Y:/0.5_WindField/pkgs/opencyclone/optimize/optimize_snapshots_spot.py", line 46, in sampler.sample(rep, ngs=8*spot_setup.numTCPt+2, kstop=30, peps=0.1, pcento=0.1)

File "\172.16.222.57\f\0.5_WindField\pkgs\spotpy-master\spotpy\algorithms\sceua.py", line 191, in sample for rep, randompar, simulations in self.repeat(param_generator):

File "\172.16.222.57\f\0.5_WindField\pkgs\spotpy-master\spotpy\parallel\sequential.py", line 27, in call data = self.process(job)

File "\172.16.222.57\f\0.5_WindField\pkgs\spotpy-master\spotpy\algorithms\sceua.py", line 76, in simulate return _algorithm.simulate(self, id_params_tuple)

File "\172.16.222.57\f\0.5_WindField\pkgs\spotpy-master\spotpy\algorithms_algorithm.py", line 460, in simulate model_result = self.setup.simulation(self.partype(*all_params))

File "\172.16.222.57\f\0.5_WindField\pkgs\opencyclone\optimize\spot_setup_snapshots.py", line 131, in simulation ss = wf.snapshot_station(x[0+i*self.numTCPt],

File "\172.16.222.57\f\0.5_WindField\pkgs\spotpy-master\spotpy\parameter.py", line 603, in getitem return self.__info['random'][item]

IndexError: index 120 is out of bounds for axis 0 with size 120

I'd really appreciate it if you can help me with this problem!

thouska commented 3 years ago

Hi @Guochaoer,

thank you for your message and sorry for the error. Without seeing the spot_setup_snapshots.py its hard to tell. But from looking at the error I am a bit suprised that the code jumps from def simulation into the parameter.py. I think this should no happen. Could it be that you defined parameter in def simulation? This would explain the error. I Would recommend to use class parameter, like in this example. I hope this helps, otherwise, feel free to post the code here, or via an privtae email to me.

thouska commented 3 years ago

And as you were speaking about a parallel part: Judging from the line "\172.16.222.57\f\0.5_WindField\pkgs\spotpy-master\spotpy\parallel\sequential.py" I think you code ran in the sequential mode and not in parallel. If this is of any help.

Guochaoer commented 3 years ago

Thanks and I think it's not the error in the parallel part. My spot_setup_snapshots.py file has been sent to your email (tobias.houska@umwelt.uni-giessen.de). I really hope you can check it. I used free-size parameters whose length depends on the input data. The weirdest thing is that the code can be run successfully when the length of parameters is less than 100 while fails when the length is more than 120.