Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working when initial_value is numpy. #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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