@Test public void regulationCapacityRegRate () { TariffSpecification specRR = new TariffSpecification(broker, PowerType.THERMAL_STORAGE_CONSUMPTION) .withExpiration(baseTime.plus(TimeService.DAY * 10)) .withMinDuration(TimeService.DAY * 5) .addRate(new Rate().withValue(-0.11)) .addRate(new RegulationRate().withUpRegulationPayment(0.15) .withDownRegulationPayment(-0.05)); Tariff tariffRR = new Tariff(specRR); tariffRR.init(); TariffSubscription sub1 = tariffSubscriptionRepo.getSubscription(customer1, tariffRR); sub1.subscribe(100); TariffSubscription sub2 = tariffSubscriptionRepo.getSubscription(customer2, tariffRR); sub2.subscribe(200); sub1.setRegulationCapacity(new RegulationCapacity(sub1, 3.0, -1.5)); sub1.usePower(200); sub2.setRegulationCapacity(new RegulationCapacity(sub2, 2.0, -1.1)); sub2.usePower(300); BalancingOrder order = new BalancingOrder(broker, specRR, 1.0, 0.1); RegulationAccumulator cap = capacityControl.getRegulationCapacity(order); assertEquals(700.0, cap.getUpRegulationCapacity(), 1e-6, "correct up-regulation"); assertEquals(-370.0, cap.getDownRegulationCapacity(), 1e-6, "correct down-regulation"); }
@Override public RegulationAccumulator getRegulationCapacity (BalancingOrder order) { Tariff tariff = tariffRepo.findTariffById(order.getTariffId()); if (null == tariff) { log.warn("Null tariff " + order.getTariffId() + " for balancing order"); return new RegulationAccumulator(0.0, 0.0); } RegulationAccumulator result = new RegulationAccumulator(0.0, 0.0); List<TariffSubscription> subs = tariffSubscriptionRepo.findSubscriptionsForTariff(tariff); for (TariffSubscription sub : subs) { result.add(sub.getRemainingRegulationCapacity()); } log.info("BalancingOrder " + order.getId() + " capacity = (" + result.getUpRegulationCapacity() + "," + result.getDownRegulationCapacity() + ")"); return result; }
CapacityControlService extends TimeslotPhaseProcessor implements CapacityControl, InitializationService { @Override public RegulationAccumulator getRegulationCapacity (BalancingOrder order) { Tariff tariff = tariffRepo.findTariffById(order.getTariffId()); if (null == tariff) { log.warn("Null tariff " + order.getTariffId() + " for balancing order"); return new RegulationAccumulator(0.0, 0.0); } RegulationAccumulator result = new RegulationAccumulator(0.0, 0.0); List<TariffSubscription> subs = tariffSubscriptionRepo.findSubscriptionsForTariff(tariff); for (TariffSubscription sub : subs) { result.add(sub.getRemainingRegulationCapacity()); } log.info("BalancingOrder " + order.getId() + " capacity = (" + result.getUpRegulationCapacity() + "," + result.getDownRegulationCapacity() + ")"); return result; } }
CapacityControlService extends TimeslotPhaseProcessor implements CapacityControl, InitializationService { @Override public RegulationAccumulator getRegulationCapacity (BalancingOrder order) { Tariff tariff = tariffRepo.findTariffById(order.getTariffId()); if (null == tariff) { log.warn("Null tariff " + order.getTariffId() + " for balancing order"); return new RegulationAccumulator(0.0, 0.0); } RegulationAccumulator result = new RegulationAccumulator(0.0, 0.0); List<TariffSubscription> subs = tariffSubscriptionRepo.findSubscriptionsForTariff(tariff); for (TariffSubscription sub : subs) { result.add(sub.getRemainingRegulationCapacity()); } log.info("BalancingOrder " + order.getId() + " capacity = (" + result.getUpRegulationCapacity() + "," + result.getDownRegulationCapacity() + ")"); return result; }  }
CapacityControlService extends TimeslotPhaseProcessor implements CapacityControl, InitializationService { @Override public RegulationAccumulator getRegulationCapacity (BalancingOrder order) { Tariff tariff = tariffRepo.findTariffById(order.getTariffId()); if (null == tariff) { log.warn("Null tariff " + order.getTariffId() + " for balancing order"); return new RegulationAccumulator(0.0, 0.0); } RegulationAccumulator result = new RegulationAccumulator(0.0, 0.0); List<TariffSubscription> subs = tariffSubscriptionRepo.findSubscriptionsForTariff(tariff); for (TariffSubscription sub : subs) { result.add(sub.getRemainingRegulationCapacity()); } log.info("BalancingOrder " + order.getId() + " capacity = (" + result.getUpRegulationCapacity() + "," + result.getDownRegulationCapacity() + ")"); return result; }  @Override String initialize(Competition competition, List<String> completedInits); @Override void exerciseBalancingControl(BalancingOrder order,
                                        double kwh, double payment); @Override void postEconomicControl(EconomicControlEvent event); @Override RegulationAccumulator getRegulationCapacity(BalancingOrder order); @Override void activate(Instant time, int phaseNumber); }
CapacityControlService extends TimeslotPhaseProcessor implements CapacityControl, InitializationService { @Override public RegulationAccumulator getRegulationCapacity (BalancingOrder order) { Tariff tariff = tariffRepo.findTariffById(order.getTariffId()); if (null == tariff) { log.warn("Null tariff " + order.getTariffId() + " for balancing order"); return new RegulationAccumulator(0.0, 0.0); } RegulationAccumulator result = new RegulationAccumulator(0.0, 0.0); List<TariffSubscription> subs = tariffSubscriptionRepo.findSubscriptionsForTariff(tariff); for (TariffSubscription sub : subs) { result.add(sub.getRemainingRegulationCapacity()); } log.info("BalancingOrder " + order.getId() + " capacity = (" + result.getUpRegulationCapacity() + "," + result.getDownRegulationCapacity() + ")"); return result; }  @Override String initialize(Competition competition, List<String> completedInits); @Override void exerciseBalancingControl(BalancingOrder order,
                                        double kwh, double payment); @Override void postEconomicControl(EconomicControlEvent event); @Override RegulationAccumulator getRegulationCapacity(BalancingOrder order); @Override void activate(Instant time, int phaseNumber);  }