thouska / spotpy

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

Parameter tuple with a constrain #280

Closed lu-kas closed 2 years ago

lu-kas commented 2 years ago

Dear all,

is it possible to create parameters as a tuple, which satisfies a given condition. E.g. n random numbers, which sum up to 1. Additionally, the elements of the random tuple have to be equally distributed.

Thanks!

Best, Lukas

thouska commented 2 years ago

Hi Lukas,

it would be possible to generate your own parameter List, with the spotpy.parameter.List function. How it can be used is shown here. You can put any numbers in that List that fullfill your conditions. If such an object is given, SPOTPY will not change these values, but go through them in the order of the given numbers. All other given parameter objects will change according to the selected algorithm.

philippkraft commented 2 years ago

Another possibility is to just create a bunch of uniform parameters in the [0..1] range and then normalize the parameters in the simulation method of your setup class.

def simulation(self, x):
    x = x / np.sum(x)
    ...
lu-kas commented 2 years ago

Dear @philippkraft , dear @thouska

thanks for your prompt answers and please excuse my very late response. We will have to try out your proposed suggestions. Regarding the proposed normalisation ( x=x/sum(x) ), I have hoped we could reduce the number of variables, as we have a given constrain, thus we could reduce the length of x from n to n-1.

I will close the issue for now.

Thanks for creating and actively maintaining this great tool!

Best Lukas