congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
SnapshotGenerator
Code IndexAdd Tabnine to your IDE (free)

How to use
SnapshotGenerator
in
org.matsim.core.events.algorithms

Best Java code snippets using org.matsim.core.events.algorithms.SnapshotGenerator (Showing top 15 results out of 315)

origin: matsim-org/matsim

private void testForSnapshot(final double time) {
  int snapshotIndex = (int) (time / this.snapshotPeriod);
  if (this.lastSnapshotIndex == -1) {
    this.lastSnapshotIndex = snapshotIndex;
  }
  while (snapshotIndex > this.lastSnapshotIndex) {
    this.lastSnapshotIndex++;
    double snapshotTime = this.lastSnapshotIndex * this.snapshotPeriod;
    doSnapshot(snapshotTime);
  }
}
origin: matsim-org/matsim

@Override
public void handleEvent(final PersonDepartureEvent event) {
  testForSnapshot(event.getTime());
  this.eventLinks.get(event.getLinkId()).departure(getEventAgent(event.getPersonId(), event.getTime()));
}
origin: matsim-org/matsim

public static void convert(Scenario scenario, String eventFileName, String outFileName, double interval_s) {
  OTFFileWriter otfFileWriter = new OTFFileWriter(scenario, outFileName);
  EventsManager events = EventsUtils.createEventsManager();
  SnapshotGenerator visualizer = new SnapshotGenerator(scenario.getNetwork(), interval_s, scenario.getConfig().qsim());
  visualizer.addSnapshotWriter(otfFileWriter);
  events.addHandler(visualizer);
  new MatsimEventsReader(events).readFile(eventFileName);
  visualizer.finish();
  otfFileWriter.finish();
}
origin: matsim-org/matsim

  System.err.println("Trying to close visualizer file up to this state, it may not be complete though.");
this.visualizer.finish();
System.out.println("done.");
origin: matsim-org/matsim

private void loadSnapshotWriters(final String outputDir) {
  if (this.writer != null) {
    this.visualizer.addSnapshotWriter(this.writer);
  }
  Collection<String> snapshotFormat = this.config.controler().getSnapshotFormat();
  if (snapshotFormat.contains("transims")) {
    String snapshotFile = outputDir + "T.veh";
    this.visualizer.addSnapshotWriter(new TransimsSnapshotWriter(snapshotFile));
  }
  if (snapshotFormat.contains("googleearth")) {
    String snapshotFile = outputDir + "googleearth.kmz";
    String coordSystem = this.config.global().getCoordinateSystem();
    this.visualizer.addSnapshotWriter(new KmlSnapshotWriter(snapshotFile,
        TransformationFactory.getCoordinateTransformation(coordSystem, TransformationFactory.WGS84)));
  }
}
origin: matsim-org/matsim

private void prepare() {
  // create events
  this.events = EventsUtils.createEventsManager();
  // create SnapshotGenerator
  this.visualizer = new SnapshotGenerator(this.network, this.config.qsim().getSnapshotPeriod(), 
      this.config.qsim());
  this.events.addHandler(this.visualizer);
}
origin: matsim-org/matsim

private void doSnapshot(final double time) {
  if (time >= skipUntil) {
    if (!this.snapshotWriters.isEmpty()) {
      Collection<AgentSnapshotInfo> positions = getVehiclePositions(time);
      for (SnapshotWriter writer : this.snapshotWriters) {
        writer.beginSnapshot(time);
        for (AgentSnapshotInfo position : positions) {
          writer.addAgent(position);
        }
        writer.endSnapshot();
      }
    }
  }
}
origin: matsim-org/matsim

