예제 #1
0
    def test_backward_induction(self):
        T = 3
        # v_T = np.zeors(self.ddp.n)
        vs_expected = [[67 / 16, 129 / 16, 194 / 16, 227 / 16],
                       [2, 25 / 4, 10, 21 / 2], [0, 5, 6, 5], [0, 0, 0, 0]]
        sigmas_expected = [[3, 0, 0, 0], [2, 0, 0, 0], [0, 0, 0, 0]]

        vs, sigmas = backward_induction(self.ddp, T)

        assert_allclose(vs, vs_expected)
        assert_array_equal(sigmas, sigmas_expected)
예제 #2
0
    def test_backward_induction(self):
        T = 3
        # v_T = np.zeors(self.ddp.n)
        vs_expected = [[67/16, 129/16, 194/16, 227/16],
                       [2, 25/4, 10, 21/2],
                       [0, 5, 6, 5],
                       [0, 0, 0, 0]]
        sigmas_expected = [[3, 0, 0, 0],
                           [2, 0, 0, 0],
                           [0, 0, 0, 0]]

        vs, sigmas = backward_induction(self.ddp, T)

        assert_allclose(vs, vs_expected)
        assert_array_equal(sigmas, sigmas_expected)