Codota Logo
NetsimEngineContext
Code IndexAdd Codota to your IDE (free)

How to use
NetsimEngineContext
in
org.matsim.core.mobsim.qsim.qnetsimengine

Best Java code snippets using org.matsim.core.mobsim.qsim.qnetsimengine.NetsimEngineContext (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Point p =
  • Codota Iconnew Point(x, y)
  • Codota Iconnew Point()
  • Codota IconMouseEvent e;e.getPoint()
  • Smart code suggestions by Codota
}
origin: matsim-org/matsim

@Override void initializeFactory(AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface netsimEngine1) {
  double effectiveCellSize = ((Network)network).getEffectiveCellSize() ;
  
  SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator();
  linkWidthCalculator.setLinkWidthForVis( qsimConfig.getLinkWidthForVis() );
  if (! Double.isNaN(network.getEffectiveLaneWidth())){
    linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() );
  }
  AbstractAgentSnapshotInfoBuilder snapshotBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator );
  
  this.context = new NetsimEngineContext(events, effectiveCellSize, agentCounter, snapshotBuilder, qsimConfig, mobsimTimer, linkWidthCalculator ) ;
  
  this.netsimEngine = netsimEngine1 ;
}
@Override QNodeI createNetsimNode(Node node) {
origin: matsim-org/matsim

@Override
public final void letVehicleDepart(QVehicle vehicle) {
  double now = context.getSimTimer().getTimeOfDay();
  
  MobsimDriverAgent driver = vehicle.getDriver();
  if (driver == null) throw new RuntimeException("Vehicle cannot depart without a driver!");
  EventsManager eventsManager = context.getEventsManager();
  eventsManager.processEvent(new PersonEntersVehicleEvent(now, driver.getId(), vehicle.getId()));
  this.addDepartingVehicle(vehicle);
}
origin: matsim-org/matsim

@Override
public final void clearVehicles() {
  // yyyyyy right now it seems to me that one should rather just abort the agents and have the framework take care of the rest. kai, mar'16
  double now = context.getSimTimer().getTimeOfDay() ;
  for (QVehicle veh : vehQueue) {
    context.getEventsManager().processEvent( new VehicleAbortsEvent(now, veh.getId(), veh.getCurrentLink().getId()));
    context.getEventsManager().processEvent( new PersonStuckEvent(now, veh.getDriver().getId(), veh.getCurrentLink().getId(), veh.getDriver().getMode()));
    context.getAgentCounter().incLost();
    context.getAgentCounter().decLiving();
  }
  vehQueue.clear();
  for (QVehicle veh : buffer) {
    context.getEventsManager().processEvent( new VehicleAbortsEvent(now, veh.getId(), veh.getCurrentLink().getId()));
    context.getEventsManager().processEvent( new PersonStuckEvent(now, veh.getDriver().getId(), veh.getCurrentLink().getId(), veh.getDriver().getMode()));
    context.getAgentCounter().incLost();
    context.getAgentCounter().decLiving();
  }
  buffer.clear();
  holes.clear();
  this.remainingHolesStorageCapacity = this.storageCapacity;
}
origin: matsim-org/matsim

private final QVehicle removeFirstVehicle(){
  double now = context.getSimTimer().getTimeOfDay() ;
  QVehicle veh = buffer.poll();
  bufferLastMovedTime = now; // just in case there is another vehicle in the buffer that is now the new front-most
  if( context.qsimConfig.isUsingFastCapacityUpdate() ) {
    flowcap_accumulate.setTimeStep(now - 1);
  }
  return veh;
}
origin: matsim-org/matsim

private void moveVehicleFromInlinkToAbort(final QVehicle veh, final QLaneI fromLane, final double now, Id<Link> currentLinkId) {
  fromLane.popFirstVehicle();
  // -->
  this.context.getEventsManager().processEvent(new LinkLeaveEvent(now, veh.getId(), currentLinkId));
  // <--
  
  // first treat the passengers:
  for ( PassengerAgent pp : veh.getPassengers() ) {
    if ( pp instanceof MobsimAgent ) {
      ((MobsimAgent)pp).setStateToAbort(now);
      netsimEngine.arrangeNextAgentState((MobsimAgent)pp) ;
    } else if ( wrnCnt < 1 ) {
      wrnCnt++ ;
      log.warn("encountering PassengerAgent that cannot be cast into a MobsimAgent; cannot say if this is a problem" ) ;
      log.warn(Gbl.ONLYONCE) ;
    }
  }
  
  // now treat the driver:
  veh.getDriver().setStateToAbort(now) ;
  netsimEngine.arrangeNextAgentState(veh.getDriver()) ;
  
}

origin: matsim-org/matsim

private void processArrivalOfHoles() {
  double now = context.getSimTimer().getTimeOfDay() ;
  while ( this.holes.size()>0 && this.holes.peek().getEarliestLinkExitTime() < now ) {
    Hole hole = this.holes.poll() ; // ???
    this.remainingHolesStorageCapacity += hole.getSizeInEquivalents() ;
  }
}
origin: matsim-org/matsim

context .getEventsManager() .processEvent(
        new VehicleEntersTrafficEvent(now, veh.getDriver().getId(),
            this.getLink().getId(), veh.getId(), veh.getDriver().getMode(), 1.0));
origin: matsim-org/matsim

private void moveVehicleFromInlinkToOutlink(final QVehicle veh, Id<Link> currentLinkId, final QLaneI fromLane, Id<Link> nextLinkId, QLaneI nextQueueLane) {
  double now = this.context.getSimTimer().getTimeOfDay() ;
  
  fromLane.popFirstVehicle();
  // -->
  //		network.simEngine.getMobsim().getEventsManager().processEvent(new LaneLeaveEvent(now, veh.getId(), currentLinkId, fromLane.getId()));
  this.context.getEventsManager().processEvent(new LinkLeaveEvent(now, veh.getId(), currentLinkId));
  // <--
  
  veh.getDriver().notifyMoveOverNode( nextLinkId );
  
  // -->
  this.context.getEventsManager().processEvent(new LinkEnterEvent(now, veh.getId(), nextLinkId ));
  // <--
  nextQueueLane.addFromUpstream(veh);
}

origin: matsim-org/matsim

private void updateFastFlowAccumulation(){
  double now = context.getSimTimer().getTimeOfDay() ;
  if( this.flowcap_accumulate.getTimeStep() < now
      && this.flowcap_accumulate.getValue() < flowCapacityPerTimeStep
      && isNotOfferingVehicle() ){
    double timeSteps = (now - flowcap_accumulate.getTimeStep()) / context.qsimConfig.getTimeStepSize();
    double accumulateFlowCap = timeSteps * flowCapacityPerTimeStep;
    double newFlowCap = Math.min(flowcap_accumulate.getValue() + accumulateFlowCap,
        flowCapacityPerTimeStep);
    flowcap_accumulate.setValue(newFlowCap);
    flowcap_accumulate.setTimeStep( now );
  }
}
origin: matsim-org/matsim

@Override
void initializeFactory( AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface netsimEngine1 ) {
  this.netsimEngine = netsimEngine1;
  double effectiveCellSize = network.getEffectiveCellSize() ;
  SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator();
  linkWidthCalculator.setLinkWidthForVis( qsimConfig.getLinkWidthForVis() );
  if (! Double.isNaN(network.getEffectiveLaneWidth())){
    linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() );
  }
  AbstractAgentSnapshotInfoBuilder agentSnapshotInfoBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator );
  context = new NetsimEngineContext( events, effectiveCellSize, agentCounter, agentSnapshotInfoBuilder, qsimConfig, mobsimTimer, linkWidthCalculator );
}
@Override
origin: matsim-org/matsim

