private double forecastCost (Tariff tariff) { CapacityProfile profile = accessor.getCapacityProfile(tariff); if (0 == profile.getProfile().length) { log.error("Zero-length profile for " + customerInfo.getName()); return 0.0; } setProfileLength(profile.getProfile().length); // NOTE: must call the next function after the previous, // since the previous writes inconv. factors. // Always 0 except for AdaptiveCapacityOriginator double inconv = accessor.getShiftingInconvenienceFactor(tariff); double profileCost = helper.estimateCost(tariff, profile.getProfile(), profile.getStart()); if (Double.isNaN(profileCost)) { log.error(getName() + ": profile cost NaN for tariff " + tariff.getId()); } //double scale = preferredDuration * 24.0 / profile.length; double scale = stdDuration * 24.0 / getProfileLength(); if (Double.isNaN(scale)) { log.error(getName() + ": scale NaN for tariff " + tariff.getId()); } log.debug("tariff {}: profileCost={}, inconv={}, scaled-charge={}, scaled (cost+inconv)={}", tariff.getId(), profileCost, inconv, profileCost * scale, (profileCost + inconv) * scale, (profileCost + inconv) * scale / (profileCost * scale)); return (profileCost + inconv) * scale; }
@Override public CapacityProfile getCapacityProfile (Tariff tariff) { // lazy creation of capacityProfile table if (null == TariffProfiles) { TariffProfiles = new HashMap<Tariff, TariffInfo>(); } // return existing capacityProfile if it exists TariffInfo info = TariffProfiles.get(tariff); if (null != info) { return info.getCapacityProfile(); } // otherwise, create a new capacityProfile info = makeTariffInfo(tariff); if (tariff.isTimeOfUse()) { heuristicTouProfile(info); } else { // fill capacityProfile with nominal consumption double[] pr = new double[profileSize]; Arrays.fill(pr, getNominalHourlyConsumption()); info.setCapacityProfile(new CapacityProfile(pr, lastSunday())); } log.debug(getName() + " capacityProfile " + Arrays.toString(info.getCapacityProfile().getProfile())); TariffProfiles.put(tariff, info); return info.getCapacityProfile(); }