Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

stateindex for MDP without CartesianIndices #332

Closed
dmteams opened this issue Jan 31, 2021 · 0 comments
Closed

stateindex for MDP without CartesianIndices #332

dmteams opened this issue Jan 31, 2021 · 0 comments

Comments

@dmteams
Copy link

dmteams commented Jan 31, 2021

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:

function POMDPs.states(mdp::RideHailingEnv)
    s = RideHailingState[] # initialize an array of RideHailingStates

    #loop over all our states
    for i = 0:mdp.n_cars, j = 0:mdp.n_cars, k = 0:mdp.n_cars, l = 0:mdp.n_cars, m = 0:mdp.max_wait, n = 0:mdp.max_wait

        if i+j+k+l==mdp.n_cars
            push!(s, RideHailingState([i,j,k,l],[m,n]))
        end
    end
    return s
end;

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 need factorial(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 valid

I 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!

@zsunberg zsunberg closed this as completed Feb 2, 2021
@JuliaPOMDP JuliaPOMDP locked and limited conversation to collaborators Feb 2, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants