16 package emlab.gen.role.operating;
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.transaction.annotation.Transactional;
21 import agentspring.role.Role;
22 import agentspring.role.RoleComponent;
30 import emlab.gen.role.AbstractEnergyProducerRole;
38 public class PayCO2AuctionRole extends AbstractEnergyProducerRole implements Role<EnergyProducer> {
43 public Reps getReps() {
50 logger.info(
"Pay for the CO2 credits");
52 Government government = reps.genericRepository.findFirst(Government.class);
55 double money = calculateCO2MarketCost(plant,
false, getCurrentTick());
56 CashFlow cf = reps.nonTransactionalCreateRepository.createCashFlow(producer, government, money, CashFlow.CO2AUCTION,
57 getCurrentTick(), plant);
58 logger.info(
"Cash flow created: {}", cf);
59 double minCO2Money = calculatePaymentEffictiveCO2NationalMinimumPriceCost(plant,
false, getCurrentTick());
60 NationalGovernment nationalGovernment = reps.nationalGovernmentRepository.findNationalGovernmentByPowerPlant(plant);
61 CashFlow cf2 = reps.nonTransactionalCreateRepository.createCashFlow(producer, nationalGovernment, minCO2Money,
62 CashFlow.NATIONALMINCO2, getCurrentTick(), plant);
63 logger.info(
"Cash flow created: {}", cf2);
66 CO2Auction auction = reps.genericRepository.findFirst(CO2Auction.class);
67 double co2Price = findLastKnownPriceOnMarket(auction, getCurrentTick());
68 double deltaOfHedging = producer.getCo2Allowances() - producer.getLastYearsCo2Allowances();
69 double money = co2Price * deltaOfHedging;
71 CashFlow cf2 = reps.nonTransactionalCreateRepository.createCashFlow(producer, government, money,
72 CashFlow.CO2HEDGING, getCurrentTick(), null);
74 CashFlow cf2 = reps.nonTransactionalCreateRepository.createCashFlow(government, producer, -money,
75 CashFlow.CO2HEDGING, getCurrentTick(), null);
Iterable< PowerPlant > findOperationalPowerPlantsByOwner(@Param("owner") EnergyProducer owner,@Param("tick") long tick)