org.matsim.core.utils.collections.Tuple.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.matsim.core.utils.collections.Tuple.<init>()方法的一些代码示例,展示了Tuple.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuple.<init>()方法的具体详情如下:
包路径:org.matsim.core.utils.collections.Tuple
类名称:Tuple
方法名:<init>

Tuple.<init>介绍

[英]Creates a new tuple with the two entries.
[中]创建一个包含两个条目的新元组。

代码示例

代码示例来源:origin: matsim-org/matsim

/**
 * Convenience method to create XML Attributes written by startTag()
 */
protected static Tuple<String, String> createTuple(String one, String two){
  return new Tuple<>(one, two);
}
/**

代码示例来源:origin: matsim-org/matsim

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);
  }
}

代码示例来源:origin: matsim-org/matsim

public Link getLinkBetweenStops(final TransitStopFacility fromStop, final TransitStopFacility toStop) {
  Node fromNode = this.nodes.get(fromStop);
  Node toNode = this.nodes.get(toStop);
  Tuple<Node, Node> connection = new Tuple<Node, Node>(fromNode, toNode);
  return this.links.get(connection);
}

代码示例来源:origin: matsim-org/matsim

@Override
public List<Tuple<Id<SignalGroup>, Id<SignalGroup>>> getEndingBeginningSignalGroupKeys(){
  List<Tuple<Id<SignalGroup>, Id<SignalGroup>>> list = new ArrayList<>();
  for (Entry<Id<SignalGroup>, Map<Id<SignalGroup>, Integer>> e : this.endingGroupToBeginningGroupTimeMap.entrySet()){
    for (Id<SignalGroup> beginningId : e.getValue().keySet()){
      list.add(new Tuple<>(e.getKey(), beginningId));
    }
  }
  return list;
}

代码示例来源:origin: matsim-org/matsim

public Tuple<Double, Double> getRouteTravelTime(Id<TransitLine> line, Id<TransitRoute> route, Id<TransitStopFacility> originStop, Id<TransitStopFacility> destinationStop, double time) {
  try {
    return linesToStopDwellEvents.get(line.toString()).getRouteTravelTime(route, originStop, destinationStop, time);
  }catch(NullPointerException ne){
    return new Tuple(Double.POSITIVE_INFINITY,Double.POSITIVE_INFINITY);
  }
}

代码示例来源:origin: matsim-org/matsim

private void writeZones() {
    for (Zone z : zones.values()) {
      List<Tuple<String, String>> atts = new ArrayList<>();
      atts.add(new Tuple<String, String>("id", z.getId().toString()));

      String type = z.getType();
      if (type != null && !type.isEmpty()) {
        atts.add(new Tuple<String, String>("type", type));
      }

      writeStartTag("zone", atts, true);
    }
  }
}

代码示例来源:origin: matsim-org/matsim

private void writeVehicles() {
    for (Vehicle veh : vehicles) {
      List<Tuple<String, String>> atts = Arrays.asList(
          new Tuple<>("id", veh.getId().toString()),
          new Tuple<>("start_link", veh.getStartLink().getId().toString()),
          new Tuple<>("t_0", veh.getServiceBeginTime() + ""),
          new Tuple<>("t_1", veh.getServiceEndTime() + ""),
          new Tuple<>("capacity", veh.getCapacity() + ""));
      writeStartTag("vehicle", atts, true);
    }
  }
}

代码示例来源:origin: matsim-org/matsim

public double getRouteStopWaitTime(Id<TransitLine> lineId, Id<TransitRoute> routeId, Id<TransitStopFacility> stopId, double time) {
  Tuple<Id<TransitLine>, Id<TransitRoute>> key = new Tuple<Id<TransitLine>, Id<TransitRoute>>(lineId, routeId);
  WaitTimeData waitTimeData = waitTimes.get(key).get(stopId);
  if(waitTimeData.getNumData((int) (time/timeSlot))==0) {
    double[] waitTimes = scheduledWaitTimes.get(key).get(stopId);
    return waitTimes[(int) (time/timeSlot)<waitTimes.length?(int) (time/timeSlot):(waitTimes.length-1)];
  }
  else
    return waitTimeData.getWaitTime((int) (time/timeSlot));
}
@Override

代码示例来源:origin: matsim-org/matsim

@Override
public double getRouteStopWaitTime(Id<TransitLine> lineId, Id<TransitRoute> routeId, Id<TransitStopFacility> stopId, double time) {
  Tuple<Id<TransitLine>, Id<TransitRoute>> key = new Tuple<Id<TransitLine>, Id<TransitRoute>>(lineId, routeId);
  WaitTimeData waitTimeData = waitTimes.get(key).get(stopId);
  if(waitTimeData.getNumData((int) (time/timeSlot))==0) {
    double[] waitTimes = scheduledWaitTimes.get(key).get(stopId);
    return waitTimes[(int) (time/timeSlot)<waitTimes.length?(int) (time/timeSlot):(waitTimes.length-1)];
  }
  else
    return waitTimeData.getWaitTime((int) (time/timeSlot));
}
@Override

代码示例来源:origin: matsim-org/matsim

private double getStopStopTime(Id<TransitStopFacility> stopOId, Id<TransitStopFacility> stopDId, double time) {
  Tuple<Id<TransitStopFacility>, Id<TransitStopFacility>> key = new Tuple<Id<TransitStopFacility>, Id<TransitStopFacility>>(stopOId, stopDId);
  StopStopTimeData stopStopTimeData = stopStopTimes.get(key);
  if(stopStopTimeData.getNumData((int) (time/timeSlot))==0)
    return scheduledStopStopTimes.get(key);
  else
    return stopStopTimeData.getStopStopTime((int) (time/timeSlot));
}
private double getStopStopTimeVariance(Id<TransitStopFacility> stopOId, Id<TransitStopFacility> stopDId, double time) {

代码示例来源:origin: matsim-org/matsim

public void handleEvent(final VehicleArrivesAtFacilityEvent event) {
  List<Tuple<Id, Double>> list = this.positions.get(event.getVehicleId());
  if (list == null) {
    list = new ArrayList<Tuple<Id, Double>>();
    this.positions.put(event.getVehicleId(), list);
  }
  list.add(new Tuple<Id, Double>(event.getFacilityId(), Double.valueOf(event.getTime())));
}

代码示例来源:origin: matsim-org/matsim

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);
}

代码示例来源:origin: matsim-org/matsim

@Override
public void handleEvent(VehicleEntersTrafficEvent event) {
  if(!event.getNetworkMode().equals("car")){
    if( nonCarWarn <=1) {
      logger.warn("non-car modes are supported, however, not properly tested yet.");
      logger.warn(Gbl.ONLYONCE);
      nonCarWarn++;
    }
  }
  Tuple<Id<Link>, Double> linkId2Time = new Tuple<Id<Link>, Double>(event.getLinkId(), event.getTime());
  this.vehicleEntersTraffic.put(event.getVehicleId(), linkId2Time);
}

代码示例来源:origin: matsim-org/matsim

@Override
public void handleEvent(LinkEnterEvent event) {
  Tuple<Id<Link>, Double> linkId2Time = new Tuple<Id<Link>, Double>(event.getLinkId(), event.getTime());
  this.linkenter.put(event.getVehicleId(), linkId2Time);
}

代码示例来源:origin: matsim-org/matsim

public double getLinkToLinkTravelTime(final Id<Link> fromLinkId, final Id<Link> toLinkId, double time) {
  if (!this.calculateLinkToLinkTravelTimes) {
    throw new IllegalStateException("No link to link travel time is available " +
        "if calculation is switched off by config option!");
  }
  DataContainer data = this.getLinkToLinkTravelTimeData(new Tuple<>(fromLinkId, toLinkId), true);
  if (data.needsConsolidation) {
    consolidateData(data);
  }
  return this.aggregator.getTravelTime(data.ttData, time);
}

代码示例来源:origin: matsim-org/matsim

public void addDrivingLane(int laneNumber, Point2D.Double  drivingLaneStart, Point2D.Double drivingLaneEnd) {
  if (this.drivingLaneMap == null){
    this.drivingLaneMap = new HashMap<Integer, Tuple<Coord, Coord>>();
  }
  Tuple<Coord, Coord> tuple = new Tuple<Coord, Coord>(new Coord(drivingLaneStart.x, drivingLaneStart.y), new Coord(drivingLaneEnd.x, drivingLaneEnd.y));
  this.drivingLaneMap.put(laneNumber, tuple);
}

代码示例来源:origin: matsim-org/matsim

public VehicleOccupancyCalculator(final TransitSchedule transitSchedule, final Vehicles vehicles, final int timeSlot, final int totalTime) {
  this.timeSlot = timeSlot;
  for(TransitLine line:transitSchedule.getTransitLines().values())
    for(TransitRoute route:line.getRoutes().values()) {
      Map<Id<TransitStopFacility>, VehicleOccupancyData> routeMap = new HashMap<Id<TransitStopFacility>, VehicleOccupancyData>(100);
      vehicleOccupancy.put(new Tuple<Id<TransitLine>, Id<TransitRoute>>(line.getId(), route.getId()), routeMap);
      for(int s=0; s<route.getStops().size()-1; s++) {
        routeMap.put(route.getStops().get(s).getStopFacility().getId(), new VehicleOccupancyDataArray((int) (totalTime/timeSlot)+1));
      }
    }
  this.vehicles = vehicles;
}

代码示例来源:origin: matsim-org/matsim

@Override
public void handleEvent(VehicleArrivesAtFacilityEvent event) {
  if(!useVehicleIds || vehicleIds.contains(event.getVehicleId())) {
    Tuple<Id<TransitStopFacility>, Double> route = inTransitVehicles.remove(event.getVehicleId());
    if(route!=null)
      stopStopTimes.get(route.getFirst()).get(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

代码示例来源:origin: matsim-org/matsim

private Tuple<Integer,Integer> getZoneTupleForLinks(Coord coord) {
     double xCoord = coord.getX();
  double yCoord = coord.getY();
  
  int xDirection = (int) ((xCoord - xCoordMinLinkNode) / (noiseParams.getRelevantRadius() / 1.));	
  int yDirection = (int) ((yCoordMaxLinkNode - yCoord) / noiseParams.getRelevantRadius() / 1.);
  
  Tuple<Integer,Integer> zoneDefinition = new Tuple<Integer, Integer>(xDirection, yDirection);
  return zoneDefinition;
}

代码示例来源:origin: matsim-org/matsim

@Override
public void handleEvent(TransitDriverStartsEvent event) {
  this.ptVehicles.put(event.getVehicleId(), 0);
  VehicleCapacity vehicleCapacity = vehicles.getVehicles().get(event.getVehicleId()).getType().getCapacity();
  this.capacities.put(event.getVehicleId(), vehicleCapacity.getSeats()+vehicleCapacity.getStandingRoom());
  linesRoutesOfVehicle.put(event.getVehicleId(), new Tuple<Id<TransitLine>, Id<TransitRoute>>(event.getTransitLineId(), event.getTransitRouteId()));
}

相关文章

微信公众号

最新文章

更多