diff --git a/spotpy/algorithms/dds.py b/spotpy/algorithms/dds.py index 11c488cc..1cd368b5 100644 --- a/spotpy/algorithms/dds.py +++ b/spotpy/algorithms/dds.py @@ -396,9 +396,9 @@ def calculate_next_s_test(self, previous_x_curr, rep, rep_limit, r): new_x_curr[j] = new_value # change relevant dec var value in x_curr if dvn_count == 0: # no DVs selected at random, so select ONE - dec_var = np.int(np.ceil(amount_params * self.np_random.rand())) - new_value = self.dds_generator.neigh_value_mixed(previous_x_curr, r, dec_var - 1, self.min_bound[j],self.max_bound[j]) - - new_x_curr[dec_var - 1] = new_value # change relevant decision variable value in s_test + dec_var = np.int(np.ceil(amount_params * self.np_random.rand())) - 1 + new_value = self.dds_generator.neigh_value_mixed(previous_x_curr, r, dec_var, self.min_bound[dec_var], + self.max_bound[dec_var]) + new_x_curr[dec_var] = new_value # change relevant decision variable value in s_test return new_x_curr diff --git a/spotpy/algorithms/padds.py b/spotpy/algorithms/padds.py index 90105f33..23f3885c 100644 --- a/spotpy/algorithms/padds.py +++ b/spotpy/algorithms/padds.py @@ -306,11 +306,11 @@ def calculate_next_s_test(self, previous_x_curr, rep, rep_limit, r): new_x_curr[j] = new_value # change relevant dec var value in x_curr if dvn_count == 0: # no DVs selected at random, so select ONE + dec_var = np.int(np.ceil(amount_params * self.np_random.rand())) new_value = self.dds_generator.neigh_value_mixed(previous_x_curr, r, dec_var - 1, self.min_bound[dec_var - 1],self.max_bound[dec_var - 1]) new_x_curr[dec_var - 1] = new_value # change relevant decision variable value in s_test - return new_x_curr diff --git a/spotpy/examples/spot_setup_dds.py b/spotpy/examples/spot_setup_dds.py index 67e93585..e39e85dd 100644 --- a/spotpy/examples/spot_setup_dds.py +++ b/spotpy/examples/spot_setup_dds.py @@ -53,6 +53,21 @@ def _objfunc_switcher(self, name): for j in range(2)] + [Uniform('c' + str(j), -500, 700, 1.5, 3.0, -500, 700, doc=str(j) + 'continuous parameter within a boundary') for j in range(8)] + elif name == "cmf_style": + self.objfunc = ackley10 + self.params = [Uniform(.5, 5., optguess=1.5, doc='saturated depth at beginning'), + Uniform(.001, .8, optguess=.1, doc='porosity of matrix [m3 Pores / m3 Soil]'), + Uniform(1., 240., optguess=10., + doc='ssaturated conductivity of macropores [m/day]'), + Uniform(.0001, .5, optguess=.05, doc='macropore fraction [m3/m3]'), + Uniform(.005, 1., optguess=.05, + doc='mean distance between the macropores [m]'), + Uniform(0., 1., optguess=0., + doc='water content when matric potential pointing towards -infinity'), + Uniform(.5, 1., optguess=.99, + doc='wetness above which the parabolic extrapolation is used instead of VGM'), + Uniform(0., 50, optguess=.1, + doc='exchange rate [1/day] for macropore-matrix-exchange')] def parameters(self): if self.params is None: diff --git a/spotpy/examples/tutorial_padds.py b/spotpy/examples/tutorial_padds.py index 3dd54cdc..897ce02a 100644 --- a/spotpy/examples/tutorial_padds.py +++ b/spotpy/examples/tutorial_padds.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import numpy as np import sys +from spotpy.parameter import Uniform try: import spotpy except ModuleNotFoundError: @@ -48,10 +49,27 @@ def ZDT1(x): class padds_spot_setup(object): - def __init__(self): + def __init__(self, default=True): self.params = [] - for i in range(30): - self.params.append(spotpy.parameter.Uniform(str(i+1), 0, 1, 0, 0, 0, 1,doc="param no " + str(i+1))) + if default: + for i in range(30): + self.params.append(spotpy.parameter.Uniform(str(i+1), 0, 1, 0, 0, 0, 1,doc="param no " + str(i+1))) + else: + self.params = [Uniform(.5, 5., optguess=1.5, doc='saturated depth at beginning'), + Uniform(.001, .8, optguess=.1, doc='porosity of matrix [m3 Pores / m3 Soil]'), + Uniform(1., 240., optguess=10., + doc='ssaturated conductivity of macropores [m/day]'), + Uniform(.0001, .5, optguess=.05, doc='macropore fraction [m3/m3]'), + Uniform(.005, 1., optguess=.05, + doc='mean distance between the macropores [m]'), + Uniform(0., 1., optguess=0., + doc='water content when matric potential pointing towards -infinity'), + Uniform(.5, 1., optguess=.99, + doc='wetness above which the parabolic extrapolation is used instead of VGM'), + Uniform(0., 50, optguess=.1, + doc='exchange rate [1/day] for macropore-matrix-exchange')] + for i in range(8,30): + self.params.append(Uniform(str(i+1), 0, 1, 0, 0, 0, 1,doc="param no " + str(i+1))) def parameters(self): return spotpy.parameter.generate(self.params) diff --git a/tests/test_dds.py b/tests/test_dds.py index 9f51027b..da6b0df5 100644 --- a/tests/test_dds.py +++ b/tests/test_dds.py @@ -126,6 +126,24 @@ def test_run_own_initial_1(self): def test_run_own_initial_2(self): self.run_a_dds("own_input_2") + def outside_bound(self, x_curr, min_bound, max_bound): + out_left = min_bound > x_curr # [x x_curr # [x