Then again, maybe there's been a qualitative change, in recent years, in the NetLogo community and the uses to which NetLogo is being put. (An emergent phenomenon!) So maybe the past isn't a reliable indicator of future needs.

That's fair.

Does it complicate the NetLogo language, though, if agentset primitives knew how to deal with "agentbags". Maybe there's something I'm not seeing.

Bags and sets are two things that you can use very similarly, but they can lead to very different behavior in a model. If someone is writing code that deals with bags and sets, there will be cognitive overhead to keeping track of which variables hold which of the structures (i.e. agentsets or agentbags), and knowing the difference between the two structures, and knowing when to use which structure. Not saying that it's the end of the world, but I think added cognitive overhead is something that's important to take into consideration—especially in a language like NetLogo that aims to have a low barrier to entry.

Regarding debugging, if you're in a situation where you think you have an agentset but truly have an agentbag (or vice versa), figuring out why your model is misbehaving might not be so easy. In fact, you might never realize at all! I think the reason that this isn't currently a problem in NetLogo is because all of the NetLogo collections—all two of them, plus those provided by extensions—use a very noticeably different set of primitives. There's some overlap in the vocabularies of lists and agentsets, but not a whole lot.

On 02/06/2015 12:09 PM, Marshall wrote:


On Friday, February 6, 2015 at 11:34:30 AM UTC-6, Jason Bertsche wrote:

    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?


Maybe it's significant that it wasn't until two years ago that there was enough motivation for someone (Nicolas) to introduce the *rnd* extension with more flexible agent selection options. To me those functions seem very valuable, but the NetLogo community got by without them for a long time. (I didn't need one until yesterday!)

Then again, maybe there's been a qualitative change, in recent years, in the NetLogo community and the uses to which NetLogo is being put. (An emergent phenomenon!) So maybe the past isn't a reliable indicator of future needs.

    I suspect it might also be opposed on grounds of complicating the
    language.


I can easily understand that it would complicate the source code, and that that might be enough to make it not worth adding "agentbags". Does it complicate the NetLogo language, though, if agentset primitives knew how to deal with "agentbags". Maybe there's something I'm not seeing.

    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]
    <javascript:>> 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
                <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]
        <javascript:>.
        For more options, visit https://groups.google.com/d/optout
        <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] <javascript:>.
    For more options, visit https://groups.google.com/d/optout
    <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.

Reply via email to