def test_ExponentialFileInput(self): cf = Exponential.ExponentialCostFunction() cf.FileInit('Values/TestExponential.txt') guess = libUnfitPython.std_vector_double() guess[:] = [0, 0] cost = 0 for r in cf(guess): cost = cost + r * r self.assertAlmostEqual(cost, 1.58190784, cost_tol) self.sa.FindMin(cf, guess) self.assertAlmostEqual(guess[0], 0.999996825348, guess_tol) self.assertAlmostEqual(guess[1], 0.500017605615, guess_tol)
def test_ExponentialDirectInput(self): cf = Exponential.ExponentialCostFunction([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1.0, 0.6065, 0.3679, 0.2231, 0.1353, 0.0821, 0.0498, 0.0302, 0.0183, 0.0111, 0.0067]) guess = libUnfitPython.std_vector_double() guess[:] = [0, 0] cost = 0 for r in cf(guess): cost = cost + r * r self.assertAlmostEqual(cost, 1.58190784, cost_tol) self.ga.FindMin(cf, guess) self.assertAlmostEqual(guess[0], 1.02684400144, guess_tol) self.assertAlmostEqual(guess[1], 0.517748487134, guess_tol)