Esempio n. 1
1
  public double getNormalizedActivatedRate() {
    LoadUnloadEdge labeledEdge = (LoadUnloadEdge) this.getEdge();

    Node source = labeledEdge.getA();
    PacketStyleTransportSystem transSystem =
        (PacketStyleTransportSystem)
            ((labeledEdge.isLoadingEdge()) ? (labeledEdge.getB()) : (labeledEdge.getA()));

    Collection<NodeLabel> lbls = source.getLabels();
    double sourcePop = 0;

    // Get the population size of the source node
    for (Iterator<NodeLabel> it = lbls.iterator(); it.hasNext(); ) {
      NodeLabel lbl = it.next();
      if (lbl instanceof PopulationLabel) {
        sourcePop = ((PopulationLabelValue) ((PopulationLabel) lbl).getCurrentValue()).getCount();
        break;
      }
    }
    assert sourcePop > 0;

    lbls = transSystem.getLabels();
    double transCapacity = 0;

    // Get the capacity of the packet transport label
    for (Iterator<NodeLabel> it = lbls.iterator(); it.hasNext(); ) {
      NodeLabel lbl = it.next();
      if (lbl instanceof PacketTransportLabel) {
        transCapacity = ((PacketTransportLabel) lbl).getCurrentValue().getCapacity();
        break;
      }
    }

    return getActivatedRate() * transCapacity / sourcePop;
  }
Esempio n. 2
0
  /** @see org.eclipse.stem.common.impl.IdentifiableImpl#sane() */
  @Override
  public boolean sane() {
    boolean retValue = super.sane();

    // This is the number of labels that each node references
    int nodeLabelCount = 0;
    int dynamicLabelCount = 0;

    // Nodes
    if (nodes != null) {
      // Yes
      for (final Iterator<Node> nodeIter = getNodes().values().iterator();
          nodeIter.hasNext() && retValue; ) {
        final Node node = nodeIter.next();
        retValue = retValue && node.sane();
        assert retValue;

        nodeLabelCount += node.getLabels().size();

        // How many dynamic labels?
        for (final Iterator<NodeLabel> labelIter = node.getLabels().iterator();
            labelIter.hasNext(); ) {
          final Label label = labelIter.next();
          if (label instanceof DynamicLabel) {
            dynamicLabelCount++;
            retValue = false;

            // The dynamic label should be in the collection of
            // dynamic labels maintained by the graph
            for (DynamicLabel dl : getDynamicLabels()) {
              if (dl == label) {
                retValue = true;
                break;
              }
            } // for each dynamic label
            assert retValue;
          } // if DynamicLabel
          // The label should be in the collection of node labels
          retValue = retValue && getNodeLabels().containsKey(label.getURI());
          assert retValue;
        } // for each label of the node
      } // for each node
    } // if

    // Edges?
    if (edges != null) {
      // Yes
      for (final Iterator<Edge> edgeIter = getEdges().values().iterator();
          edgeIter.hasNext() && retValue; ) {
        final Edge edge = edgeIter.next();
        retValue = retValue && edge.sane();
        assert retValue;

        // Is the edge's label dynamic?
        if (edge.getLabel() instanceof DynamicLabel) {
          // Yes
          dynamicLabelCount++;
        }
      } // for each edge
    } // if

    // Node Labels?
    if (nodeLabels != null) {
      // Yes
      // The number of node labels should match the number we counted
      // above...not true for graph fragments that might have labels for
      // nodes in other (sub) graph fragments.
      // retValue = retValue && nodeLabelCount ==
      // getNodeLabels().getSize();
      // assert retValue;

      for (final Iterator<NodeLabel> labelIter = getNodeLabels().values().iterator();
          labelIter.hasNext() && retValue; ) {
        final NodeLabel nodeLabel = labelIter.next();
        retValue = retValue && nodeLabel.sane();
        assert retValue;
      } // for each node label
    } // if

    if (graphLabels != null) {
      // Yes
      for (final Iterator<Label> graphLabelIter = getGraphLabels().values().iterator();
          graphLabelIter.hasNext(); ) {
        final Label graphLabel = graphLabelIter.next();
        retValue = retValue && graphLabel.sane();
        assert retValue;

        if (graphLabel instanceof DynamicLabel) {
          dynamicLabelCount++;
        }
      }
    } // if graphLabels

    // Dynamic Labels?
    if (dynamicLabels != null) {
      // Yes
      // The number of dynamic labels should equal the count
      retValue = dynamicLabelCount == getNumDynamicLabels();
      assert retValue;

      for (final Iterator<DynamicLabel> dynamiclIter = getDynamicLabels().iterator();
          dynamiclIter.hasNext() && retValue; ) {
        final DynamicLabel dynamicLabel = dynamiclIter.next();
        retValue = retValue && dynamicLabel.sane();
        assert retValue;
      } // for each dynamic label
    } // if

    return retValue;
  } // sane
Esempio n. 3
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated NOT
  */
 public void putNode(Node node) {
   getNodes().put(node.getURI(), node);
   for (NodeLabel nodeLabel : node.getLabels()) {
     putNodeLabel(nodeLabel);
   } // for each NodeLabel
 } // putNode