Ejemplo n.º 1
0
    def test_estimation_all_args(self):
        ga_opts = {'maxiter': 3, 'pop_size': 10, 'trm_size': 5, 'lhs': True}
        ps_opts = {'maxiter': 3}
        session = Estimation(self.tmpdir, self.fmu_path, self.inp,
                             self.known, self.est, self.ideal,
                             lp_n=2, lp_len=3600, lp_frame=(0, 3600),
                             vp=(20000, 40000), ic_param={'Tstart': 'T'},
                             methods=('GA', 'PS'),
                             ga_opts=ga_opts, ps_opts=ps_opts,
                             seed=1, ftype='NRMSE')

        estimates = session.estimate()
        err, res = session.validate()  # Standard validation period
        err2, res2 = session.validate(vp=(25000, 28600))

        self.assertIsNotNone(estimates)
        self.assertGreater(len(estimates), 0)
        self.assertIsNotNone(err)
        self.assertIsNotNone(res)
        self.assertIsNotNone(err2)
        self.assertIsNotNone(res2)
        self.assertGreater(len(res.index), 1)
        self.assertGreater(len(res.columns), 0)
        self.assertGreater(len(res2.index), 1)
        self.assertGreater(len(res2.columns), 0)
        self.assertEqual(session.lp[0][0], 0)
        self.assertEqual(session.lp[0][1], 3600)
        # Enabling next line triggers the Matplotlib error (issue #20)
        # raw_input('Continue...')
        self.assertLess(err['tot'], 1.7)  # NRMSE
Ejemplo n.º 2
0
    def test_estimation_basic_parallel(self):
        """Will use default methods ('MODESTGA', 'PS')"""
        modestga_opts = {
            "generations": 2,
            "workers": 2,
            "pop_size": 16,
            "trm_size": 3
        }
        ps_opts = {"maxiter": 2}
        session = Estimation(
            self.tmpdir,
            self.fmu_path,
            self.inp,
            self.known,
            self.est,
            self.ideal,
            modestga_opts=modestga_opts,
            ps_opts=ps_opts,
            default_log=False,
        )
        estimates = session.estimate()
        err, res = session.validate()

        self.assertIsNotNone(estimates)
        self.assertGreater(len(estimates), 0)
        self.assertIsNotNone(err)
        self.assertIsNotNone(res)
        self.assertGreater(len(res.index), 1)
        self.assertGreater(len(res.columns), 0)
Ejemplo n.º 3
0
    def test_estimation_rmse(self):
        modestga_opts = {"generations": 8}
        ps_opts = {"maxiter": 16}

        session = Estimation(
            self.tmpdir,
            self.fmu_path,
            self.inp,
            self.known,
            self.est,
            self.ideal,
            lp_n=1,
            lp_len=3600,
            lp_frame=(0, 3600),
            vp=(20000, 40000),
            ic_param={"Tstart": "T"},
            methods=("MODESTGA", "PS"),
            modestga_opts=modestga_opts,
            ps_opts=ps_opts,
            ftype="RMSE",
            default_log=False,
        )

        estimates = session.estimate()
        err, res = session.validate()

        self.assertIsNotNone(estimates)
        self.assertGreater(len(estimates), 0)
        self.assertIsNotNone(err)
        self.assertIsNotNone(res)
        self.assertGreater(len(res.index), 1)
        self.assertGreater(len(res.columns), 0)
        self.assertLess(err["tot"], 1.48)
Ejemplo n.º 4
0
    def test_estimation_rmse(self):
        ga_opts = {'maxiter': 3, 'pop_size': 8, 'trm_size': 3}
        ps_opts = {'maxiter': 3}

        session = Estimation(self.tmpdir,
                             self.fmu_path,
                             self.inp,
                             self.known,
                             self.est,
                             self.ideal,
                             lp_n=1,
                             lp_len=3600,
                             lp_frame=(0, 3600),
                             vp=(20000, 40000),
                             ic_param={'Tstart': 'T'},
                             methods=('GA', 'PS'),
                             ga_opts=ga_opts,
                             ps_opts=ps_opts,
                             seed=1,
                             ftype='RMSE')

        estimates = session.estimate()
        err, res = session.validate()

        self.assertIsNotNone(estimates)
        self.assertGreater(len(estimates), 0)
        self.assertIsNotNone(err)
        self.assertIsNotNone(res)
        self.assertGreater(len(res.index), 1)
        self.assertGreater(len(res.columns), 0)
        self.assertLess(err['tot'], 1.48)
Ejemplo n.º 5
0
    def test_estimation_basic(self):
        """Will use default methods ('MODESTGA', 'PS')"""
        modestga_opts = {
            'generations': 2,
            'workers': 1,
            'pop_size': 8,
            'trm_size': 3
        }
        ps_opts = {'maxiter': 2}
        session = Estimation(self.tmpdir,
                             self.fmu_path,
                             self.inp,
                             self.known,
                             self.est,
                             self.ideal,
                             modestga_opts=modestga_opts,
                             ps_opts=ps_opts,
                             default_log=False)
        estimates = session.estimate()
        err, res = session.validate()

        self.assertIsNotNone(estimates)
        self.assertGreater(len(estimates), 0)
        self.assertIsNotNone(err)
        self.assertIsNotNone(res)
        self.assertGreater(len(res.index), 1)
        self.assertGreater(len(res.columns), 0)
