Example #1
0
 def test_obs1(self):
     model = RecursiveLogitModelEstimation(
         network_struct,
         observations_record=[input_obs[0]],
         initial_beta=-0.4,
         mu=1,
         optimiser=optimiser)
     ll = model.get_log_likelihood()[0]
     start_link_ind, fin_link_ind = model._compute_obs_path_indices(
         ak.from_iter(input_obs[0]))
     assert tuple(start_link_ind) == (0, 1, 2)
     assert tuple(fin_link_ind) == (1, 2, 1)
     assert (pytest.approx(
         model.get_short_term_utility()[start_link_ind,
                                        fin_link_ind].sum()) == -4.4)
     assert pytest.approx(ll, abs=1e-6) == 2.537993985
Example #2
0
    def test_obs2(self):
        obs = [input_obs[1]]
        model = RecursiveLogitModelEstimation(network_struct,
                                              observations_record=obs,
                                              initial_beta=-0.4,
                                              mu=1,
                                              optimiser=optimiser)
        ll = model.get_log_likelihood()[0]

        start_link_ind, fin_link_ind = model._compute_obs_path_indices(
            ak.from_iter(obs[0]))
        assert tuple(start_link_ind) == (0, 3, 0)
        assert tuple(fin_link_ind) == (3, 0, 1)
        assert (pytest.approx(
            model.get_short_term_utility()[start_link_ind,
                                           fin_link_ind].sum()) == -5.2)

        print(model.get_short_term_utility()[start_link_ind,
                                             fin_link_ind].sum())
        assert pytest.approx(ll) == 3.337993985