Skip to content

Not working when initial_value is numpy.#43

Open
Al17OTON wants to merge 1 commit intosawcordwell:masterfrom
Al17OTON:patch-1
Open

Not working when initial_value is numpy.#43
Al17OTON wants to merge 1 commit intosawcordwell:masterfrom
Al17OTON:patch-1

Conversation

@Al17OTON
Copy link

@Al17OTON Al17OTON commented Jun 4, 2023

In ValueIteration, Numpy and Integer can't be compared when initial_value is given as numpy.

vi = mdptoolbox.mdp.ValueIteration(P,R,discount, initial_value=initial_values)

If initial_values is integer and greater than zero. len(integer) won't work.
Or initial_values is Numpy and it's Lengths are exactly same as S (states). initial_value == 0 won't work.
and will make Error.
"""
import mdptoolbox.example
import mdptoolbox.mdp
import numpy as np

P,R = mdptoolbox.example.forest()

initial_values = np.array([ # Forest have three state.
0,0,0
])

discount = 0.96

vi = mdptoolbox.mdp.ValueIteration(P,R,discount, initial_value=initial_values)

vi.run()

print(vi.V)

#expected : (5.93215488, 9.38815488, 13.38815488)

#result : ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
"""

In ValueIteration, Numpy and Integer can't be compared when initial_value is given as numpy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant