Ejemplo n.º 1
0
  public BgpAwareIGPWO(int asId, List<Integer> tmIds) {
    this(asId);

    ObjectFactory factory = new ObjectFactory();
    List list = this.getTrafficMatrix();
    for (Iterator<Integer> iter = tmIds.iterator(); iter.hasNext(); ) {
      int tmId = iter.next();
      try {
        IGPWOCalculateWeightsType.TrafficMatrixType tm =
            factory.createIGPWOCalculateWeightsTypeTrafficMatrixType();
        tm.setTMID(tmId);
        list.add(tm);
      } catch (JAXBException e) {
        logger.error(
            "JAXBException in constructor of IGPWOCalculateWeights. Message: " + e.getMessage());
        if (logger.isDebugEnabled()) {
          e.printStackTrace();
        }
        return;
      }
    }
  }
Ejemplo n.º 2
0
  /** @see be.ac.ulg.montefiore.run.totem.scenario.model.Event#action() */
  public EventResult action() throws EventExecutionException {
    logger.debug("Processing an bgpAwareIGPWO event - ASID: " + _ASID);

    try {
      int asId =
          isSetASID() ? _ASID : InterDomainManager.getInstance().getDefaultDomain().getASID();

      int[] tmIds;
      if (this.getTrafficMatrix().size() == 0) {
        tmIds = new int[] {TrafficMatrixManager.getInstance().getDefaultTrafficMatrixID(asId)};
      } else {
        List list = this.getTrafficMatrix();
        tmIds = new int[list.size()];
        int i = 0;
        for (Iterator iter = list.iterator(); iter.hasNext(); ++i) {
          IGPWOCalculateWeightsType.TrafficMatrixType tm =
              (IGPWOCalculateWeightsType.TrafficMatrixType) iter.next();
          tmIds[i] = tm.getTMID();
        }
      }
      bgpAwareIGPWO bgpAwareIgpwo =
          (bgpAwareIGPWO) RepositoryManager.getInstance().getAlgo("bgpAwareIGPWO", asId);

      int nbIter = isSetNbIter() ? _NbIter : 150;
      int maxPossibleWeight = isSetMaxPossibleWeight() ? _MaxPossibleWeight : 50;
      int seed = isSetSeed() ? _Seed : 0;
      boolean interDomainTE = isSetInterdomainTE() ? _InterdomainTE : true;

      boolean randomInitialArray = true;
      if (isSetInitialWeightArray()
          && (getInitialWeightArray() == IgpwoInitialWeightArrayType.CURRENT)) {
        randomInitialArray = false;
      }

      SamplingRateType samplingRate = getSamplingRate();
      float maxSamplingRate, minSamplingRate, initialSamplingRate;
      if (samplingRate == null) {
        maxSamplingRate = 0.4f;
        minSamplingRate = 0.01f;
        initialSamplingRate = 0.2f;
      } else {
        maxSamplingRate = samplingRate.isSetMax() ? samplingRate.getMax() : 0.4f;
        minSamplingRate = samplingRate.isSetMin() ? samplingRate.getMin() : 0.01f;
        initialSamplingRate = samplingRate.isSetInitial() ? samplingRate.getInitial() : 0.2f;
      }

      long time = System.currentTimeMillis();
      TotemActionList actionList =
          bgpAwareIgpwo.calculateWeightsParameters(
              asId,
              tmIds,
              nbIter,
              maxPossibleWeight,
              randomInitialArray,
              seed,
              minSamplingRate,
              maxSamplingRate,
              initialSamplingRate,
              interDomainTE);
      time = System.currentTimeMillis() - time;
      System.out.println(
          "bgpAwareIGPWO takes " + time + " ms to compute weights on domain ASID" + _ASID);
      logger.info("bgpAwareIGPWO takes " + time + " ms to compute weights on domain ASID" + _ASID);
      double[] newLinkWeights = null;
      for (Iterator iter = actionList.iterator(); iter.hasNext(); ) {
        TotemAction action = (TotemAction) iter.next();
        if (action instanceof UpdateIGPWeightsAction) {
          newLinkWeights = ((UpdateIGPWeightsAction) action).getWeights();
        }
        action.execute();
      }
      return new EventResult(newLinkWeights);
    } catch (Exception e) {
      logger.error("An exception occurred. Message: " + e.getMessage());
      throw new EventExecutionException(e);
    }
  }