@Override // natural ordering is by decreasing utility values public int compareTo (TariffUtility other) { double result = other.utility - utility; if (result == 0.0) // consistent with equals... return (int) (other.tariff.getId() - tariff.getId()); else if (result > 0.0) return 1; else return -1; } }
tariff.setState(Tariff.State.KILLED); log.info("Revoke tariff " + tariff.getId()); TariffRevoke msg = new TariffRevoke(tariff.getBroker(), tariff.getTariffSpecification()); brokerProxyService.broadcastMessage(msg); log.info("Revoked tariff " + tariff.getId() + " has " + activeSubscriptions.size() + " active subscriptions");
/** 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()); }
/** * Computes composite per-tariff inconvenience of a tariff. */ public double computeInconvenience (Tariff tariff) { double result = 0.0; // Time-of-use tariffs have multiple Rates, at least one of which // has a daily or weekly begin/end if (tariff.isTimeOfUse()) result += touFactor; // Tiered tariffs have multiple Rates, at least one having // a non-zero tier threshold. if (tariff.isTiered()) result += tieredRateFactor; // Variable-rate tariffs have at least one non-fixed Rate if (tariff.isVariableRate()) result += variablePricingFactor; // Interruptible tariffs are for an interruptible PowerType, and // have a Rate with a maxCurtailment != 0 if (tariff.isInterruptible()) result += interruptibilityFactor; return result; }
private void revokeTariffsForDisabledBrokers () { for (Broker broker : brokerRepo.findDisabledBrokers()) { if (!disabledBrokers.contains(broker)) { // this is a new one disabledBrokers.add(broker); for (Tariff tariff : tariffRepo.findTariffsByBroker(broker)) { if (Tariff.State.KILLED != tariff.getState()) { log.info("Revoking tariff " + tariff.getId() + " from disabled broker " + broker.getUsername()); addPendingRevoke(tariff); } } } } }
boolean revoked = false; Tariff replacementTariff = null; if (currentTariff.getState() == Tariff.State.KILLED) { revoked = true; replacementTariff = currentTariff.getIsSupersededBy(); log.info("Customer " + customerInfo.getName() + ": tariff " + currentTariff.getId() + " revoked, superseded by " + ((null == replacementTariff) ? "default": replacementTariff.getId())); if (null == replacementTariff) { replacementTariff = defaultTariff; if (tariff.getBroker() != currentTariff.getBroker()) { inconvenience += accessor.getBrokerSwitchFactor(revoked); currentTariff.getSpecId(), tariff.getSpecId(), signupCost, withdraw0, withdrawCost); if (Double.isNaN(cost)) { log.error(getName() + ": cost is NaN for tariff " + tariff.getId()); + tariff.getId()); tariff.getId(), finalCost.costEstimate, defaultEval.costEstimate, utility); TariffUtility tu = util.tariff.getId(), util.probability);
if (!tariff.isRevoked()) { log.warn("Tariff " + tariff.getId() + " is not revoked."); return tariff; getTariffMarket().getDefaultTariff(tariff.getTariffSpec() .getPowerType()); getTariffMarket().getDefaultTariff(tariff.getTariffSpec() .getPowerType().getGenericType()); getTariffMarket().subscribeToTariff(newTariff, customer, customersCommitted); log.info("Tariff " + tariff.getId() + " superseded by " + newTariff.getId() + " for " + customersCommitted + " customers");
log.error("tariff " + tariff.getId() + " customer " + customer.getName() + ": attempt to unsubscribe " + customerCount + double withdrawPayment = -tariff.getEarlyWithdrawPayment(); if (tariff.isRevoked()) { withdrawPayment = 0.0; tariff, customer, customerCount, 0.0, penaltyCount * withdrawPayment); if (tariff.getSignupPayment() < 0.0) { customerCount * tariff.getSignupPayment());
tariff.getUsageCharge(time, kwhPerTs, kwh) / kwhPerTs; if (null == currentBlock) { blockCost = cost;
@Override public synchronized TariffTransaction addRegulationTransaction (Tariff tariff, CustomerInfo customer, int customerCount, double kWh, double charge) { TariffTransaction.Type txType = TariffTransaction.Type.CONSUME; if (kWh > 0.0) txType = TariffTransaction.Type.PRODUCE; TariffTransaction ttx = txFactory.makeTariffTransaction(tariff.getBroker(), txType, tariffRepo.findSpecificationById(tariff.getSpecId()), customer, customerCount, kWh, charge, true); if (null == ttx.getTariffSpec()) log.error("Null tariff spec in addTariffTx()"); pendingTransactions.add(ttx); return ttx; }
/** * Handles changes in tariff expiration date. */ public void handleMessage (TariffExpire update) { ValidationResult result = validateUpdate(update); if (result.tariff == null) send(result.message); else { Instant newExp = update.getNewExpiration(); if (newExp != null && newExp.isBefore(timeService.getCurrentTime())) { // new expiration date in the past log.warn("attempt to set expiration for tariff " + result.tariff.getId() + " in the past:" + newExp.toString()); send(new TariffStatus(update.getBroker(), update.getTariffId(), update.getId(), TariffStatus.Status.invalidUpdate) .withMessage("attempt to set expiration in the past")); } else { // update expiration date result.tariff.setExpiration(newExp); log.info("Tariff " + update.getTariffId() + "now expires at " + new DateTime(result.tariff.getExpiration(), DateTimeZone.UTC).toString()); success(update); } } }
getAccounting().addTariffTransaction(txType, tariff, customer, customersCommitted, -actualKwh, customersCommitted * -tariff.getUsageCharge(actualKwh / customersCommitted, totalUsage, true)); if (getTimeService().getHourOfDay() == 0) { if (tariff.getPeriodicPayment() != 0.0) { getAccounting().addTariffTransaction(TariffTransaction.Type.PERIODIC, tariff, customer, customersCommitted, 0.0, customersCommitted * -tariff.getPeriodicPayment() / 24.0);
new BalancingControlEvent(tariff.getTariffSpec(), kwh, payment, timeslotRepo.currentTimeslot().getSerialNumber()); accountingService.postBalancingControl(bce); brokerProxy.sendMessage(tariff.getBroker(), bce);
log.info("Evaluated tariff " + tariff.getId() + ": cost=" + cost + ", inconvenience=" + hassle); Tariff subTariff = subscription.getTariff(); double withdrawCost = subTariff.getEarlyWithdrawPayment(); int committedCount = subscription.getCustomersCommitted(); int expiredCount = subscription.getExpiredCustomerCount();
regCapacity = new RegulationCapacity(subscription, 0.0, 0.0); else if (tariff.isTimeOfUse() || tariff.isVariableRate()) {
private void storeSubscription (TariffSubscription subscription, CustomerInfo customer, Tariff tariff) { if (tariffMap.get(tariff) == null) tariffMap.put(tariff, new ArrayList<TariffSubscription>()); tariffMap.get(tariff).add(subscription); if (customerMap.get(customer) == null) customerMap.put(customer, new ArrayList<TariffSubscription>()); customerMap.get(customer).add(subscription); Broker broker = tariff.getBroker(); if (brokerMap.get(broker) == null) brokerMap.put(broker, new ArrayList<TariffSubscription>()); brokerMap.get(broker).add(subscription); } }
if (getTariff().hasRegulationRate()) { if (pendingRegulationRatio < 0.0) { double mur = tariff.getMaxUpRegulation(proposedUsage, cumulativeUsage); result = Math.min(proposedUpRegulation, mur); log.debug("proposedUpRegulation=" + proposedUpRegulation
if (result.tariff.hasRegulationRate()) { result.message.withMessage("Cannot use BO with RegulationRate") .setStatus(TariffStatus.Status.unsupported); for (Rate rate: result.tariff.getTariffSpecification().getRates()) { if (rate.getMaxCurtailment() > 0.0) { curtailmentAllowed = true;
boolean isTOU () { return tariff.isTimeOfUse(); }