public static void main(String[] args) { Matrix parkingTimesEC = GeneralLib.readStringMatrix( "A:/for marina/26. april 2012/parkingTimesAndEnergyConsumptionCH.txt"); Network network = GeneralLib.readNetwork( "H:/data/cvs/ivt/studies/switzerland/networks/teleatlas-ivtcheu/network.xml.gz"); HashMap<String, Id> agentIds = new HashMap(); BasicPointVisualizer basicPointVisualizer = new BasicPointVisualizer(); for (int i = 0; i < parkingTimesEC.getNumberOfRows(); i++) { String actType = parkingTimesEC.getString(i, 4); Id<Link> linkId = Id.create(parkingTimesEC.getString(i, 3), Link.class); Link link = network.getLinks().get(linkId); if (actType.equalsIgnoreCase("tta")) { agentIds.put(parkingTimesEC.getString(i, 0), null); // System.out.println("x"); basicPointVisualizer.addPointCoordinate( new Coord(link.getCoord().getX(), link.getCoord().getY()), "", Color.GREEN); } } // for (String agentId:agentIds.keySet()){ // System.out.println(agentId); // } basicPointVisualizer.write("c:/temp/abdd.kml"); }
public static DoubleValueHashMap<Id<Person>> readIncome(String fileName) { DoubleValueHashMap<Id<Person>> houseHoldIncome = new DoubleValueHashMap<>(); Matrix morningMatrix = GeneralLib.readStringMatrix(fileName, "\t"); for (int i = 1; i < morningMatrix.getNumberOfRows(); i++) { Id<Person> id = Id.create(morningMatrix.getString(i, 0), Person.class); double income = morningMatrix.getDouble(i, 1); houseHoldIncome.put(id, income); } return houseHoldIncome; }
public static void main(String[] args) { String basePath = "H:/data/experiments/TRBAug2012/runs/run77/output/"; String fileName = basePath + "houseHoldIncome.txt"; DoubleValueHashMap<Id<Person>> income = readIncome(fileName); int iterationNumber = 35; // String fileNameInputFile = ".walkTimes.txt"; String fileNameInputFile = ".parkingCostLog.txt"; String walkTimesFile = basePath + "ITERS/it." + iterationNumber + "/" + iterationNumber + fileNameInputFile; IntegerValueHashMap<Id> numberOfParkingActs = new IntegerValueHashMap<Id>(); DoubleValueHashMap<Id> walkTimes = new DoubleValueHashMap<Id>(); Matrix walkTimesMatrix = GeneralLib.readStringMatrix(walkTimesFile, "\t"); for (int i = 1; i < walkTimesMatrix.getNumberOfRows(); i++) { String parkingIdString = walkTimesMatrix.getString(i, 1); if (parkingIdString.contains("gp") || parkingIdString.contains("stp")) { Id<Person> personId = Id.create(walkTimesMatrix.getString(i, 0), Person.class); double walkTime = walkTimesMatrix.getDouble(i, 2); if (walkTime != 0) { numberOfParkingActs.increment(personId); walkTimes.incrementBy(personId, walkTime); } } } for (Id<Person> personId : walkTimes.keySet()) { double averageWalkTime = walkTimes.get(personId) / numberOfParkingActs.get(personId); walkTimes.put(personId, averageWalkTime); } IntegerValueHashMap<Integer> categoryFrequency = new IntegerValueHashMap<Integer>(); DoubleValueHashMap<Integer> categorySum = new DoubleValueHashMap<Integer>(); for (Id<Person> personId : walkTimes.keySet()) { int incomeCategory = getIncomeCategory(income.get(personId)); categorySum.incrementBy(incomeCategory, walkTimes.get(personId)); categoryFrequency.increment(incomeCategory); } for (Integer incomeCategory : categorySum.keySet()) { categorySum.put( incomeCategory, categorySum.get(incomeCategory) / categoryFrequency.get(incomeCategory)); } categorySum.printToConsole(); }
private static void collectGarageParkings(ArrayList<String> outputList) { Matrix garageParkingData = GeneralLib.readStringMatrix(Config.baseFolder + "../parkhäuser.txt"); int totalCapacity = 0; for (int i = 1; i < garageParkingData.getNumberOfRows(); i++) { double x = garageParkingData.getDouble(i, 0); double y = garageParkingData.getDouble(i, 1); if (Config.isInsideStudyArea(x, y)) { int capacity = Integer.parseInt(garageParkingData.getString(i, 2)); totalCapacity += capacity; outputList.add(getParkingString("gp-" + i, x, y, capacity)); } } System.out.println("total number of garage parking in the scenario:" + totalCapacity); }
public static void main(String[] args) { Matrix matrix = GeneralLib.readStringMatrix("c:/tmp/homeDemand.txt", "\t"); LinkedList<WeightedDemand> demand = new LinkedList<WeightedDemand>(); LinkedList<Coord> possibleChargingLocations = new LinkedList<Coord>(); int maxNumberOfChargingLocations = 1; for (int i = 1; i < matrix.getNumberOfRows(); i++) { WeightedDemand wd = new WeightedDemand(); wd.demandCount = matrix.getInteger(i, 1); wd.coord = new Coord(matrix.getDouble(i, 2), matrix.getDouble(i, 3)); demand.add(wd); possibleChargingLocations.add(wd.coord); } SimpleLocationOptimizer slo = new SimpleLocationOptimizer(); slo.solveSingleChargingLocation(demand, possibleChargingLocations); System.out.println(slo.scoreSolution(demand, possibleChargingLocations)); }