16 package emlab.gen.role.market;
18 import java.util.HashMap;
20 import org.springframework.beans.factory.annotation.Autowired;
21 import org.springframework.transaction.annotation.Transactional;
23 import agentspring.role.Role;
24 import agentspring.role.RoleComponent;
32 import emlab.gen.role.AbstractEnergyProducerRole;
56 logger.info(
"Purchasing commodities");
58 HashMap<Substance, Double> fuelAmounts =
new HashMap<Substance, Double>();
62 double totalSupply = plant.calculateElectricityOutputAtTime(getCurrentTick(),
false);
66 double amount = share.getShare() * totalSupply;
67 Substance substance = share.getSubstance();
70 if (fuelAmounts.containsKey(substance)) {
71 amount += fuelAmounts.get(substance);
73 fuelAmounts.put(substance, amount);
77 for (
Substance substance : fuelAmounts.keySet()) {
80 if (!fuelAmounts.get(substance).isNaN() && fuelAmounts.get(substance) > 0) {
81 Bid bid = reps.nonTransactionalCreateRepository.submitBidToMarket(
82 reps.marketRepository.findFirstMarketBySubstance(substance), producer, getCurrentTick(),
false, Double.MAX_VALUE,
83 fuelAmounts.get(substance));
84 logger.info(
"Submited bid " + bid);
Iterable< PowerPlant > findOperationalPowerPlantsByOwner(@Param("owner") EnergyProducer owner,@Param("tick") long tick)