ForecastComputationUnit.java 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package classes.holonControlUnit;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import classes.Holon;
  5. import classes.holonControlUnit.messages.StateMsg;
  6. /**
  7. * here we "try" to predict the future power usage inside the holon
  8. * as predicted values we use the real power usage values for future timestamps
  9. * @author Jonas
  10. *
  11. */
  12. public class ForecastComputationUnit {
  13. public final int N_TIMESTEPS = 5;
  14. private HolonControlUnit hcu;
  15. public ForecastComputationUnit(HolonControlUnit hcu) {
  16. this.hcu = hcu;
  17. }
  18. public ArrayList<Float> computeForecast(HashMap<String, StateMsg> childStates, int timeStep){
  19. ArrayList<Float> forecast = new ArrayList<Float>();
  20. Holon holon = this.hcu.getHolon();
  21. for(int i=0; i<this.N_TIMESTEPS; i++) {
  22. //compute power usage for timestamp+i
  23. int t = timeStep+i+1;
  24. if(t >= holon.model.getIterations())
  25. break;
  26. float powerUsage = 0f;
  27. for(String s : childStates.keySet()) {
  28. powerUsage += childStates.get(s).getPredictedPowerUsage().get(i);
  29. }
  30. if(holon.isPhysical) {
  31. powerUsage += holon.getHolonObject().getEnergyAtTimeStep(t);
  32. }
  33. forecast.add(powerUsage);
  34. }
  35. return forecast;
  36. }
  37. }