I am still interested in knowing who (meaning other turtles) are linked to a given turtle, either to or from. Is this data available to be accessed through LinkManager and if so, do you have a suggestion for how to do so?

For clarity, I'd like to point out that links are created with the `create-link*` primitives <http://ccl.northwestern.edu/netlogo/docs/dictionary.html#linkgroup>. That is, links between turtles are created in your model's NetLogo code. To get at link information from within Java code, you /could/ use `LinkManager` and its `findLink*` methods, but I don't see those methods as helpful for visualization purposes. Instead, I think you would want to get a handle on the collection of links in the model, which you can do by using `workspace.world().links()` (similar to how you got ahold of the turtles). Then, you can iterate over the collection, looking at each link, looking up the corresponding turtle on each end, and drawing the visual link between them.

And is "who is linked to who" part of the updates provided in the diffs method of Mirroring?

Yes, updates are given with information about newly-created, modified, and deleted links. Link updates are their own category of updates (alongside the categories for patches, turtles, and the "observer").

On 05/19/2014 03:40 PM, Brant Horio wrote:
Many thanks Jason for the quick reply. Yes, you are correct that I want to run NetLogo headlessly and provide my own version of the NetLogo view. This visualization is using Processing and will for the most part act independently from what the NetLogo view has been coded to show in the model. I'll look into the Mirroring, many thanks as I had not known about that.

A quick comment regarding the links: I am still interested in knowing who (meaning other turtles) are linked to a given turtle, either to or from. Is this data available to be accessed through LinkManager and if so, do you have a suggestion for how to do so? And is "who is linked to who" part of the updates provided in the diffs method of Mirroring?

Thanks for your patience with me. I really appreciate your time.

Thanks,
Brant


On Monday, May 19, 2014 4:06:52 PM UTC-4, Jason Bertsche wrote:

    `LinkManager` is for NetLogo links
    <http://ccl.northwestern.edu/netlogo/5.0/docs/programming.html#links>,
    which are a type of visible agent in NetLogo and not exactly an
    abstraction for data correlation.

    What's the purpose of your correlation of turtles with other
    data?  NetLogo doesn't really have anything built in for saying
    that a turtle is related to some other data. I'm not sure I'm
    understanding your goals correctly, but, if I am, it sounds like
    you just want to run NetLogo headlessly and provide your own
    version of the NetLogo view, which, of course, is kept in sync
    with the state of the model as it progresses.  Is that right?  If
    so, and if you're dealing with the code from the 'headless' branch
    of NetLogo, then take of a look at 'org.nlogo.mirror.Mirroring
<https://github.com/NetLogo/NetLogo/blob/headless/src/main/mirror/Mirroring.scala>'. Using that and its `diffs` method, you can find out what variables
    have changed in the model since your last snapshot, and then
    update your visualization according to that diff.

    On 05/19/2014 02:01 PM, Brant Horio wrote:
    Hello all,

    I am currently working on calling NetLogo headless from Java for
    the purposes of doing my own non-NetLogo visualization, primarily
    as just an exploratory programming exercise. I am coding in Java
    and have been able to successfully read in and iterate through
    the turtle agent list, reading in agent attribute values,
    coordinate positions, etc, for the visualization. I do so by:

    public static HeadlessWorkspace workspace =
    HeadlessWorkspace.newInstance( );
    public static Iterable<Agent> netLogoAgentList;

    netLogoAgentList = workspace.world( ).turtles( ).agents( );

    ... after which I iterate through netLogoAgentList to get the
    variable values, etc that I need for my visualization.


    What I am envisioning is that for each of these agents read in, I
    create an agent object in Java that carries the read in variable
    updates from its NetLogo counterpart and my own methods for the
    visualization. I also want these agent object to carry with them
    an ArrayList of other agent objects that they are "linked" with,
    as informed to them by updates from the NetLogo model. Are there
    any suggestions out there for the best way for me to do so? I
    suspect it will involve LinkManager, in particular
    LinkManager.findLinksWith( ).

    My current strategy (though I have found no success yet) is to do
    the following:

     1. iterate through netLogoAgentList, and cast as (Turtle).
          * netLogoAgentList = workspace.world( ).turtles( ).agents( );
          * for (Agent t : netLogoAgentList)
            {
                 Turtle tmpAgent = (Turtle)
            workspace.world().turtles().agent(t);
            }
     2. for each Turtle agent, tmpAgent, call
        LinkManager.findLinksWith( ), using tmpAgent and
        workspace.world( ).turtles( ) as arguments, the idea being I
        can get back an agent set of all turtles linked to or from
        turtle tmpAgent.
     3. Store the linked turtles to my Java agent object in the
        previously mentioned ArrayList, allowing me to later iterate
        through the list and plot out the links in the NetLogo
        network in my visualization.

    I am produce perhaps some of the ugliest code around so I
    apologize if I'm totally off base in my pseudo
    code/approach/thought process. I have tried a bunch of different
    things though and cannot seem to get what *I think* I should be
    able to get back from LinkManager, which is the turtles that each
    one is linked from/to. Any advice for how to best access the API
    to get this data would be very much appreciated.

    THANK YOU IN ADVANCE!!!

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