/** * Test the performing part of the scoring function. */ @Test public void testPerforming() { Fixture f = new Fixture(); double perf = +6.0; double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0); double zeroUtilDurH = getZeroUtilDuration_hrs(15.0, 1.0); f.config.planCalcScore().setPerforming_utils_hr(perf); if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams p : f.config.planCalcScore().getActivityParams()){ p.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.uniform); } } assertEquals(perf * 3.0 * Math.log(2.5 / zeroUtilDurW) + perf * 3.0 * Math.log(2.75/zeroUtilDurW) + perf * 3.0 * Math.log(2.5/zeroUtilDurW) + perf * 15.0 * Math.log(14.75 / zeroUtilDurH), calcScore(f), EPSILON); // perf = +3.0; // f.config.planCalcScore().setPerforming_utils_hr(perf); // assertEquals(perf * 3.0 * Math.log(2.5 / zeroUtilDurW) // + perf * 3.0 * Math.log(2.75/zeroUtilDurW) // + perf * 3.0 * Math.log(2.5/zeroUtilDurW) // + perf * 15.0 * Math.log(14.75 / zeroUtilDurH), calcScore(f), EPSILON); }
Fixture f = new Fixture();
@Test public void testTravelingAndConstantCar() { Fixture f = new Fixture(); final double traveling = -6.0; f.config.planCalcScore().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling); assertEquals(-3.0, calcScore(f), EPSILON); double constantCar = -6.0; f.config.planCalcScore().getModes().get(TransportMode.car).setConstant(constantCar); assertEquals(-9.0, calcScore(f), EPSILON); }
Fixture f = new Fixture(); double perf_hrs = +6.0; f.config.planCalcScore().setPerforming_utils_hr(perf_hrs);
Fixture f = new Fixture();
Fixture f = new Fixture();
double perf = +3.0; Fixture f = new Fixture();
@Test public void testUnusualMode() { Fixture f = new Fixture(); Leg leg = (Leg) f.plan.getPlanElements().get(1); leg.setMode("sackhuepfen"); boolean exception = false ; try { assertEquals(-3.0, calcScore(f), EPSILON); // default for unknown modes // no longer allowed. kai, may'17 } catch ( Exception ee ) { // this is expected exception = true ; } assertTrue( exception ) ; f.config.planCalcScore().addParam("traveling_sackhuepfen", "-30.0"); assertEquals(-15.0, calcScore(f), EPSILON); }
@Test public void testDistanceCostScoringPt() { Fixture f = new Fixture(); // test 1 where marginalUtitityOfMoney is fixed to 1.0 f.config.planCalcScore().setMarginalUtilityOfMoney(1.0); // this.config.charyparNagelScoring().setMarginalUtlOfDistancePt(-0.00001); double monetaryDistanceRatePt1 = -0.00001; f.config.planCalcScore().getModes().get(TransportMode.pt).setMonetaryDistanceRate(monetaryDistanceRatePt1); assertEquals(-0.20, calcScore(f), EPSILON); // test 2 where MonetaryDistanceCostRate is fixed to -1.0 double monetaryDistanceRatePt = -1.0; f.config.planCalcScore().getModes().get(TransportMode.pt).setMonetaryDistanceRate(monetaryDistanceRatePt); f.config.planCalcScore().setMarginalUtilityOfMoney(0.5); assertEquals(-10000.0, calcScore(f), EPSILON); }
@Test public void testDistanceCostScoringCar() { Fixture f = new Fixture(); // test 1 where marginalUtitityOfMoney is fixed to 1.0 f.config.planCalcScore().setMarginalUtilityOfMoney(1.0); // this.config.charyparNagelScoring().setMarginalUtlOfDistanceCar(-0.00001); double monetaryDistanceRateCar1 = -0.00001; f.config.planCalcScore().getModes().get(TransportMode.car).setMonetaryDistanceRate(monetaryDistanceRateCar1); assertEquals(-0.25, calcScore(f), EPSILON); // test 2 where MonetaryDistanceCostRate is fixed to -1.0 double monetaryDistanceRateCar = -1.0; f.config.planCalcScore().getModes().get(TransportMode.car).setMonetaryDistanceRate(monetaryDistanceRateCar); f.config.planCalcScore().setMarginalUtilityOfMoney(0.5); assertEquals(-12500.0, calcScore(f), EPSILON); }
/** * Test the performing part of the scoring function when an activity has a ClosingTime set. */ @Test public void testClosingTime() { Fixture f = new Fixture(); double perf = +6.0; f.config.planCalcScore().setPerforming_utils_hr(perf); double initialScore = calcScore(f); ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); wParams.setClosingTime(15*3600.0); // now the agent stays 1h too long at the LAST work activity double score = calcScore(f); // check the difference between 2.5 and 1.5 hours working assertEquals(perf * 3.0 * Math.log(2.5 / 1.5), initialScore - score, EPSILON); }
/** * Test the performing part of the scoring function when an activity has an OpeningTime set. */ @Test public void testOpeningTime() { Fixture f = new Fixture(); double perf = +6.0; f.config.planCalcScore().setPerforming_utils_hr(perf); double initialScore = calcScore(f); ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); wParams.setOpeningTime(8*3600.0); // now the agent arrives 30min early to the FIRST work activity and has to wait double score = calcScore(f); // check the difference between 2.5 and 2.0 hours of working assertEquals(perf * 3.0 * Math.log(2.5 / 2.0), initialScore - score, EPSILON); }
/** * Test the scoring function in regards to late arrival. */ @Test public void testLateArrival() { Fixture f = new Fixture(); double disutility = -10.0; f.config.planCalcScore().setLateArrival_utils_hr(disutility); ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); wParams.setLatestStartTime(13 * 3600.0); // agent should start working latest at 13 o'clock // the agent arrived 30mins late assertEquals(disutility * 0.5, calcScore(f), EPSILON); }
/** * Test the waiting part of the scoring function. */ @Test public void testWaitingTime() { Fixture f = new Fixture(); double waiting = -10.0; f.config.planCalcScore().setMarginalUtlOfWaiting_utils_hr(waiting); ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); wParams.setOpeningTime( 8*3600.0); // the agent arrives 30min early wParams.setClosingTime(15*3600.0); // the agent stays 1h too long // the agent spends 1.5h waiting at the work place assertEquals(waiting * 1.5, calcScore(f), EPSILON); }
@Test public void testTravelingBikeAndConstantBike(){ Fixture f = new Fixture(); final double travelingBike = -6.0; f.config.planCalcScore().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(travelingBike); assertEquals(-1.5, calcScore(f), EPSILON ) ; double constantBike = -2.0; f.config.planCalcScore().getModes().get(TransportMode.bike).setConstant(constantBike); assertEquals(-3.5, calcScore(f), EPSILON); }
@Test public void testTravelingWalkAndConstantWalk() { Fixture f = new Fixture(); final double travelingWalk = -18.0; f.config.planCalcScore().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling(travelingWalk); assertEquals(-9.0, calcScore(f), EPSILON ) ; double constantWalk = -1.0; f.config.planCalcScore().getModes().get(TransportMode.walk).setConstant(constantWalk); assertEquals(-10.0, calcScore(f), EPSILON); }
@Test public void testTravelingPtAndConstantPt() { Fixture f = new Fixture(); final double travelingPt = -9.0; f.config.planCalcScore().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling(travelingPt); assertEquals(-2.25, calcScore(f), EPSILON); double constantPt = -3.0; f.config.planCalcScore().getModes().get(TransportMode.pt).setConstant(constantPt); assertEquals(-5.25, calcScore(f), EPSILON); }
/** * Test the scoring function in regards to early departures. */ @Test public void testEarlyDeparture() { Fixture f = new Fixture(); double disutility = -10.0; f.config.planCalcScore().setEarlyDeparture_utils_hr(disutility); ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); wParams.setEarliestEndTime(10.75 * 3600.0); // require the agent to work until 16:45 // the agent left 45mins too early assertEquals(disutility * 0.75, calcScore(f), EPSILON); }
/** * Test the scoring function in regards to early departures. */ @Test public void testMinimumDuration() { Fixture f = new Fixture(); double disutility = -10.0; f.config.planCalcScore().setEarlyDeparture_utils_hr(disutility); ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); wParams.setMinimalDuration(3 * 3600.0); // require the agent to be 3 hours at every working activity // the agent overall works 1.25h too short assertEquals(disutility * 1.25, calcScore(f), EPSILON); }
/** * Test the scoring function when all parameters are set to 0. */ @Test public void testZero() { Fixture f = new Fixture(); assertEquals(0.0, calcScore(f), EPSILON); }