@Override
public void clearVehicles() {
  double now = context.getSimTimer().getTimeOfDay();
      context.getEventsManager().processEvent(
          new VehicleAbortsEvent(now, veh.getId(), veh.getCurrentLink().getId()));
      context.getEventsManager().processEvent(
          new PersonStuckEvent(now, veh.getDriver().getId(), veh.getCurrentLink().getId(), veh.getDriver().getMode()));
      context.getAgentCounter().incLost();
      context.getAgentCounter().decLiving();
      context.getEventsManager().processEvent(
          new PersonStuckEvent(now, mobsimAgent.getId(), veh.getCurrentLink().getId(), mobsimAgent.getMode()));
      context.getAgentCounter().incLost();
      context.getAgentCounter().decLiving();
    context.getEventsManager().processEvent(
        new PersonStuckEvent(now, driver.getId(), driver.getCurrentLinkId(), driver.getMode()));
    context.getAgentCounter().incLost();
    context.getAgentCounter().decLiving();
      context.getEventsManager().processEvent(
          new PersonStuckEvent(now, driver.getId(), driver.getCurrentLinkId(), driver.getMode()));
      context.getAgentCounter().incLost();
      context.getAgentCounter().decLiving();
      context.getEventsManager().processEvent(
          new PersonStuckEvent(now, passenger.getId(), passenger.getCurrentLinkId(), passenger.getMode()));
      this.context.getAgentCounter().incLost();
origin: matsim-org/matsim

@Override
public final QVehicle popFirstVehicle() {
  double now = context.getSimTimer().getTimeOfDay() ;
  QVehicle veh = removeFirstVehicle();
  if (this.context.qsimConfig.isUseLanes() ) {
    if (  hasMoreThanOneLane() ) {
      this.context.getEventsManager().processEvent(new LaneLeaveEvent( now, veh.getId(), this.qLink.getId(), this.getId() ));
    }
  }
  return veh;
}
origin: matsim-org/matsim

private void addToBuffer(final QVehicle veh) {
  // yy might make sense to just accumulate to "zero" and go into negative when something is used up.
  // kai/mz/amit, mar'12
  double now = context.getSimTimer().getTimeOfDay() ;
  flowcap_accumulate.addValue(-veh.getFlowCapacityConsumptionInEquivalents(), now);
  buffer.add(veh);
  if (buffer.size() == 1) {
    bufferLastMovedTime = now;
    // (if there is one vehicle in the buffer now, there were zero vehicles in the buffer before.  in consequence,
    // need to reset the lastMovedTime.  If, in contrast, there was already a vehicle in the buffer before, we can
    // use the lastMovedTime that was (somehow) computed for that vehicle.)
  }
  final QNodeI toNode = qLink.getToNodeQ();
  if ( toNode instanceof QNodeImpl ) {
    ((QNodeImpl) toNode).activateNode();
    // yy for an "upstream" QLane, this activates the toNode too early.  Yet I think I founds this
    // also in the original QLane code.  kai, sep'13
  }
}
origin: matsim-org/matsim

@Override
void initializeFactory(AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface netsimEngine1) {
  this.netsimEngine = netsimEngine1 ;
  double effectiveCellSize = network.getEffectiveCellSize() ;
  SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator();
  linkWidthCalculator.setLinkWidthForVis( qsimConfig.getLinkWidthForVis() );
  if (! Double.isNaN(network.getEffectiveLaneWidth())){
    linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() );
  }
  AbstractAgentSnapshotInfoBuilder agentSnapshotInfoBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator );
  context = new NetsimEngineContext( events, effectiveCellSize, agentCounter, agentSnapshotInfoBuilder, qsimConfig, mobsimTimer, linkWidthCalculator );
  delegate.initializeFactory(agentCounter, mobsimTimer, netsimEngine1);
}
origin: matsim-org/matsim

