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

Use LightGraphs.jl API to check whether undirected graph edge in the graph rather than collected edgelist #4

Open
rejuvyesh opened this issue Jan 12, 2022 · 4 comments

Comments

@rejuvyesh
Copy link
Member

nbrs = neighbors(tree.coordination_stats.adjmatgraph, i)
edgelist = collect(edges(adjgraphmat))
if tree.coordination_stats.use_agent_utils
@views q_values[i, :] = state_stats.agent_action_q[i, :]/n_agents
end
for n in nbrs
if Edge(i,n) in edgelist # use backward message
q_values[i,:] += bwd_messages[findfirst(isequal(Edge(i,n)), edgelist), :]
elseif Edge(n,i) in edgelist
q_values[i,:] += fwd_messages[findfirst(isequal(Edge(n,i)), edgelist), :]
else
@warn "Neither edge found!"
end
end
end

Thanks @freemin7 for bringing this to our attention on slack.

@rejuvyesh
Copy link
Member Author

rejuvyesh commented Jan 14, 2022

The correct way it seems will be to check has_edge(adjmatgraph, Edge(i,n)) or has_edge(adjmatgraph, Edge(n,i)) and use the appropriate bwd_messages then:

for n in nbrs
  if has_edge(tree.coordination_stats.adjmatgraph, Edge(i,n))
    e = Edge(i, n)
  elseif has_edge(tree.coordination_stats.adjmatgraph, Edge(n,i))
    e = Edge(n, i)
  end
  q_values[i,:] += bwd_messages[findfirst(isequal(e), edgelist), :] 
end

@freemin7
Copy link

So does that mean that the current implementation is somehow "wrong"?

@rejuvyesh
Copy link
Member Author

I'll have to run some experiments and check if we even ever hit the else case in the current version.

@alexkoven
Copy link

Is there any updates on this?

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

No branches or pull requests

3 participants