@Override
    public org.powertac.common.CapacityProfile getCapacityProfile(Tariff tariff) {
      double usageSign = bundle.getPowerType().isConsumption() ? +1 : -1;

      // New code: shifted prediction - correct for tariff-eval purposes
      // ===============================================================
      double[] newForecast;
      // new code
      HashMap<CapacityOriginator, double[]> originator2usage = new HashMap<>();
      for (CapacityOriginator capacityOriginator : bundle.getCapacityOriginators()) {
        double[] usageForecast = new double[CapacityProfile.NUM_TIMESLOTS];
        // BUG FIX: this function is called from forecastCost() and used
        // by TariffEvaluationHelper, which assumes the forcast starts
        // at the next timeslot
        CapacityProfile forecast = capacityOriginator.getForecastForNextTimeslot();
        for (int i = 0; i < CapacityProfile.NUM_TIMESLOTS; ++i) {
          double hourlyUsage = usageSign * forecast.getCapacity(i);
          usageForecast[i] = hourlyUsage; // don't divide yet / bundle.getPopulation();
        }
        originator2usage.put(capacityOriginator, usageForecast);
      }

      // Refactored the following code for LearningUtilityOptimizer - shift profile
      //
      // create dummy subscription for the above usage vector:
      // 1 population member under 'tariff', (consuming the sum
      // of the originators' usage)
      TariffSubscription dummySubscription = new DummyTariffSubscription(getCustomerInfo(), tariff);
      newForecast = adjustForecastPerTariff(originator2usage, dummySubscription, bundle);

      double[] result = newForecast;
      Instant start = service.getTimeService().getCurrentTime().plus(TimeService.HOUR);
      return new org.powertac.common.CapacityProfile(result, start);
    }
 private double useCapacity(TariffSubscription subscription, CapacityBundle bundle) {
   double capacity = 0;
   for (CapacityOriginator capacityOriginator : bundle.getCapacityOriginators()) {
     capacity += capacityOriginator.useCapacity(subscription);
   }
   return capacity;
 }
 /**
  * Is it correct to sum inconveniences over originators? currently every shifting customer has 1
  * originator so this doesn't matter, but it might change in the future.
  */
 @Override
 public double getShiftingInconvenienceFactor(Tariff tariff) {
   double inconv = 0;
   for (CapacityOriginator capacityOriginator : bundle.getCapacityOriginators()) {
     inconv += capacityOriginator.getShiftingInconvenienceFactor(tariff);
   }
   return inconv;
 }