Package jmt.gui.common.routingStrategies

Examples of jmt.gui.common.routingStrategies.RoutingStrategy


   * @param warnings vector Vector to store warnings found during computation
   * @return an array with probability to reach each other station starting from given station
   */
  private static double[] getRoutingProbability(Object stationKey, Object classKey, CommonModel model, List<Object> stations, List<String> warnings) {
    double[] p = new double[stations.size()];
    RoutingStrategy strategy = (RoutingStrategy) model.getRoutingStrategy(stationKey, classKey);
    if (strategy instanceof ProbabilityRouting && !model.getStationType(stationKey).equals(CommonConstants.STATION_TYPE_FORK)) {
      Map routingMap = strategy.getValues();
      Iterator it = routingMap.keySet().iterator();
      while (it.hasNext()) {
        Object dest = it.next();
        if (stations.lastIndexOf(dest) >= 0) {
          p[stations.lastIndexOf(dest)] = ((Double) routingMap.get(dest)).doubleValue();
        }
      }
    } else {
      if (model.getStationType(stationKey).equals(CommonConstants.STATION_TYPE_FORK)) {
        warnings.add("Fork-Join are not supported in JMVA. They are considered as routers.");
      } else if (!(strategy instanceof RandomRouting)) {
        warnings.add("\"" + strategy.getName() + "\" routing strategy in " + model.getClassName(classKey) + " for "
            + model.getStationName(stationKey) + " is not allowed. This was considered as RandomRouting");
      }

      Vector<Object> links = model.getForwardConnections(stationKey);
      int linksNum = links.size();
View Full Code Here


    private void checkForLoadDependentRoutingError() {
        //Step 1 : Find all stations.
        for(Object stationKey : station_def.getStationKeys()) {
            //Step 2: check Routing for each class of the station
            for(Object classKey : class_def.getClassKeys()) {
                RoutingStrategy rs = (RoutingStrategy) station_def.getRoutingStrategy(stationKey, classKey);
                if(rs instanceof LoadDependentRouting){
                    List<String> errorMsgs = ((LoadDependentRouting) rs).validate();
                    if(errorMsgs != null && errorMsgs.size() > 0){
                        errors[LOAD_DEPENDENT_ROUTING_INVALID] = true;
                        HashMap innerVal = new HashMap<Object, Object>();
View Full Code Here

    Vector<Object> classes = class_def.getClassKeys();
    for (int i = 0; i < stations.size(); i++) {
      Object thisStation = stations.get(i);
      for (int j = 0; j < classes.size(); j++) {
        Object thisClass = classes.get(j);
        RoutingStrategy thisRoutingStrategy = (RoutingStrategy) station_def.getRoutingStrategy(thisStation, thisClass);
        if (thisRoutingStrategy != null) {
          if (thisRoutingStrategy.isModelStateDependent()) {
            BCMPnonStateIndependentRoutingStations.add(thisStation);
            warnings[BCMP_NON_STATE_INDEPENDENT_ROUTING_WARNING] = true;
            break;
          }
        }
View Full Code Here

      //... if it has not been explored yet ...
      if (!alreadyVisited.contains(thisForwardStation)) {
        //... add the element to the alreadyVisited vector ...
        alreadyVisited.add(thisForwardStation);
        // ... get the routing strategy for the class in the starting station ...
        RoutingStrategy strategy = (RoutingStrategy) station_def.getRoutingStrategy(startingStationKey, classKey);
        // ... if thisForwardStation is a Sink ...
        if (station_def.getStationType(thisForwardStation).equals(STATION_TYPE_SINK)) {
          // ... if the routing strategy is the Probability Routing ...
          if (strategy instanceof ProbabilityRouting) {
            Map probabilities = strategy.getValues();
            // ... get the routing probability toward thisForwardStation ...
            double p = ((Double) probabilities.get(thisForwardStation)).doubleValue();
            // ... if p = 1 there is an error, put startingStationKey into the
            // toBeReturned vector ...
            if (p == 1) {
              toBeReturned.add(startingStationKey);
            }
          }
        }
        // ... else thisForwardStation isn't a Sink ...
        else {
          Vector<Object> temp;
          // ... if the routing policy is ProbabilityRouting ...
          if (strategy instanceof ProbabilityRouting) {
            Map probabilities = strategy.getValues();
            // ... get the routing probability toward thisForwardStation ...
            double p = ((Double) probabilities.get(thisForwardStation)).doubleValue();
            // ... if p != 0 start exploring from thisForwardStation and collect
            // the returned vector into temp ...
            if (p != 0) {
View Full Code Here

          //... add the element to the alreadyVisited vector ...
          alreadyVisited.add(thisForwardStation);
          // ... if thisForwardStation is not a Sink ...
          if (!station_def.getStationType(thisForwardStation).equals(STATION_TYPE_SINK)) {
            // ... get the routing strategy for the class in the starting station ...
            RoutingStrategy strategy = (RoutingStrategy) station_def.getRoutingStrategy(startingStationKey, classKey);
            if (strategy instanceof ProbabilityRouting) {
              Map probabilities = strategy.getValues();
              // ... get the routing probability toward thisForwardStation ...
              double p = ((Double) probabilities.get(thisForwardStation)).doubleValue();
              // ... if p != 0 start exploring from thisForwardStation and collect
              // the returned vector into temp ...
              if (p != 0) {
View Full Code Here

    Vector<Object> classes = class_def.getClassKeys();
    for (int i = 0; i < BCMPnonStateIndependentRoutingStations.size(); i++) {
      Object thisStation = BCMPnonStateIndependentRoutingStations.get(i);
      for (int j = 0; j < classes.size(); j++) {
        Object thisClass = classes.get(j);
        RoutingStrategy rs = (RoutingStrategy) station_def.getRoutingStrategy(thisStation, thisClass);
        if (rs.isModelStateDependent()) {
          station_def.setRoutingStrategy(thisStation, thisClass, new RandomRouting());
        }
      }
    }
  }
View Full Code Here

    /*        if(stationKey==null||classKey==null||sd==null){
                emptyPane();
                return;
            }
    */
        RoutingStrategy rs = (RoutingStrategy) sd.getRoutingStrategy(stationKey, classKey);
    if (rs == null) {
      emptyPane();
    } else {
      descrTextPane.setText(rs.getDescription());
      /*if (rs.getValues() == null) {
        emptyPane();
      } else {
        createDetails(rs, sd, stationKey, classKey);
      }*/
 
View Full Code Here

      Vector<Object> bacwardStationKeys = this.getBackwardConnections(key);
            for(Iterator<Object> it = bacwardStationKeys.iterator(); it.hasNext();){
                Object stationKey = it.next();
                Vector<Object> classKeys = this.getClassKeys();
                for(Object classKey : classKeys){
                    RoutingStrategy rs = (RoutingStrategy)this.getRoutingStrategy(stationKey, classKey);
                    if(rs instanceof LoadDependentRouting){
                        LoadDependentRouting ld = (LoadDependentRouting) rs;
                        ld.refreshRoutingOnStationDeletion(this.getStationName(key));
                    }
                }
View Full Code Here

    // Sets correct station key into every empiricalRouting element
    // Now each key is an Object[] where (0) is station key and (1) class key
    keys = empiricalRouting.keySet().toArray();
    for (Object key : keys) {
      Object[] dualkey = (Object[]) key;
      RoutingStrategy rs = (RoutingStrategy) model.getRoutingStrategy(dualkey[0], dualkey[1]);
      Map<Object, Double> routing = rs.getValues();
      Map<String, Double> values = empiricalRouting.get(key);
      Object[] names = values.keySet().toArray();
      // Creates correct hashmap with station key --> probability mapping
      for (Object name : names) {
        routing.put(stations.get(name), values.get(name));
View Full Code Here

          model.setRoutingStrategy(key, classes.get(className2), engineToGuiRouting.get(routStratKey).clone());
        }
      }

      // Treat particular case of Empirical (Probabilities) Routing
      RoutingStrategy rs = (RoutingStrategy) model.getRoutingStrategy(key, classes.get(className2));
      if (rs instanceof ProbabilityRouting) {
        // Creates a Vector of all empirical entris. Could not be done automaticly
        // for the above problem with array (see parseParameterRefclassArray)
        Vector<Node> entries = new Vector<Node>();
        // Finds EntryArray node
View Full Code Here

TOP

Related Classes of jmt.gui.common.routingStrategies.RoutingStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.