public SnapshotGenerator(final Network network, final double snapshotPeriod, final QSimConfigGroup config) {
  this.network = network;
  int initialCapacity = (int)(network.getLinks().size()*1.1);
  this.eventLinks = new HashMap<>(initialCapacity, 0.95f);
  this.linkList = new ArrayList<>(initialCapacity);
  this.eventAgents = new HashMap<>(1000, 0.95f);
  this.snapshotPeriod = snapshotPeriod;
  this.capCorrectionFactor = config.getFlowCapFactor() / network.getCapacityPeriod();
  this.storageCapFactor = config.getStorageCapFactor();
  this.snapshotStyle = config.getSnapshotStyle();
  
  if (! Double.isNaN( config.getLinkWidthForVis() )){
    this.linkWidthCalculator.setLinkWidthForVis( config.getLinkWidthForVis() );
  } 
  if (! Double.isNaN(network.getEffectiveLaneWidth())){
    this.linkWidthCalculator.setLaneWidth(network.getEffectiveLaneWidth());
  }
  reset(-1);
}
origin: matsim-org/matsim

public void makeMVI(Carriers carriers, String outfile, double snapshotInterval){
  OTFFileWriter otfFileWriter = new OTFFileWriter(scenario, outfile);
  
  EventsManager events = EventsUtils.createEventsManager();
  CarrierAgentTracker carrierAgentTracker = new CarrierAgentTracker(carriers, scenario.getNetwork(), new CarrierScoringFunctionFactory() {
    
    @Override
    public ScoringFunction createScoringFunction(Carrier carrier) {
      return getNoScoring();
    }
    
  });
  CarrierConfig carrierConfig = new CarrierConfig();
  carrierConfig.setPhysicallyEnforceTimeWindowBeginnings(true);
  FreightQSimFactory mobsimFactory = new FreightQSimFactory(scenario, events, carrierAgentTracker, carrierConfig);
  Mobsim mobsim = mobsimFactory.get();
  
  SnapshotGenerator visualizer = new SnapshotGenerator(scenario.getNetwork(), snapshotInterval, scenario.getConfig().qsim());
  visualizer.addSnapshotWriter(otfFileWriter);
  events.addHandler(visualizer);
  
  mobsim.run();
  
  visualizer.finish();
  otfFileWriter.finish();
}

origin: matsim-org/matsim

this.visualizer.finish();
System.out.println("done.");
origin: matsim-org/matsim

@Override
public void handleEvent(final PersonArrivalEvent event) {
  testForSnapshot(event.getTime());
  this.eventLinks.get(event.getLinkId()).arrival(getEventAgent(event.getPersonId(), event.getTime()));
}
origin: matsim-org/matsim

@Override
public void handleEvent(final PersonStuckEvent event) {
  testForSnapshot(event.getTime());
  if (event.getLinkId() != null) { // link id is optional - agent can be teleporting or whatever.
    this.eventLinks.get(event.getLinkId()).stuck(getEventAgent(event.getPersonId(), event.getTime()));
  }
}
origin: matsim-org/matsim

@Override
public void handleEvent(final LinkEnterEvent event) {
  testForSnapshot(event.getTime());
  this.eventLinks.get(event.getLinkId()).enter(getEventAgent(delegate.getDriverOfVehicle(event.getVehicleId()), event.getTime()));
}
origin: matsim-org/matsim

@Override
public void handleEvent(final LinkLeaveEvent event) {
  testForSnapshot(event.getTime());
  this.eventLinks.get(event.getLinkId()).leave(getEventAgent(delegate.getDriverOfVehicle(event.getVehicleId()), event.getTime()));
}
origin: matsim-org/matsim

@Override
public void handleEvent(final VehicleEntersTrafficEvent event) {
  testForSnapshot(event.getTime());
  this.eventLinks.get(event.getLinkId()).wait2link(getEventAgent(event.getPersonId(), event.getTime()));
  
  delegate.handleEvent(event);
}
org.matsim.core.events.algorithmsSnapshotGenerator

Most used methods

  • <init>
  • addSnapshotWriter
  • finish
  • doSnapshot
  • getEventAgent
  • getVehiclePositions
  • reset
  • testForSnapshot

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • onRequestPermissionsResult (Fragment)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • JFileChooser (javax.swing)
  • JLabel (javax.swing)
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now