EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
DCFinvestInPowerGenerationTechnologies.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 java.util.HashMap;
19 import java.util.Map;
20 
21 import org.apache.commons.math.stat.regression.SimpleRegression;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.beans.factory.annotation.Configurable;
24 import org.springframework.data.annotation.Transient;
25 import org.springframework.data.neo4j.annotation.NodeEntity;
26 import org.springframework.data.neo4j.aspects.core.NodeBacked;
27 import org.springframework.transaction.annotation.Transactional;
28 
29 import agentspring.role.Role;
34 
35 @Configurable
36 @NodeEntity
37 public class DCFinvestInPowerGenerationTechnologies<T extends EnergyProducer> extends GenericInvestmentRole<T>
38 implements Role<T>,
39 NodeBacked {
40 
41  @Transient
42  @Autowired
43  Reps reps;
44 
45  @Transactional
46  @Override
47  public void act(EnergyProducer agent) {
48 
49  Map<Substance, SimpleRegression> expectedFuelPrices = new HashMap<Substance, SimpleRegression>();
50  for (Substance substance : reps.genericRepository.findAll(Substance.class)) {
51 
52  // co2
53  }
54  // price
55 
56  // Investment decision
57  agent.setWillingToInvest(false);
58  }
59 
60  SimpleRegression calculateRegressionBasedOnTimeStepsAndSubstance(long startTime, long endTime, Substance substance) {
61 
62  SimpleRegression sr = new SimpleRegression();
63 
64  Iterable<ClearingPoint> clearingPoints = reps.clearingPointRepository.findAllClearingPointsForSubstanceAndTimeRange(substance,
65  startTime, endTime, false);
66 
67  for (ClearingPoint cp : clearingPoints) {
68  sr.addData(cp.getTime(), cp.getPrice());
69  }
70  return sr;
71  }
72 
73 }