/** * Returns the regulation in kwh, aggregated across the subscribed population, * for the previous timeslot. * Intended to be called by Customer models only. Value is non-negative for * consumption power types, non-positive for production types. For storage * types it may be positive or negative. * * NOTE: this method is not idempotent; if you call it twice * in the same timeslot, the second time returns zero. */ public synchronized double getCurtailment () { double sgn = 1.0; if (tariff.getPowerType().isProduction()) sgn = -1.0; double result = sgn * Math.max(sgn * regulation, 0.0) * customersCommitted; setRegulation(0.0); return result; }
/** Subscribing a certain population amount to a certain subscription */ void subscribe (Tariff tariff, int customerCount, CustomerInfo customer) { tariffMarketService.subscribeToTariff(tariff, customer, customerCount); log.info(this.toString() + " " + tariff.getPowerType().toString() + ": " + customerCount + " were subscribed to tariff " + tariff.getId()); }
/** Unsubscribing a certain population amount from a certain subscription */ void unsubscribe (TariffSubscription subscription, int customerCount) { subscription.unsubscribe(customerCount); log.info(this.toString() + " " + subscription.getTariff().getPowerType().toString() + ": " + customerCount + " were unsubscribed from tariff " + subscription.getTariff().getId()); } }
public void subscribeDefault (TariffMarket tariffMarketService) { for (CustomerInfo customer: getCustomerInfos()) { Tariff candidate = tariffMarketService.getDefaultTariff(customer.getPowerType()); if (null == candidate) { log.error("No default tariff for " + customer.getPowerType().toString()); } else { log.info("Subscribe " + customer.getName() + " to " + candidate.getPowerType().toString()); } tariffMarketService.subscribeToTariff(candidate, customer, customer.getPopulation()); } }