Replies: 1 comment 1 reply
-
Hi @dmteams , Thanks for your question - I hope we can assist. I hope you don't mind that I converted this to a discussion. One quick and dirty way to do it is to store a dictionary in the struct RideHailingEnv
s_inds::Dict{RideHailingState, Int}
# ...
end
function fill_state_inds!(m::RideHailingEnv)
for (i, s) enumerate(states(m))
m.s_inds[s] = i
end
end
POMDPs.stateindex(m::RideHailingEnv, s::RideHailingState) = m.s_inds[s] Which solver(s) are you planning to use? You may not need to define the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am currently struggling with the function stateindex at the moment of solving a simple MDP with value iteration.
Basically, my problem is the following:
I have taxis traveling around locations to serve riders. There can be a maximum of
n_cars
in the network. Thus, the state is described by two vectors. One for the number of cars in each node (I have two transit and two pick-up nodes) and one for the number of riders waiting in each location (max_wait
is the max number of riders waiting).I define:
At the moment of indexing my states, I do not exactly know how to do it efficiently. Using a typical function as CartesianIndices would not work as the number of states would be way too large.
For instance, state index would create me
n_cars^4*max_wait^2
possible indexes while I only needfactorial(n_cars+n_locations-1)/factorial(n_locations-1)*(n_cars)
indexes. Another example: if I have 5 cars,RideHailingState([3,1,2,0],[1,0])
would be indexed with CartesianIndices while actually not validI am not particularly an expert in programming. Therefore, I was wondering if there would exist a way to index the states efficiently for the problem I just described.
Thanks in advance for the reply!
Beta Was this translation helpful? Give feedback.
All reactions