UtilizationModelPlanetLabInMemory implements UtilizationModel { @Override public double getUtilization(double time) { if (time % getSchedulingInterval() == 0) { return data[(int) time / (int) getSchedulingInterval()]; } int time1 = (int) Math.floor(time / getSchedulingInterval()); int time2 = (int) Math.ceil(time / getSchedulingInterval()); double utilization1 = data[time1]; double utilization2 = data[time2]; double delta = (utilization2 - utilization1) / ((time2 - time1) * getSchedulingInterval()); double utilization = utilization1 + delta * (time - time1 * getSchedulingInterval()); return utilization; } UtilizationModelPlanetLabInMemory(String inputPath, double schedulingInterval);  UtilizationModelPlanetLabInMemory(String inputPath, double schedulingInterval, int dataSamples); @Override double getUtilization(double time); void setSchedulingInterval(double schedulingInterval); double getSchedulingInterval(); double[] getData();  }
@Test public void testGetPowerModel() { assertEquals(0.24, utilizationModel.getUtilization(0), 0); assertEquals(0.34, utilizationModel.getUtilization(1 * SCHEDULING_INTERVAL), 0); assertEquals( (24 + 0.2 * SCHEDULING_INTERVAL * (34 - 24) / SCHEDULING_INTERVAL) / 100, utilizationModel.getUtilization(0.2 * SCHEDULING_INTERVAL), 0.01); assertEquals(0.29, utilizationModel.getUtilization(2 * SCHEDULING_INTERVAL), 0); assertEquals(0.18, utilizationModel.getUtilization(136 * SCHEDULING_INTERVAL), 0); assertEquals( (18 + 0.7 * SCHEDULING_INTERVAL * (21 - 18) / SCHEDULING_INTERVAL) / 100, utilizationModel.getUtilization(136.7 * SCHEDULING_INTERVAL), 0.01); assertEquals(0.51, utilizationModel.getUtilization(287 * SCHEDULING_INTERVAL), 0); }