public void test1DSenseSleepUtilityFunction() throws Exception { List<SensorProperties> sensorProperties = new ArrayList<SensorProperties>(); sensorProperties.add(new SensorProperties(l1)); function = SenseSleepUtilityFunctionFactory.createSenseSleepFunction(scenario, sensorProperties); for (double x1 = 0; x1 <= 8.0; x1 += 0.5) { double expected = l1; assertEquals(expected, function.evaluate(x1), 1e-7); } }
public void test2DSenseSleepUtilityFunction() throws Exception { List<SensorProperties> sensorProperties = new ArrayList<SensorProperties>(); sensorProperties.add(new SensorProperties(l1)); sensorProperties.add(new SensorProperties(l2)); function = SenseSleepUtilityFunctionFactory.createSenseSleepFunction(scenario, sensorProperties); for (double x1 = 0; x1 <= 8.0; x1 += 0.5) { for (double x2 = 0; x2 <= 7.0; x2 += 0.5) { double expected = l1 + l2 - (Math.max(Math.min(x1 + l1, x2 + l2) - Math.max(x1, x2), 0.0)); assertEquals(expected, function.evaluate(x1, x2), 1e-7); } } }