@Override
public final boolean insertPassengerIntoVehicle(MobsimAgent passenger, Id<Vehicle> vehicleId) {
  double now = context.getSimTimer().getTimeOfDay();
  
  QVehicle vehicle = this.getParkedVehicle(vehicleId);
  // if the vehicle is not parked at the link, mark the agent as passenger waiting for vehicle
  if (vehicle == null) {
    registerPassengerAgentWaitingForCar(passenger, vehicleId);
    return false;
  } else {
    boolean added = vehicle.addPassenger((PassengerAgent) passenger);
    if (!added) {
      log.warn("Passenger " + passenger.getId().toString() +
      " could not be inserted into vehicle " + vehicleId.toString() +
      " since there is no free seat available!");
      return false;
    }
    ((PassengerAgent) passenger).setVehicle(vehicle);
    EventsManager eventsManager = context.getEventsManager();
    eventsManager.processEvent(new PersonEntersVehicleEvent(now, passenger.getId(), vehicle.getId()));
    // TODO: allow setting passenger's currentLinkId to null
    return true;
  }
}
origin: matsim-org/matsim

double now = context.getSimTimer().getTimeOfDay() ;
origin: matsim-org/matsim

@Override
void initializeFactory(AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface arg2) {
  network = arg2.getNetsimNetwork().getNetwork();
  double effectiveCellSize = ( network).getEffectiveCellSize() ;
  SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator();
  linkWidthCalculator.setLinkWidthForVis( qsimConfig.getLinkWidthForVis() );
  if (! Double.isNaN(network.getEffectiveLaneWidth())){
    linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() );
  }
  AbstractAgentSnapshotInfoBuilder snapshotInfoBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator );
  this.context = new NetsimEngineContext( events, effectiveCellSize, agentCounter, snapshotInfoBuilder, qsimConfig, mobsimTimer, linkWidthCalculator ) ;
  
  this.netsimEngine = arg2 ;
}
origin: matsim-org/matsim

