/** * Stores travel cost (total time * income) in files. * * @param income * @param timePlan * @param csvWriter */ public void storeTravelCost(BigDecimal income, TimePlan timePlan, CSVWriter csvWriter) { final int workHoursPerWeek = 35; final int minutesPerHour = 60; final int totalMinutes = workHoursPerWeek * minutesPerHour; double totalTime = timePlan.getDriveTime() + timePlan.getWaitTime() + timePlan.getWalkTime() + timePlan.getTransitTime() + timePlan.getOtherTime(); BigDecimal travelCost = income .multiply(new BigDecimal(totalTime)) .divide(new BigDecimal(totalMinutes), 3, RoundingMode.HALF_UP); String[] entries = { String.valueOf(timePlan.getHhold()), String.valueOf(timePlan.getPerson()), String.valueOf(timePlan.getTrip()), String.valueOf(timePlan.getPurpose()), String.valueOf(timePlan.getMode()), String.valueOf(totalTime), String.valueOf(income), String.valueOf(travelCost) }; csvWriter.writeNext(entries); }
/** * Use the fixed cost and variable cost in the model to calculate the delta between the cost of * current mode and cheapest mode. * * @param timePlan * @param hhPersonTrip : a combined string of HholdID, PersonID and TripID with TimePlan file * format * @author vlcao */ public void setupDeltaFixedCostVariableCost(TimePlan timePlan, String hhPersonTrip) { double carTime = 0; double transitTime = 0; double walkTime = 0; double bikeTime = 0; double travelTime = 0; switch (timePlan.getMode()) { case Walk: travelTime = timePlan.getWalkTime(); walkTime = travelTime; carTime = (travelTime * main.getWalkToCarRatio()); transitTime = (travelTime * main.getWalkToBusRatio()); bikeTime = (travelTime * main.getWalkToBikeRatio()); break; case CarDriver: travelTime = timePlan.getDriveTime(); walkTime = (travelTime / main.getWalkToCarRatio()); transitTime = (travelTime / main.getBusToCarRatio()); carTime = travelTime; bikeTime = (travelTime / main.getBikeToCarRatio()); break; case Bus: travelTime = timePlan.getTransitTime(); walkTime = (travelTime / main.getWalkToBusRatio()); transitTime = travelTime; carTime = (travelTime * main.getBusToCarRatio()); bikeTime = (travelTime / main.getBikeToBusRatio()); break; case LightRail: travelTime = timePlan.getTransitTime(); walkTime = (travelTime / main.getWalkToBusRatio()); transitTime = travelTime; carTime = (travelTime * main.getBusToCarRatio()); bikeTime = (travelTime / main.getBikeToBusRatio()); break; case Bike: travelTime = timePlan.getOtherTime(); walkTime = (travelTime / main.getWalkToBikeRatio()); transitTime = (travelTime * main.getBikeToBusRatio()); carTime = (travelTime * main.getBikeToCarRatio()); bikeTime = travelTime; break; case CarPassenger: travelTime = timePlan.getDriveTime(); walkTime = (travelTime / main.getWalkToCarRatio()); transitTime = (travelTime / main.getBusToCarRatio()); carTime = travelTime; bikeTime = (travelTime / main.getBikeToCarRatio()); break; case Taxi: travelTime = timePlan.getDriveTime(); // checkme walkTime = (travelTime / main.getWalkToCarRatio()); transitTime = (travelTime / main.getBusToCarRatio()); carTime = travelTime; bikeTime = (travelTime / main.getBikeToCarRatio()); break; default: break; } // set delta fixed cost and delta variable cost if (main.getHmHhPersonTripTravelMode().get(hhPersonTrip) != null) { timePlan.setDeltaFixedCost( travelModeSelection.calculateDeltaFixedCost( TravelModes.classify(main.getHmHhPersonTripTravelMode().get(hhPersonTrip)), bikeTime, walkTime, transitTime)); timePlan.setDeltaVariableCost( travelModeSelection.calculateDeltaVariableCost( TravelModes.classify(main.getHmHhPersonTripTravelMode().get(hhPersonTrip)), bikeTime, walkTime, transitTime, carTime)); } // add the delta fixed cost and variable cost into a hash map hhPersonTrip = main.getHhPersonTripConvertedMap().get(hhPersonTrip); main.getTripTimePlanMap() .put( hhPersonTrip, new double[] {timePlan.getDeltaFixedCost(), timePlan.getDeltaVariableCost()}); // add the values for hash map of Car driver with details of trip time // driverTimeMap: // <"HhPersonTrip_TravelDiary",[WalkTime,DriveTime,TransitTime,WaitTime,OtherTime]> if (main.getDriverTimeMap().get(hhPersonTrip) != null) { double[] detailsTripTime = { timePlan.getWalkTime(), timePlan.getDriveTime(), timePlan.getTransitTime(), timePlan.getWaitTime(), timePlan.getOtherTime() }; main.getDriverTimeMap().put(hhPersonTrip, detailsTripTime); } }