Print

Print


Bug report in Network class, addeEdge(Edge e) method Sorry if this is not the right place to post a bug report, but I couldn’t find any other list or email address on the MASON page.

Details below.

Russ

------

The suspected bug is in the “addEdge(Edge e)” method of the Network class. I get a exception: “Attempted to add an Edge already added elsewhere” when actually the network is empty after a clear().

Context: Prior to the code snippet shown, I have initialized a network “consumerSocialNetwork” and have been updating it for many steps during the priming process for my agents.  Once priming is complete, I want to reset the network to its initial topology and continue the run.

This code works:
       consumerSocialNetwork.clear();       
        Edge [][] e = softRestartSocialNetwork.getAdjacencyMatrix();
        for (int i = 0; i < e.length; i++){
            for (int j = i + 1; j < e[i].length; j++){
                if (e[i][j]!=null){
                  Consumer from = (Consumer)e[i][j].from();
                  Consumer to = (Consumer)e[i][j].to();
                  SocialTie tie = (SocialTie)e[i][j].getInfo();
                  consumerSocialNetwork.addEdge(from,to,tie);
                }
            }
        }
---------------------------------------------------
This code, which should be equivalent, does not work:
       consumerSocialNetwork.clear();       
        Edge [][] e = softRestartSocialNetwork.getAdjacencyMatrix();
        
        for (int i = 0; i < e.length; i++){
            for (int j = i + 1; j < e[i].length; j++){
                if (e[i][j]!=null){  
                  consumerSocialNetwork.addEdge(e[i][j]);
                }
            }
        }
------------------------------------------------
OUTPUT
Diagnostic print statement for e[i][j], i = 0, j = 1:

   array indices = (0, 1); edge = Edge[agents.Consumer@7031086c<->agents.Consumer@2670d85b: valueNets.SocialTie@e74917]

Error message:
java.lang.RuntimeException: Attempted to add an Edge already added elsewhere
       at sim.field.network.Network.addEdge(Network.java:355)
        at valueNets.ValueNets.softRestart(ValueNets.java:1600)
        at valueNets.ValueNets.access$000(ValueNets.java:73)
        at valueNets.ValueNets$2.step(ValueNets.java:1384)
        at sim.engine.Repeat.step(Schedule.java:766)
        at sim.engine.Schedule.step(Schedule.java:324)
        at sim.display.GUIState.step(GUIState.java:462)
        at sim.display.Console$58.run(Console.java:2532)
        at java.lang.Thread.run(Thread.java:680)