0

I am modeling a supply chain with an customer, retailer and supplier. They are connected in a node. I have found this code. But I do not understand, why this code creates the double amount of outedges. Perhaps, someone can help?

      while (it.hasNext()) {
                // Find the next agent to link to.
                tempAgent = (supply_chain_agent) it.next();
                System.out.println(tempAgent);


                // Create an edge from the last agent to the temp agent.
                tempEdge = new supply_chain_edge("Orders", 1, this.initialOrderPerTimeStep);

                // Connect the new edge.
                tempAgent.addInEdge(tempEdge);
                System.out.println(tempEdge.getLabel());

                lastAgent.addOutEdge(tempEdge);
                System.out.println(tempEdge.getLabel());

                tempEdge.setTo(tempAgent);
                tempEdge.setFrom(lastAgent);

                // Create an edge from the temp agent to the last agent.
                if (lastAgent.getNodeLabel().startsWith("Customer")) {
                    tempEdge = new supply_chain_edge("Shipments", this.ordering_delay, this.initialOrderPerTimeStep);
                } else {
                    tempEdge = new supply_chain_edge("Shipments", this.delivery_delay, this.initialOrderPerTimeStep);
                }

                // Connect the new edge.
                lastAgent.addInEdge(tempEdge);
                System.out.println(tempEdge.getLabel());

                tempAgent.addOutEdge(tempEdge);
                System.out.println(tempEdge.getLabel());

                tempEdge.setTo(lastAgent);
                tempEdge.setFrom(tempAgent);

                // Move on.
                lastAgent = tempAgent;
                System.out.println(lastAgent);

            }
  • please provide some more code – Harmeet Singh Aug 02 '12 at 06:03
  • Since you're dealing with "orders" and "shipments", you might consider renaming "OutEdge" because, in spoken English, it sounds like "outage" -- in other words, a complete lack of stock. – chb Aug 03 '12 at 01:58

0 Answers0