Ejemplo n.º 6
0
    def test_estimation_rmse(self):
        modestga_opts = {'generations': 8}
        ps_opts = {'maxiter': 16}

        session = Estimation(self.tmpdir,
                             self.fmu_path,
                             self.inp,
                             self.known,
                             self.est,
                             self.ideal,
                             lp_n=1,
                             lp_len=3600,
                             lp_frame=(0, 3600),
                             vp=(20000, 40000),
                             ic_param={'Tstart': 'T'},
                             methods=('MODESTGA', 'PS'),
                             modestga_opts=modestga_opts,
                             ps_opts=ps_opts,
                             ftype='RMSE',
                             default_log=False)

        estimates = session.estimate()
        err, res = session.validate()

        self.assertIsNotNone(estimates)
        self.assertGreater(len(estimates), 0)
        self.assertIsNotNone(err)
        self.assertIsNotNone(res)
        self.assertGreater(len(res.index), 1)
        self.assertGreater(len(res.columns), 0)
        self.assertLess(err['tot'], 1.48)
Ejemplo n.º 7
0
    def test_estimation_all_args(self):
        modestga_opts = {
            "generations": 2,
            "workers": 2,
            "pop_size": 16,
            "trm_size": 3
        }
        ps_opts = {"maxiter": 3}
        session = Estimation(
            self.tmpdir,
            self.fmu_path,
            self.inp,
            self.known,
            self.est,
            self.ideal,
            lp_n=2,
            lp_len=3600,
            lp_frame=(0, 3600),
            vp=(20000, 40000),
            ic_param={"Tstart": "T"},
            methods=("MODESTGA", "PS"),
            modestga_opts=modestga_opts,
            ps_opts=ps_opts,
            ftype="NRMSE",
            default_log=False,
        )

        estimates = session.estimate()
        err, res = session.validate()  # Standard validation period
        err2, res2 = session.validate(vp=(25000, 28600))

        self.assertIsNotNone(estimates)
        self.assertGreater(len(estimates), 0)
        self.assertIsNotNone(err)
        self.assertIsNotNone(res)
        self.assertIsNotNone(err2)
        self.assertIsNotNone(res2)
        self.assertGreater(len(res.index), 1)
        self.assertGreater(len(res.columns), 0)
        self.assertGreater(len(res2.index), 1)
        self.assertGreater(len(res2.columns), 0)
        self.assertEqual(session.lp[0][0], 0)
        self.assertEqual(session.lp[0][1], 3600)
        self.assertLess(err["tot"], 1.7)  # NRMSE
Ejemplo n.º 8
0
    def test_estimation_all_args(self):
        modestga_opts = {
            'generations': 2,
            'workers': 2,
            'pop_size': 16,
            'trm_size': 3
        }
        ps_opts = {'maxiter': 3}
        session = Estimation(self.tmpdir,
                             self.fmu_path,
                             self.inp,
                             self.known,
                             self.est,
                             self.ideal,
                             lp_n=2,
                             lp_len=3600,
                             lp_frame=(0, 3600),
                             vp=(20000, 40000),
                             ic_param={'Tstart': 'T'},
                             methods=('MODESTGA', 'PS'),
                             modestga_opts=modestga_opts,
                             ps_opts=ps_opts,
                             ftype='NRMSE',
                             default_log=False)

        estimates = session.estimate()
        err, res = session.validate()  # Standard validation period
        err2, res2 = session.validate(vp=(25000, 28600))

        self.assertIsNotNone(estimates)
        self.assertGreater(len(estimates), 0)
        self.assertIsNotNone(err)
        self.assertIsNotNone(res)
        self.assertIsNotNone(err2)
        self.assertIsNotNone(res2)
        self.assertGreater(len(res.index), 1)
        self.assertGreater(len(res.columns), 0)
        self.assertGreater(len(res2.index), 1)
        self.assertGreater(len(res2.columns), 0)
        self.assertEqual(session.lp[0][0], 0)
        self.assertEqual(session.lp[0][1], 3600)
        self.assertLess(err['tot'], 1.7)  # NRMSE
Ejemplo n.º 9
0
    def test_estimation_basic(self):
        ga_opts = {'maxiter': 3}
        ps_opts = {'maxiter': 3}
        session = Estimation(self.tmpdir, self.fmu_path, self.inp,
                             self.known, self.est, self.ideal,
                             ga_opts=ga_opts, ps_opts=ps_opts)
        estimates = session.estimate()
        err, res = session.validate()

        self.assertIsNotNone(estimates)
        self.assertGreater(len(estimates), 0)
        self.assertIsNotNone(err)
        self.assertIsNotNone(res)
        self.assertGreater(len(res.index), 1)
        self.assertGreater(len(res.columns), 0)
Ejemplo n.º 10
0
    # MODEL IDENTIFICATION ==========================================
    session = Estimation(workdir,
                         fmu_path,
                         inp,
                         known,
                         est,
                         ideal,
                         lp_n=2,
                         lp_len=50000,
                         lp_frame=(0, 50000),
                         vp=(0, 50000),
                         ic_param={'Tstart': 'T'},
                         methods=('GA', 'PS'),
                         ga_opts={
                             'maxiter': 5,
                             'tol': 0.001,
                             'lhs': True
                         },
                         ps_opts={
                             'maxiter': 500,
                             'tol': 1e-6
                         },
                         scipy_opts={},
                         ftype='RMSE',
                         seed=1,
                         default_log=True,
                         logfile='simple.log')

    estimates = session.estimate()
    err, res = session.validate()