16 package emlab.gen.role.co2policy;
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.data.annotation.Transient;
20 import org.springframework.data.neo4j.support.Neo4jTemplate;
21 import org.springframework.transaction.annotation.Transactional;
23 import agentspring.role.AbstractRole;
24 import agentspring.role.RoleComponent;
51 Neo4jTemplate
template;
59 double co2Emissions = 0;
61 CO2Auction co2Auction = template.findAll(CO2Auction.class).iterator().next();
63 ClearingPoint lastClearingPointOfCo2Market = reps.clearingPointRepositoryOld.findClearingPointForMarketAndTime(
64 co2Auction, getCurrentTick() - 1,
false);
65 if (lastClearingPointOfCo2Market != null) {
66 co2Emissions = lastClearingPointOfCo2Market.getVolume();
69 double totalProduction = 0;
72 for (
ClearingPoint cp : reps.clearingPointRepository.findAllClearingPointsForMarketAndTimeRange(esm,
73 getCurrentTick() - 1, getCurrentTick() - 1,
false)) {
74 totalProduction += cp.getVolume();
78 double absoluteBase = government.isAdaptiveCapAdjustmentBasedOnCapNotActualEmissions() ? government
79 .getCo2CapTrend().getValue(getCurrentTick()) : co2Emissions;
81 double plannedProductionByRenewables = 0;
82 double totalPlannedCapacity = 0;
84 double totalProducedRenewableElectricity = 0;
86 double totalActualInstalledCapacity = 0;
89 double producedRenewableElectricityByTechnologyByTargetInvestor = reps.powerPlantDispatchPlanRepository
90 .calculateTotalProductionForEnergyProducerForTimeForTechnology(targetInvestor,
91 getCurrentTick() - 1, target.getPowerGeneratingTechnology(),
false);
92 totalProducedRenewableElectricity += producedRenewableElectricityByTechnologyByTargetInvestor;
93 double installedCapacityByTechnology = reps.powerPlantRepository
94 .calculateCapacityOfExpectedOperationalPowerPlantsByOwnerByTechnology(getCurrentTick() - 1,
95 targetInvestor, target.getPowerGeneratingTechnology());
96 totalActualInstalledCapacity += installedCapacityByTechnology;
97 double plannedCapacityByTechnologyAndTargetInvestor = target.getTrend().getValue(getCurrentTick() - 1);
98 totalPlannedCapacity += plannedCapacityByTechnologyAndTargetInvestor;
99 double plannedProducedRenewableElectricityByTechnologyAndTargetInvestor = plannedCapacityByTechnologyAndTargetInvestor
100 / installedCapacityByTechnology * producedRenewableElectricityByTechnologyByTargetInvestor;
109 plannedProductionByRenewables += Double
110 .isNaN(plannedProducedRenewableElectricityByTechnologyAndTargetInvestor) ? 0
111 : plannedProducedRenewableElectricityByTechnologyAndTargetInvestor;
115 double capReduction = government.isAdaptiveCapAdjustmentRelativeToNonSubsidisedProduction() ? calculateCapReductionForTimeStepRelativeToNonSubsidizedGeneration(
116 government, plannedProductionByRenewables, totalProducedRenewableElectricity, totalProduction,
118 : calculateCapReductionForTimeStepRelativeToTotalGeneration(government,
119 plannedProductionByRenewables, totalProducedRenewableElectricity, totalProduction, absoluteBase);
120 government.getCo2CapTrend().setValue(getCurrentTick(),
121 government.getCo2CapTrend().getValue(getCurrentTick()) - capReduction);
122 TimeSeriesImpl co2CapAdjustmentTimeSeries = government.getCo2CapAdjustmentTimeSeries();
123 if (co2CapAdjustmentTimeSeries == null) {
125 co2CapAdjustmentTimeSeries.setTimeSeries(
new double[government.getCo2CapTrend().getTimeSeries().length]);
126 co2CapAdjustmentTimeSeries.persist();
127 government.setCo2CapAdjustmentTimeSeries(co2CapAdjustmentTimeSeries);
129 co2CapAdjustmentTimeSeries.setValue(getCurrentTick(), capReduction);
135 public double calculatedExpectedCapReductionForTimeStep(
Government government,
long currentTimeStep,
137 double currentEmissions,
138 double futureEmissions,
long centralForecastingYear) {
140 double co2Emissions = 1.0d / centralForecastingYear * currentEmissions + (centralForecastingYear - 1.0d)
141 / centralForecastingYear * futureEmissions;
143 double totalProduction = 0;
146 for (
ClearingPoint cp : reps.clearingPointRepository.findAllClearingPointsForMarketAndTimeRange(esm,
147 currentTimeStep, currentTimeStep,
false)) {
148 totalProduction += cp.getVolume() * 1 / centralForecastingYear;
150 for (
ClearingPoint cp : reps.clearingPointRepository.findAllClearingPointsForMarketAndTimeRange(esm,
151 futureTimeStep, futureTimeStep,
true)) {
152 totalProduction += cp.getVolume() * (centralForecastingYear - 1) / centralForecastingYear;
157 double absoluteBase = government.isAdaptiveCapAdjustmentBasedOnCapNotActualEmissions() ? government.getCo2CapTrend().getValue(futureTimeStep - 1) : co2Emissions;
159 double plannedProductionByRenewables = 0;
160 double totalPlannedCapacity = 0;
162 double totalProducedRenewableElectricity = 0;
164 double totalActualInstalledCapacity = 0;
167 double producedRenewableElectricityByTechnologyByTargetInvestor = reps.powerPlantDispatchPlanRepository
168 .calculateTotalProductionForEnergyProducerForTimeForTechnology(targetInvestor, currentTimeStep,
169 target.getPowerGeneratingTechnology(),
false)
171 / centralForecastingYear
172 + reps.powerPlantDispatchPlanRepository
173 .calculateTotalProductionForEnergyProducerForTimeForTechnology(targetInvestor,
174 futureTimeStep, target.getPowerGeneratingTechnology(),
true)
175 * (centralForecastingYear - 1) / centralForecastingYear;
176 totalProducedRenewableElectricity += producedRenewableElectricityByTechnologyByTargetInvestor;
177 double installedCapacityByTechnology = reps.powerPlantRepository
178 .calculateCapacityOfExpectedOperationalPowerPlantsByOwnerByTechnology(futureTimeStep - 1,
179 targetInvestor, target.getPowerGeneratingTechnology());
180 totalActualInstalledCapacity += installedCapacityByTechnology;
181 double plannedCapacityByTechnologyAndTargetInvestor = target.getTrend().getValue(futureTimeStep - 1);
182 totalPlannedCapacity += plannedCapacityByTechnologyAndTargetInvestor;
183 double plannedProducedRenewableElectricityByTechnologyAndTargetInvestor = plannedCapacityByTechnologyAndTargetInvestor
184 / installedCapacityByTechnology * producedRenewableElectricityByTechnologyByTargetInvestor;
193 plannedProductionByRenewables += Double
194 .isNaN(plannedProducedRenewableElectricityByTechnologyAndTargetInvestor) ? 0
195 : plannedProducedRenewableElectricityByTechnologyAndTargetInvestor;
200 double capReduction = government.isAdaptiveCapAdjustmentRelativeToNonSubsidisedProduction() ? calculateCapReductionForTimeStepRelativeToNonSubsidizedGeneration(
201 government, plannedProductionByRenewables, totalProducedRenewableElectricity, totalProduction,absoluteBase)
202 : calculateCapReductionForTimeStepRelativeToTotalGeneration(government,
203 plannedProductionByRenewables, totalProducedRenewableElectricity, totalProduction, absoluteBase);
207 double calculateCapReductionForTimeStepRelativeToTotalGeneration(
Government government,
208 double plannedProductionByRenewables,
double totalProducedRenewableElectricity,
double totalProduction,
209 double absoluteBase) {
210 double averageEmissionsPerMWh = (absoluteBase / totalProduction);
211 double plannedSavedEmissionsApproximation = plannedProductionByRenewables * averageEmissionsPerMWh;
212 double actualSavedEmissionsApproximation = totalProducedRenewableElectricity * averageEmissionsPerMWh;
214 double capReduction = 0;
216 if (!government.isDeviationFromResTargetAdjustment()) {
217 capReduction = actualSavedEmissionsApproximation * government.getAdaptiveCapCO2SavingsWeighingFactor();
219 capReduction = Math.max(0, actualSavedEmissionsApproximation - plannedSavedEmissionsApproximation)
220 * government.getAdaptiveCapCO2SavingsWeighingFactor();
233 double calculateCapReductionForTimeStepRelativeToNonSubsidizedGeneration(
Government government,
234 double plannedProductionByRenewables,
double totalProducedRenewableElectricity,
double totalProduction,
235 double absoluteBase) {
236 double capReduction = Math.max(0, (totalProducedRenewableElectricity - plannedProductionByRenewables)
237 / (totalProduction - plannedProductionByRenewables))
Iterable< ElectricitySpotMarket > findAllElectricitySpotMarkets()