/** * @param coord * @return */ private Tuple<Integer, Integer>[] getZoneTuplesForLinks(Coord coord) { Tuple<Integer, Integer> zoneTuple = getZoneTupleForLinks(coord); int x = zoneTuple.getFirst(); int y = zoneTuple.getSecond(); return new Tuple[] { zoneTuple, new Tuple<Integer, Integer>(x-1, y-1), new Tuple<Integer, Integer>(x, y-1), new Tuple<Integer, Integer>(x+1, y-1), new Tuple<Integer, Integer>(x-1, y), new Tuple<Integer, Integer>(x+1, y), new Tuple<Integer, Integer>(x-1, y+1), new Tuple<Integer, Integer>(x, y+1), new Tuple<Integer, Integer>(x+1, y+1) }; }
/** * Convenience method to create XML Attributes written by startTag() */ protected static Tuple<String, String> createTuple(String one, String two){ return new Tuple<>(one, two); } /**
/** * Scales a vector given by start and end point by a factor. Changes only the start coordinate of the vector. * @param scaleFactor a scale factor in [0..1] * @return a tuple with the scaled start point as first and the old end point as * second entry * @deprecated not used yet */ @Deprecated public static Tuple<Point2D.Double, Point2D.Double> scaleVectorStart(final Point2D.Double start, final Point2D.Double end, double scaleFactor) { Tuple<Point2D.Double, Point2D.Double> scaledVector = calculateScaledVector(start, end, scaleFactor); return new Tuple<Point2D.Double, Point2D.Double>(scaledVector.getFirst(), end); }
/** * Scales a vector given by start and end point by a factor. Changes only the end coordinate of the vector. * @param scaleFactor a scale factor in [0..1] * @return a tuple with the old start point as first and the scaled end point as * second entry * @deprecated not used yet */ @Deprecated public static Tuple<Point2D.Double, Point2D.Double> scaleVectorEnd(final Point2D.Double start, final Point2D.Double end, double scaleFactor) { Tuple<Point2D.Double, Point2D.Double> scaledVector = calculateScaledVector(start, end, scaleFactor); return new Tuple<Point2D.Double, Point2D.Double>(start, scaledVector.getSecond()); }
private DataContainer getLinkToLinkTravelTimeData(Tuple<Id<Link>, Id<Link>> fromLinkToLink, final boolean createIfMissing) { DataContainer data = this.linkToLinkData.get(fromLinkToLink); if ((null == data) && createIfMissing) { data = new DataContainer(this.ttDataFactory.createTravelTimeData(fromLinkToLink.getFirst())); this.linkToLinkData.put(fromLinkToLink, data); } return data; }
private HbefaWarmEmissionFactor getEf(Id<Vehicle> vehicleId, Tuple<HbefaVehicleCategory, HbefaVehicleAttributes> vehicleInformationTuple, HbefaWarmEmissionFactorKey efkey) { HbefaWarmEmissionFactor ef; //The logic has changed here, now it will fall back to aggregate factors per traffic scenario, instead of if any scenarios are missing. if(this.detailedHbefaWarmTable != null && this.detailedHbefaWarmTable.get(efkey) != null){ ef = this.detailedHbefaWarmTable.get(efkey); } else { vehAttributesNotSpecifiedCnt++; efkey.setHbefaVehicleAttributes(new HbefaVehicleAttributes()); //want to check for average vehicle ef = this.avgHbefaWarmTable.get(efkey); int maxWarnCnt = 3; if(this.detailedHbefaWarmTable != null && vehAttributesNotSpecifiedCnt <= maxWarnCnt) { logger.warn("Detailed vehicle attributes are not specified correctly for vehicle " + vehicleId + ": " + "`" + vehicleInformationTuple.getSecond() + "'. Using fleet average values instead."); if(vehAttributesNotSpecifiedCnt == maxWarnCnt) logger.warn(Gbl.FUTURE_SUPPRESSED); } } return ef; }
public void testHashCode_withNull() { Integer i1 = Integer.valueOf(1); Integer i2 = Integer.valueOf(2); Tuple<Integer, Integer> tuple = new Tuple<Integer, Integer>(i1, i2); assertEquals(3, tuple.hashCode()); tuple = new Tuple<Integer, Integer>(null, i2); assertEquals(2, tuple.hashCode()); tuple = new Tuple<Integer, Integer>(i1, null); assertEquals(1, tuple.hashCode()); tuple = new Tuple<Integer, Integer>(null, null); assertEquals(0, tuple.hashCode()); } }
@Deprecated //not tested private int getNumberOfCarsAtDistancePerSecond(Id<Link> linkId, Double distanceMeter, double timeSeconds){ Tuple<Double, Double> tuple = this.linkFirstSecondDistanceMeterMap.get(linkId); int numberOfCarsFirstDetector = this.getNumberOfCarsInDistance(linkId, tuple.getFirst(), timeSeconds); int numberOfCarsSecondDetector = this.getNumberOfCarsInDistance(linkId, tuple.getSecond(), timeSeconds); log.error("Link " + linkId + " first pos: " + tuple.getFirst() + " second pos: " + tuple.getSecond()); log.error("NumberOfCars SecondDetector: " + numberOfCarsSecondDetector + " first detector: " + numberOfCarsFirstDetector); return numberOfCarsFirstDetector - numberOfCarsSecondDetector ; }
private Tuple<Double, Double> getTimeOfOperationFromTimeSlots(int startSlot, int endSlot){ // convert slots to time double startTime = ((double) startSlot) * this.timeBinSize; double endTime = ((double) endSlot + 1) * this.timeBinSize; return new Tuple<>(startTime, endTime); } }
public Tuple<QuadTree<ActivityFacilityWithIndex>, ActivityFacilityImpl[]> getQuadTreeAndFacilities(String activityType) { if (this.cacheQuadTrees) { QuadTree<ActivityFacilityWithIndex> quadTree = this.quadTreesOfType.get(activityType); ActivityFacilityImpl[] facilities = this.facilitiesOfType.get(activityType); if (quadTree == null || facilities == null) { Tuple<QuadTree<ActivityFacilityWithIndex>, ActivityFacilityImpl[]> tuple = getTuple(activityType); this.quadTreesOfType.put(activityType, tuple.getFirst()); this.facilitiesOfType.put(activityType, tuple.getSecond()); return tuple; } else return new Tuple<QuadTree<ActivityFacilityWithIndex>, ActivityFacilityImpl[]>(quadTree, facilities); } else return getTuple(activityType); }
@Override public int compare(final Tuple<Double, MobsimAgent> o1, final Tuple<Double, MobsimAgent> o2) { int ret = o1.getFirst().compareTo(o2.getFirst()); // first compare time information if (ret == 0) { ret = o2.getSecond().getId().compareTo(o1.getSecond().getId()); // if they're equal, compare the Ids: the one with the larger Id should be first } return ret; } }
public void addActivityCombination(DistributionClass distributionClass, String fromActivity, String toActivity) { distributionClass.activityTypesFromTo.add(new Tuple<String, String>(fromActivity, toActivity)); }
ActivityFacility activityFacility = tuple.getFirst(); double y = activityFacility.getCoord().getY(); if (!yValues.contains(y)) { List<Double> xValues = new LinkedList<>(); for (Tuple<ActivityFacility, Double> tuple : accessibilitiesMap.keySet()) { ActivityFacility activityFacility = tuple.getFirst(); double y = activityFacility.getCoord().getY(); if (y == yGiven) { for (double x : coordMap.get(y)) { for (Tuple<ActivityFacility, Double> tuple : accessibilitiesMap.keySet()) { Coord coord = tuple.getFirst().getCoord(); if (coord.getX() == x && coord.getY() == y) { accessibilitiesMap2.put(tuple, accessibilitiesMap.get(tuple));
@Override public void afterSim() { double now = internalInterface.getMobsim().getSimTimer().getTimeOfDay(); for (Tuple<Double, MobsimAgent> entry : teleportationList) { MobsimAgent agent = entry.getSecond(); eventsManager.processEvent(new PersonStuckEvent(now, agent.getId(), agent.getDestinationLinkId(), agent.getMode())); } teleportationList.clear(); }
@Override public void handleEvent(VehicleArrivesAtFacilityEvent event) { if(vehicleIds.contains(event.getVehicleId())) { Tuple<Id<TransitStopFacility>, Double> route = inTransitVehicles.remove(event.getVehicleId()); if(route!=null) stopStopTimes.get(new Tuple<Id<TransitStopFacility>, Id<TransitStopFacility>>(route.getFirst(), event.getFacilityId())).addStopStopTime((int) (route.getSecond()/timeSlot), event.getTime()-route.getSecond()); inTransitVehicles.put(event.getVehicleId(), new Tuple<Id<TransitStopFacility>, Double>(event.getFacilityId(), event.getTime())); } } @Override