Ejemplo n.º 1
0
  /** reads all activity utility values from the config-file */
  private static final void readUtilityValues(PlanCalcScoreConfigGroup config) {
    for (ActivityParams params : config.getActivityParams()) {
      //			String type = params.getType();
      //			double priority = params.getPriority();
      //			double typDurationSecs = params.getTypicalDuration();
      //			ActivityUtilityParameters actParams = new ActivityUtilityParameters(type, priority,
      // typDurationSecs);
      //			if (params.getMinimalDuration() >= 0) {
      //				actParams.setMinimalDuration(params.getMinimalDuration());
      //			}
      //			if (params.getOpeningTime() >= 0) {
      //				actParams.setOpeningTime(params.getOpeningTime());
      //			}
      //			if (params.getLatestStartTime() >= 0) {
      //				actParams.setLatestStartTime(params.getLatestStartTime());
      //			}
      //			if (params.getEarliestEndTime() >= 0) {
      //				actParams.setEarliestEndTime(params.getEarliestEndTime());
      //			}
      //			if (params.getClosingTime() >= 0) {
      //				actParams.setClosingTime(params.getClosingTime());
      //			}
      //			utilParams.put(type, actParams);

      ActivityUtilityParameters.Builder factory = new ActivityUtilityParameters.Builder(params);
      if (params.getActivityType().equals(PtConstants.TRANSIT_ACTIVITY_TYPE)) {
        factory.setScoreAtAll(false);
      }
      utilParams.put(params.getActivityType(), factory.build());
    }
  }
  public PersonalScoringParameters(final PlanCalcScoreConfigGroup config) {
    this.usingOldScoringBelowZeroUtilityDuration =
        config.isUsingOldScoringBelowZeroUtilityDuration();

    marginalUtilityOfWaiting_s = config.getMarginalUtlOfWaiting_utils_hr() / 3600.0;
    marginalUtilityOfLateArrival_s = config.getLateArrival_utils_hr() / 3600.0;
    marginalUtilityOfEarlyDeparture_s = config.getEarlyDeparture_utils_hr() / 3600.0;
    marginalUtilityOfWaitingPt_s = config.getMarginalUtlOfWaitingPt_utils_hr() / 3600.0;
    marginalUtilityOfPerforming_s = config.getPerforming_utils_hr() / 3600.0;
    utilityOfLineSwitch = config.getUtilityOfLineSwitch();
    marginalUtilityOfMoney = config.getMarginalUtilityOfMoney();
    scoreActs =
        marginalUtilityOfPerforming_s != 0
            || marginalUtilityOfWaiting_s != 0
            || marginalUtilityOfLateArrival_s != 0
            || marginalUtilityOfEarlyDeparture_s != 0;

    SortedMap<String, ActivityUtilityParameters> tmpUtlParams =
        new TreeMap<String, ActivityUtilityParameters>();
    for (ActivityParams params : config.getActivityParams()) {
      ActivityUtilityParameters.Builder factory = new ActivityUtilityParameters.Builder(params);
      // the following was introduced in nov'12.  Also see setupTransitSimulation in Controler.
      // kai, nov'12
      if (params.getActivityType().equals(PtConstants.TRANSIT_ACTIVITY_TYPE)) {
        factory.setScoreAtAll(false);
      }
      tmpUtlParams.put(params.getActivityType(), factory.create());
    }
    utilParams = Collections.unmodifiableMap(tmpUtlParams);

    SortedMap<String, Mode> tmpModeParams = new TreeMap<String, Mode>();
    Map<String, ModeParams> modes = config.getModes();
    double worstMarginalUtilityOfTraveling_s = 0.0;
    for (Entry<String, ModeParams> mode : modes.entrySet()) {
      String modeName = mode.getKey();
      ModeParams modeParams = mode.getValue();
      double marginalUtilityOfTraveling_s = modeParams.getMarginalUtilityOfTraveling() / 3600.0;
      worstMarginalUtilityOfTraveling_s =
          Math.min(worstMarginalUtilityOfTraveling_s, marginalUtilityOfTraveling_s);
      double marginalUtilityOfDistance_m = modeParams.getMarginalUtilityOfDistance();
      double monetaryDistanceCostRate = modeParams.getMonetaryDistanceCostRate();
      double constant = modeParams.getConstant();
      Mode newModeParams =
          new Mode(
              marginalUtilityOfTraveling_s,
              marginalUtilityOfDistance_m,
              monetaryDistanceCostRate,
              constant);
      tmpModeParams.put(modeName, newModeParams);
    }
    modeParams = Collections.unmodifiableMap(tmpModeParams);

    abortedPlanScore =
        Math.min(
                Math.min(marginalUtilityOfLateArrival_s, marginalUtilityOfEarlyDeparture_s),
                Math.min(
                    worstMarginalUtilityOfTraveling_s - marginalUtilityOfPerforming_s,
                    marginalUtilityOfWaiting_s - marginalUtilityOfPerforming_s))
            * 3600.0
            * 24.0; // SCENARIO_DURATION
    // TODO 24 has to be replaced by a variable like scenario_dur (see also other places below)
    // This rather complicated definition has to do with the fact that exp(some_large_number)
    // relatively quickly becomes Inf.
    // In consequence, the abortedPlanScore needs to be more strongly negative than anything else,
    // but not much more.
    // kai, feb'12
  }