We've definitely discussed the idea of bag/multiset support in NetLogo
before, but, as was already noted in this thread, it would be a
substantial thing to introduce. In this particular situation, it seems
like the use case for multisets is not terribly difficult to work
around, but I'd be interested to hear about other cases in which people
might find multisets useful. If there's enough need for it, multiset
support could /possibly/ be added, but my intuition is that the need
didn't seem to arise in the first 15 years of NetLogo's history, so what
would cause it to arise now? I suspect it might also be opposed on
grounds of complicating the language. Either way, I think it's an
interesting idea worth discussing.
On 02/06/2015 11:18 AM, Bryan Head wrote:
Glad you think that will work for you. I should note that if you want
to reproduce the random ordering behavior of `ask` and `with`, just
put `shuffle` before `agent-list`. For instance `foreach shuffle
agent-list [ ... ]` and `map [...] shuffle agent-list`. You'll take a
performance hit, but then they will behave more like the agentset
primitives, and you won't see artifacts cropping up from using the
same order every time.
On Fri Feb 06 2015 at 11:11:13 AM Marshall <[email protected]
<mailto:[email protected]>> wrote:
Thanks Bryan--That's a good solution. Hadn't thought of it.
(Seems obvious, now!) I'll probably do that. And I appreciate
knowing that uniqueness is deeply embedded in the nature of agentsets.
Roman, you're right--I should have called that what I was
proposing an "agentmultiset".
On Friday, February 6, 2015 at 10:30:05 AM UTC-6, Bryan Head wrote:
Hi Marshall,
Writing you're own ask-procedure that operates on lists could
be a pretty easy workaround. For instance:
to ask-list [ agent-list commands ]
foreach agent-list [ ask ? [ run commands ] ]
end
which you then call like:
ask-list agents-with-repeats task [ do-stuff ]
Where `agents-with-repeats` is your list of agents. Note the
`task` primitive is unfortunately required. Besides that, this
should pretty much be a drop-in replacement for `ask` after
you switch to using a list. `of` could be similarly transformed:
to-report of-list [ agent-list reporter ]
report map [ [ runresult reporter ] of ? ] agent-list
end
Called like: of-list agents-with-repeats task [ turtle-variable ]
Now `with`:
to-report with-list [ agent-list predicate ]
report filter [ [ runresult reporter ] of ? ] agent-list
end
Called like: with-list agents-with-repeats task [
turtle-variable = 5 ]
Besides reordering arguments and requiring `task`, these
should pretty much be drop-in replacements for their agentset
counterparts. As you said, the uniqueness of agents in
agentsets is quite baked in.
Hope that helps!
Bryan
On Fri Feb 06 2015 at 10:00:48 AM Marshall
<[email protected]> wrote:
A model I'm working on includes a series of functions that
implement a random choice of turtles that will send
messages to another turtle. Recently, I decided it might
be better to allow the selection of senders to be random
with repeats. Nicolas Payette's rnd extension
<https://github.com/NetLogo/Rnd-Extension> provides a
convenient function that provides this functionality,
returning a list that may contain
repeats:|||weighted-n-of-with-repeats|. (Thanks Nicolas!)
However, converting a list of turtles with repeats into a
turtleset loses the repeats; agentsets contain only unique
elements. So if I want to allow repeats in the turtles
that send messages, I have to rewrite a small but
significant bit of code in different functions, replacing
ask's with loops, etc.
Question: Might it be useful to allow a new kind of
agentset that allows repeats? It would be useful to me in
this situation, but I know that the idea violates
longstanding assumptions about agentsets, and I suspect
that it would also require a lot of changes to the NetLogo
source to implement.
I thought I'd raise it as a question, anyway, to see what
others think.
--
You received this message because you are subscribed to
the Google Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.