/* package */ final void letVehicleArrive(QVehicle qveh) {
  addParkedVehicle(qveh);
  double now = context.getSimTimer().getTimeOfDay();;
  context.getEventsManager().processEvent(new VehicleLeavesTrafficEvent(now , qveh.getDriver().getId(), 
      this.link.getId(), qveh.getId(), qveh.getDriver().getMode(), 1.0 ) ) ;
  
  this.netsimEngine.letVehicleArrive(qveh);
  makeVehicleAvailableToNextDriver(qveh);
}
origin: matsim-org/matsim

@Override public void recalcTimeVariantAttributes() {
  double now = context.getSimTimer().getTimeOfDay() ;
  qlane.changeUnscaledFlowCapacityPerSecond( this.getLink().getFlowCapacityPerSec(now ) );
  qlane.changeEffectiveNumberOfLanes(this.getLink().getNumberOfLanes(now));
  //		qlane.changeSpeedMetersPerSecond( getLink().getFreespeed(now) ) ; flowCap & nLanes are "push", freeSpeed is
  //"pull".  This is not completely honest w.r.t. freeSpeed consequences to the fdiag, but also wasn't correctly
  //thought through/implemented when I found it.  kai, feb'18
  qlane.recalcTimeVariantAttributes();
}
origin: matsim-org/matsim

@Override
void initializeFactory( AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface netsimEngine1 ) {
  this.netsimEngine = netsimEngine1;
  double effectiveCellSize = scenario.getNetwork().getEffectiveCellSize() ;
  SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator();
  linkWidthCalculator.setLinkWidthForVis( scenario.getConfig().qsim().getLinkWidthForVis() );
  linkWidthCalculator.setLaneWidth( scenario.getNetwork().getEffectiveLaneWidth() );
  AbstractAgentSnapshotInfoBuilder agentSnapshotInfoBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator );
  context = new NetsimEngineContext( events, effectiveCellSize, agentCounter, agentSnapshotInfoBuilder, scenario.getConfig().qsim(), 
      mobsimTimer, linkWidthCalculator );
}
@Override
org.matsim.core.mobsim.qsim.qnetsimengineNetsimEngineContext

Most used methods

  • <init>
  • getSimTimer
  • getAgentCounter
  • getEventsManager

Popular in Java

  • Reactive rest calls using spring rest template
  • startActivity (Activity)
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now