Skip to content

Commit

Permalink
Merge branch 'master' into PADDS_v03
Browse files Browse the repository at this point in the history
* master: (29 commits)
  Updated the statistics output
  Updated fscabc
  Updated fscabc
  Fix for thouska#217
  Update version number
  Update new style of Rosenbrock example on docs thouska#213
  Add missing keyword, fix for thouska#213
  Update version number
  Add basic test for parallel computing
  Remove altobjfunc from dream example
  Enlarge runs for dream in unittest
  Update Test script for rosenbrock setup thouska#213
  Update new style of rosenbrock_setup
  Fix for thouska#213
  Making status print more informativ
  Remov Gelman Rubin plot from test suite for Python < 3.6
  Remove Hymod support for Python <3.6
  Remove copy functions for py2 support
  Add classmethod statement
  WIP fix Python 2 errors
  ...

# Conflicts:
#	spotpy/__init__.py
#	spotpy/algorithms/_algorithm.py
  • Loading branch information
bees4ever committed Jun 4, 2019
2 parents f849ab1 + 300d58b commit 4a3259f
Show file tree
Hide file tree
Showing 31 changed files with 658 additions and 715 deletions.
73 changes: 48 additions & 25 deletions docs/Tutorial/2-Rosenbrock.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,45 +84,68 @@ We start directly with all algorithms. First we have to create a new file:
Now we create samplers for every algorithm and sample 5,000 parameter combinations for every algorithm:

results=[]
spotpy_setup=spotpy_setup()
rep=5000
spot_setup=spot_setup()
rep=1000
timeout=10 #Given in Seconds

sampler=spotpy.algorithms.mc(spotpy_setup, dbname='RosenMC', dbformat='csv')
results.append(sampler.sample(rep))
parallel = "seq"
dbformat = "csv"

sampler=spotpy.algorithms.lhs(spotpy_setup, dbname='RosenLHS', dbformat='csv')
results.append(sampler.sample(rep))
sampler=spotpy.algorithms.mc(spot_setup,parallel=parallel, dbname='RosenMC', dbformat=dbformat, sim_timeout=timeout)
print(describe(sampler))
sampler.sample(rep)
results.append(sampler.getdata())

sampler=spotpy.algorithms.lhs(spot_setup,parallel=parallel, dbname='RosenLHS', dbformat=dbformat, sim_timeout=timeout)
sampler.sample(rep)
results.append(sampler.getdata())

sampler=spotpy.algorithms.mle(spotpy_setup, dbname='RosenMLE', dbformat='csv')
results.append(sampler.sample(rep))
sampler=spotpy.algorithms.mle(spot_setup, parallel=parallel, dbname='RosenMLE', dbformat=dbformat, sim_timeout=timeout)
sampler.sample(rep)
results.append(sampler.getdata())

sampler=spotpy.algorithms.mcmc(spotpy_setup, dbname='RosenMCMC', dbformat='csv')
results.append(sampler.sample(rep))
sampler=spotpy.algorithms.mcmc(spot_setup, parallel=parallel, dbname='RosenMCMC', dbformat=dbformat, sim_timeout=timeout)
sampler.sample(rep)
results.append(sampler.getdata())

sampler=spotpy.algorithms.sceua(spotpy_setup, dbname='RosenSCEUA', dbformat='csv')
results.append(sampler.sample(rep,ngs=4))
sampler=spotpy.algorithms.sceua(spot_setup, parallel=parallel, dbname='RosenSCEUA', dbformat=dbformat, sim_timeout=timeout)
sampler.sample(rep,ngs=4)
results.append(sampler.getdata())

sampler=spotpy.algorithms.sa(spotpy_setup, dbname='RosenSA', dbformat='csv')
results.append(sampler.sample(rep))
sampler=spotpy.algorithms.sa(spot_setup, parallel=parallel, dbname='RosenSA', dbformat=dbformat, sim_timeout=timeout)
sampler.sample(rep)
results.append(sampler.getdata())

sampler=spotpy.algorithms.demcz(spotpy_setup, dbname='RosenDEMCz', dbformat='csv')
results.append(sampler.sample(rep,nChains=4))
sampler=spotpy.algorithms.demcz(spot_setup,parallel=parallel, dbname='RosenDEMCz', dbformat=dbformat, sim_timeout=timeout)
sampler.sample(rep,nChains=4)
results.append(sampler.getdata())

