1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package classes.holonControlUnit;
- import java.util.ArrayList;
- import java.util.HashMap;
- import classes.Holon;
- import classes.holonControlUnit.messages.StateMsg;
- /**
- * here we "try" to predict the future power usage inside the holon
- * as predicted values we use the real power usage values for future timestamps
- * @author Jonas
- *
- */
- public class ForecastComputationUnit {
- public final int N_TIMESTEPS = 5;
-
- private HolonControlUnit hcu;
-
- public ForecastComputationUnit(HolonControlUnit hcu) {
- this.hcu = hcu;
- }
-
- public ArrayList<Float> computeForecast(HashMap<String, StateMsg> childStates, int timeStep){
- ArrayList<Float> forecast = new ArrayList<Float>();
-
- Holon holon = this.hcu.getHolon();
- for(int i=0; i<this.N_TIMESTEPS; i++) {
- //compute power usage for timestamp+i
- int t = timeStep+i+1;
- if(t >= holon.model.getIterations())
- break;
- float powerUsage = 0f;
- for(String s : childStates.keySet()) {
- powerUsage += childStates.get(s).getPredictedPowerUsage().get(i);
- }
- if(holon.isPhysical) {
- powerUsage += holon.getHolonObject().getEnergyAtTimeStep(t);
- }
- forecast.add(powerUsage);
- }
- // System.out.println("Forecast for "+holon.getHolonObject()+"\n\t"+forecast);
- return forecast;
- }
-
- }
|