options.walkReluctance = 1;
options.setTriangleSafetyFactor(0);
options.setTriangleSlopeFactor(0);
options.setTriangleTimeFactor(1);
State startState = new State(v1, options);
State result = testStreet.traverse(startState);
double timeWeight = result.getWeight();
double expectedTimeWeight = slopeSpeedLength / options.getSpeed(TraverseMode.BICYCLE);
assertTrue(Math.abs(expectedTimeWeight - timeWeight) < 0.00001);
options.setTriangleSafetyFactor(0);
options.setTriangleSlopeFactor(1);
options.setTriangleTimeFactor(0);
startState = new State(v1, options);
result = testStreet.traverse(startState);
double slopeWeight = result.getWeight();
double expectedSlopeWeight = slopeWorkLength / options.getSpeed(TraverseMode.BICYCLE);
assertTrue(Math.abs(expectedSlopeWeight - slopeWeight) < 0.00001);
assertTrue(length * 1.5 / options.getSpeed(TraverseMode.BICYCLE) < slopeWeight);
assertTrue(length * 1.5 * 10 / options.getSpeed(TraverseMode.BICYCLE) > slopeWeight);
options.setTriangleSafetyFactor(1);
options.setTriangleSlopeFactor(0);
options.setTriangleTimeFactor(0);
startState = new State(v1, options);
result = testStreet.traverse(startState);
double safetyWeight = result.getWeight();
double slopeSafety = costs.slopeSafetyCost;
double expectedSafetyWeight = (trueLength * 0.74 + slopeSafety) / options.getSpeed(TraverseMode.BICYCLE);
assertTrue(Math.abs(expectedSafetyWeight - safetyWeight) < 0.00001);
final double ONE_THIRD = 1/3.0;
options.setTriangleSafetyFactor(ONE_THIRD);
options.setTriangleSlopeFactor(ONE_THIRD);
options.setTriangleTimeFactor(ONE_THIRD);
startState = new State(v1, options);
result = testStreet.traverse(startState);
double averageWeight = result.getWeight();
assertTrue(Math.abs(safetyWeight * ONE_THIRD + slopeWeight * ONE_THIRD + timeWeight * ONE_THIRD - averageWeight) < 0.00000001);
}