コード例 #1
0
def default_evaluation():
    """Default evaluation of current model:

    * runs particle swarm for 600 iterations followed by
    * levelberg marquardt


    :return: found parameter values
    """
    basico.run_parameter_estimation(method='Particle Swarm', update_model=True,
                                    settings={'method': {'Iteration Limit': 600}})
    sol = basico.run_parameter_estimation(method='Levenberg - Marquardt', update_model=True)
    return sol
コード例 #2
0
 def test_change_bounds(self):
     basico.set_fit_parameters([{
         'name': '(R1).k2',
         'lower': 1,
         'upper': 0.01
     }])
     with self.assertLogs(level='ERROR') as cm:
         sol = basico.as_dict(basico.run_parameter_estimation())
     self.assertTrue(np.isnan(sol['sol']))
コード例 #3
0
    def test_get_data(self):
        data = basico.get_experiment_data_from_model()
        self.assertEqual(len(data), 5)
        set_1 = data[0]
        self.assertEqual(set_1.shape, (100, 3))

        names = basico.get_experiment_names()
        self.assertIn('Experiment', names)

        files = basico.get_experiment_filenames()
        self.assertEqual(len(files), len(names))

        set_2 = basico.get_data_from_experiment('Experiment')
        self.assertEqual(set_2.shape, (100, 3))

        sol_before = basico.run_parameter_estimation(
            method=basico.PE.CURRENT_SOLUTION)

        # remove data
        basico.remove_experiments()

        # add data back
        for exp, name in zip(data, names):
            basico.add_experiment(name, exp)

        # since we have affected experiments, reset them
        basico.set_fit_parameters(basico.get_fit_parameters())

        # save to temp file
        main_file = tempfile.mktemp()
        basico.save_model_and_data(main_file, delete_data_on_exit=True)

        # ensure it still works
        sol_after = basico.run_parameter_estimation(
            method=basico.PE.CURRENT_SOLUTION)
        self.assertListEqual(basico.as_dict(sol_before[['sol']]),
                             basico.as_dict(sol_after[['sol']]))
コード例 #4
0
 def evaluate(self):
     if self.settings is not None:
         basico.set_task_settings('Parameter Estimation', self.settings)
     return basico.run_parameter_estimation()
コード例 #5
0
 def test_statistic(self):
     basico.run_parameter_estimation(method=basico.PE.CURRENT_SOLUTION)
     result = basico.get_fit_statistic()
     self.assertTrue(result is not None)
     self.assertTrue(result['obj'] < 0.2)
コード例 #6
0
 def test_run(self):
     sol = basico.run_parameter_estimation(
         method=basico.PE.CURRENT_SOLUTION)
     self.assertTrue(sol is not None)
     self.assertAlmostEqual(sol.loc['(R1).k2'].sol, 1.0, places=2)