thouska / spotpy

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

Maybe there is a mistake in SCE-UA algorithm #275

Open ToshiyukiBandai opened 3 years ago

ToshiyukiBandai commented 3 years ago

Hi,

Thank you for providing the code. I really appreciate your work. I am using the SCE-UA algorithm for my research and just noticed that there may be a mistake in the code

Line 93 of the sceua.py lcs[0] = 1 should be lcs[0] = 0

I think this error comes from that the original Matlab code starts with 1 for index, but 0 in python. This code means that we alwarys pick up the best value in the sub-pupulation for defining the simpex. This error may be related to issues reported here (ex. "Strange behavior of SCEUA convergence #204").

suraj081 commented 1 year ago

for loop in range(self.nspl):

Select simplex by sampling the complex according to a linear

            # probability distribution
            lcs = np.array([0] * self.nps)
            lcs[0] = 1
            for k3 in range(1, self.nps):
                for i in range(1000):  

################## matlab code #################

    for loop=1:nspl;

        % Select simplex by sampling the complex according to a linear
        % probability distribution
        lcs(1) = 1;
        for k3=2:nps;
            for iter=1:1000;
                lpos = 1 + floor(npg+0.5-sqrt((npg+0.5)^2 - npg*(npg+1)*rand));
                idx=find(lcs(1:k3-1)==lpos); if isempty(idx); break; end;
            end;

i guess yr guess is correct!