NetLogo / NW-Extension

This is the NetLogo Network Extension. For general information about NetLogo, see:
http://ccl.northwestern.edu/netlogo/
Other
62 stars 25 forks source link

Conditionally select subset of network based on link values (for distance-to, path-to and turtles-in-radius) #203

Open EwoutH opened 1 year ago

EwoutH commented 1 year ago

I would like to conditionally select a subset of a network based on link values to perform some functions, mainly distance-to, path-to and turtles-in-radius.

So for example, I have a network with links. Each link has either a red, green or blue color. I would like see which turtles are in a certain radius using only the green and blue links (so not red). Then I want to find a path those one of those turtles over only those green and blue links.

Is it currently possible to select such a subset of the network/links? If so, how? (I would expect something like with [color != red]). If not, it would be amazing to have this as an feature!

EwoutH commented 1 year ago

@LaCuneta or @brandesNW Any chance one of you could help out with this case?

nicolaspayette commented 1 year ago

@EwoutH, I think that nw:set-context does exactly what you need. Something like:

nw:set-context turtles links with [color != red]

should ensure that future calls to nw primitives will only take non-red links into account.

EwoutH commented 1 year ago

Thanks a lot, I will try it and report back.

Do you by any chance know if there is a "move to next turtle in route and delete that item from the route (list)" function?

I'm now using:

But I feel it should be able to be done more efficiently.

nicolaspayette commented 1 year ago

I think that

move-to first route
set route remove-item 0 route

is as good as it gets.