/** * Returns a mapping of brokers to total supply and demand among subscribed * customers. */ @Override public Map<Broker, Map<Type, Double>> getCurrentSupplyDemandByBroker () { HashMap<Broker, Map<Type, Double>> result = new HashMap<Broker, Map<Type, Double>>(); for (BrokerTransaction btx : pendingTransactions) { if (btx instanceof TariffTransaction) { TariffTransaction ttx = (TariffTransaction)btx; Broker broker = ttx.getBroker(); Map<Type, Double> record = result.get(broker); if (null == record) { record = new HashMap<Type, Double>(); result.put(broker, record); record.put(Type.CONSUME, 0.0); record.put(Type.PRODUCE, 0.0); } if (ttx.getTxType() == Type.CONSUME) record.put(Type.CONSUME, record.get(Type.CONSUME) + ttx.getKWh()); else if (ttx.getTxType() == Type.PRODUCE) record.put(Type.PRODUCE, record.get(Type.PRODUCE) + ttx.getKWh()); } } return result; }
/** * Processes a tariff transaction, updating the broker's cash position * and the consumption, production data in the distribution report. */ public void processTransaction(TariffTransaction tx, ArrayList<Object> messages) { //log.info("processing tariff tx " + tx.toString()); updateCash(tx.getBroker(), tx.getCharge()); // update the distribution report if (TariffTransaction.Type.CONSUME == tx.getTxType()) totalConsumption -= tx.getKWh(); else if (TariffTransaction.Type.PRODUCE == tx.getTxType()) totalProduction += tx.getKWh(); }
/** * Returns the net load for the given broker in the current timeslot. * Note that this only works AFTER the customer models have run, and * BEFORE the day's transactions have been processed. The value will be * negative if the broker's customers are consuming more than they produce * in the current timeslot. */ @Override public synchronized double getCurrentNetLoad (Broker broker) { double netLoad = 0.0; for (BrokerTransaction btx : pendingTransactions) { if (btx instanceof TariffTransaction) { TariffTransaction ttx = (TariffTransaction)btx; if (ttx.getBroker().getUsername().equals(broker.getUsername())) { if (ttx.getTxType() == TariffTransaction.Type.CONSUME || ttx.getTxType() == TariffTransaction.Type.PRODUCE) { netLoad += ttx.getKWh(); } } } } log.info("net load for " + broker.getUsername() + ": " + netLoad); return netLoad; }
" of subscribed population " + record.subscribedPopulation); record.produceConsume(ttx.getKWh(), ttx.getPostedTime()); " of subscribed population " + record.subscribedPopulation); record.produceConsume(ttx.getKWh(), ttx.getPostedTime()); ensureBootProfiles(); record = bootProfiles.get(ttx.getCustomerInfo()); record.produceConsume(ttx.getKWh(), ttx.getPostedTime());