sampler=spotpy.algorithms.rope(spotpy_setup, dbname='RosenROPE', dbformat='csv')
results.append(sampler.sample(rep))

sampler=spotpy.algorithms.abc(spotpy_setup, dbname='RosenDEMCz', dbformat='csv')
results.append(sampler.sample(rep))
sampler=spotpy.algorithms.rope(spot_setup, parallel=parallel, dbname='RosenROPE', dbformat=dbformat,sim_timeout=timeout)
sampler.sample(rep)
results.append(sampler.getdata())

sampler=spotpy.algorithms.fscabd(spotpy_setup, dbname='RosenROPE', dbformat='csv')
results.append(sampler.sample(rep))
sampler=spotpy.algorithms.abc(spot_setup, parallel=parallel, dbname='RosenABC', dbformat=dbformat,sim_timeout=timeout)
sampler.sample(rep)
results.append(sampler.getdata())

sampler=spotpy.algorithms.fscabc(spot_setup, parallel=parallel, dbname='RosenFSABC', dbformat=dbformat, sim_timeout=timeout)
sampler.sample(rep)
results.append(sampler.getdata())

sampler=spotpy.algorithms.demcz(spot_setup, parallel=parallel, dbname='RosenDEMCZ', dbformat=dbformat, sim_timeout=timeout)
sampler.sample(rep)
results.append(sampler.getdata())

sampler=spotpy.algorithms.dream(spot_setup, parallel=parallel, dbname='RosenDREAM', dbformat=dbformat, sim_timeout=timeout)
sampler.sample(rep)
results.append(sampler.getdata())

## Plotting

To see the all results of your sampling, just type something like this:

algorithms=['MC','LHS','MLE','MCMC','SCEUA','SA','DEMCz','ROPE','ABC','FSCABC']
spotpy.analyser.plot_parametertrace_algorithms(results,algorithmnames=algorithms,parameternames=['x','y'])
algorithms = ['mc','lhs','mle','mcmc','sceua','sa','demcz','rope','abc','fscabc', 'demcz', 'dream']
spotpy.analyser.plot_parametertrace_algorithms(results, algorithms, spot_setup)

This should give you an nice overview about, how the parameter settings evolve during the sampling of each algorithm:

Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The example comes along with parameter boundaries, the Rosenbrock function, the
So we can directly start to analyse the Rosenbrock function with one of the algorithms. We start with a simple Monte Carlo sampling:

# Give Monte Carlo algorithm the example setup and saves results in a RosenMC.csv file
sampler = spotpy.algorithms.mc(spotpy_setup(), dbname='RosenMC', dbformat='csv')
sampler = spotpy.algorithms.mc(spot_setup(), dbname='RosenMC', dbformat='csv')

Now we can sample with the implemented Monte Carlo algorithm:

Expand All @@ -35,7 +35,7 @@ We can see that the parameters *x* and *y*, which drive the the Rosenbrock funct

If you want to see the best 10% of your samples, which is called posterior parameter distribution, you have to do something like this:

posterior=spotpy.analyser.get_posterior(results,percentage=10)
posterior=spotpy.analyser.get_posterior(results, percentage=10)
spotpy.analyser.plot_parameterInteraction(posterior)

This should give you a parameter interaction plot of your best 10% samples, which should look like Fig. 2:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name = 'spotpy',
version = '1.4.6',
version = '1.5.1',
description = 'A Statistical Parameter Optimization Tool',
long_description=open(os.path.join(os.path.dirname(__file__),
"README.rst")).read(),
Expand All @@ -22,7 +22,7 @@
},
#include_package_data = True,
use_2to3 = True,
keywords = 'Monte Carlo, MCMC, MLE, SCE-UA, Simulated Annealing, DE-MCz, DREAM, ROPE, Artifical Bee Colony, Uncertainty, Calibration, Model, Signatures',
keywords = 'Monte Carlo, MCMC, MLE, SCE-UA, Simulated Annealing, DE-MCz, DREAM, ROPE, Artifical Bee Colony, DDS, Uncertainty, Calibration, Model, Signatures',
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down
2 changes: 1 addition & 1 deletion spotpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
from . import describe # Contains some helper functions to describe smaplers and setups
from .hydrology import signatures # Quantifies goodness of fit between simulation and evaluation data with hydrological signatures
from . import unittests
__version__ = '1.4.6'
__version__ = '1.5.1'
Loading

0 comments on commit 4a3259f

Please sign in to comment.