Beispiel #1
0
    def setUpClass(self):
        np.random.seed(42)
        self.rep = 300
        self.parallel = "seq"
        self.dbformat = "ram"
        self.timeout = 5
        self.fig_name = 'test_output.png'

        sampler = spotpy.algorithms.mc(rosenbrock_setup(),
                                       sim_timeout=self.timeout)
        sampler.sample(self.rep)
        self.results = sampler.getdata()

        sampler = spotpy.algorithms.mc(griewank_setup(),
                                       sim_timeout=self.timeout)
        sampler.sample(self.rep)
        self.griewank_results = sampler.getdata()
        if sys.version_info >= (3, 6):  # FAST is only fully operational under
            #Python 3
            sampler = spotpy.algorithms.fast(rosenbrock_setup(),
                                             sim_timeout=self.timeout)
            sampler.sample(self.rep)
            self.sens_results = sampler.getdata()
            #Hymod resuts are empty with Python <3.6
            sampler = spotpy.algorithms.dream(hymod_setup(GausianLike),
                                              sim_timeout=self.timeout)
            self.r_hat = sampler.sample(self.rep)
            self.hymod_results = sampler.getdata()
Beispiel #2
0
    def test_plot_regression(self):
        spotpy.analyser.plot_regression(self.results,
                                        rosenbrock_setup().evaluation(),
                                        fig_name=self.fig_name)

        # approximately 8855 KB is the size of an empty matplotlib.pyplot.plot, so
        # we expecting a plot with some content without testing the structure of the plot, just
        # the size
        self.assertGreaterEqual(os.path.getsize(self.fig_name), 8855)
Beispiel #3
0
    def test_compare_different_objectivefunctions(self):

        sampler = spotpy.algorithms.lhs(rosenbrock_setup(),
                                        sim_timeout=self.timeout)

        sampler.sample(self.rep)
        compare_different_objectivefunctions = spotpy.analyser.compare_different_objectivefunctions(
            sampler.getdata()['like1'], self.results['like1'])

        self.assertEqual(type(compare_different_objectivefunctions[1]),
                         type(np.array([0.5])[0]))
Beispiel #4
0
 def test_calc_like(self):
     calc_like = spotpy.analyser.calc_like(self.results,
                                           rosenbrock_setup().evaluation(),
                                           spotpy.objectivefunctions.rmse)
     self.assertEqual(len(calc_like), len(self.results))
     self.assertEqual(type(calc_like), type([]))
Beispiel #5
0
 def test_get_parbounds(self):
     get_parbounds = spotpy.analyser.get_parbounds(
         spotpy_setup=rosenbrock_setup())
     self.assertEqual(len(get_parbounds[0]), 2)
     self.assertEqual(len(get_parbounds), 3)
     self.assertEqual(type(get_parbounds), type([]))
Beispiel #6
0
 def test_get_min_max(self):
     get_min_max = spotpy.analyser.get_min_max(
         spotpy_setup=rosenbrock_setup())
     self.assertEqual(len(get_min_max[0]), 3)
     self.assertEqual(type(get_min_max), type(()))