EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
DismantlePowerPlantOperationalLossRole.java
1 /*******************************************************************************
2  * Copyright 2012 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 package emlab.gen.role.investment;
17 
18 import org.springframework.beans.factory.annotation.Autowired;
19 
20 import agentspring.role.Role;
21 import agentspring.role.RoleComponent;
25 import emlab.gen.role.AbstractEnergyProducerRole;
26 
35 @RoleComponent
36 public class DismantlePowerPlantOperationalLossRole extends AbstractEnergyProducerRole implements Role<EnergyProducer> {
37 
38  @Autowired
39  Reps reps;
40 
41  public Reps getReps() {
42  return reps;
43  }
44 
45  public void act(EnergyProducer producer) {
46 
47  logger.info("Dismantling plants if out of merit");
48 
49  // dis-mantle plants when passed technical lifetime.
50  for (PowerPlant plant : reps.powerPlantRepository.findOperationalPowerPlantsByOwner(producer, getCurrentTick())) {
51  long horizon = producer.getPastTimeHorizon();
52 
53  double requiredProfit = producer.getDismantlingRequiredOperatingProfit();
54  if (calculateAveragePastOperatingProfit(plant, horizon) < requiredProfit) {
55  logger.info("Dismantling power plant because it has had an operating loss (incl O&M cost) on average in the last "
56  + horizon + " years: " + plant);
57 
58  plant.dismantlePowerPlant(getCurrentTick());
59 
60  }
61  }
62  }
63 
64 }
Iterable< PowerPlant > findOperationalPowerPlantsByOwner(@Param("owner") EnergyProducer owner,@Param("tick") long tick)