public NetworkRoutingInclAccessEgressModule( final String mode, final PopulationFactory populationFactory, final Network network, final LeastCostPathCalculator routeAlgo, PlansCalcRouteConfigGroup calcRouteConfig) { Gbl.assertNotNull(network); Gbl.assertIf( network.getLinks().size()>0 ) ; // otherwise network for mode probably not defined this.network = network; this.routeAlgo = routeAlgo; this.mode = mode; this.populationFactory = populationFactory; this.stageActivityType = this.mode + " interaction"; if ( !calcRouteConfig.isInsertingAccessEgressWalk() ) { throw new RuntimeException("trying to use access/egress but not switched on in config. " + "currently not supported; there are too many other problems") ; } }
public static final void printRoundTime() { log.info("### round time: " + Gbl.printTime()); Gbl.startMeasurement(); }
public static final void printBuildInfo() { printBuildInfo("MATSim", "/revision.txt"); }
/** * Constructor * * @param eventsMonitors */ protected PerceptHandler(final EventsMonitorRegistry eventsMonitors) { Gbl.assertNotNull( eventsMonitors ); this.eventsMonitors = eventsMonitors ; }
public static void main(String[] args) { Gbl.assertIf(args.length >=1 && args[0]!="" ); run(ConfigUtils.loadConfig(args[0])); // makes some sense to not modify the config here but in the run method to help with regression testing. }
/** * @param args array with 2 or 3 entries: * - path to network file: required * - path to plans file 0: required * - path to plans file 1: optional */ public static void main(final String[] args) { if (args.length < 2 || args.length > 3 ) { System.out.println("Too few arguments."); printUsage(); System.exit(1); } Gbl.startMeasurement(); final CreateSelectedPlansTables table=new CreateSelectedPlansTables(); if (args.length==3) { table.setTwoPlans(true); table.run(args[0], args[1], args[2]); } else { table.setTwoPlans(false); table.run(args[0], args[1], ""); } Gbl.printElapsedTime(); }
private QuadTree<ActivityFacility> buildFacQuadTree(String type, TreeMap<Id<ActivityFacility>,ActivityFacility> facilities_of_type) { Gbl.startMeasurement(); log.info(" building " + type + " facility quad tree"); double minx = Double.POSITIVE_INFINITY; double miny = Double.POSITIVE_INFINITY; double maxx = Double.NEGATIVE_INFINITY; double maxy = Double.NEGATIVE_INFINITY; for (final ActivityFacility f : facilities_of_type.values()) { if (f.getCoord().getX() < minx) { minx = f.getCoord().getX(); } if (f.getCoord().getY() < miny) { miny = f.getCoord().getY(); } if (f.getCoord().getX() > maxx) { maxx = f.getCoord().getX(); } if (f.getCoord().getY() > maxy) { maxy = f.getCoord().getY(); } } minx -= 1.0; miny -= 1.0; maxx += 1.0; maxy += 1.0; System.out.println(" xrange(" + minx + "," + maxx + "); yrange(" + miny + "," + maxy + ")"); QuadTree<ActivityFacility> quadtree = new QuadTree<ActivityFacility>(minx, miny, maxx, maxy); for (final ActivityFacility f : facilities_of_type.values()) { quadtree.put(f.getCoord().getX(),f.getCoord().getY(),f); } log.info(" done"); Gbl.printRoundTime(); Gbl.printMemoryUsage(); return quadtree; }
@Override public final void run() { while (simulationRunning) { try { /* * The End of the Replanning is synchronized with * the TimeStepEndBarrier. If all Threads reach this Barrier * the main run() Thread can go on. * * The Threads wait now at the TimeStepStartBarrier until * they are triggered again in the next TimeStep by the main run() * method. */ timeStepEndBarrier.await(); timeStepStartBarrier.await(); if (!simulationRunning) { Gbl.printCurrentThreadCpuTime(); return; } doReplanning(); } catch (InterruptedException | BrokenBarrierException e) { throw new RuntimeException(e); } } // while Simulation Running } // run()
private void scanZIPFile(ZipFile zipFile) { this.nextTime = -1; Enumeration<? extends ZipEntry> zipFileEntries = zipFile.entries(); System.out.println("Scanning timesteps:"); Gbl.startMeasurement(); while (zipFileEntries.hasMoreElements()) { ZipEntry entry = zipFileEntries.nextElement(); String currentEntry = entry.getName(); if (currentEntry.contains("step")) { String[] spliti = StringUtils.explode(currentEntry, '.', 10); double time_s = Double.parseDouble(spliti[1]); if (this.nextTime == -1) { this.nextTime = time_s; } this.timesteps.put(time_s, entry.getSize()); System.out.print(time_s); System.out.print(", "); } } System.out.println(""); System.out.println("Nr of timesteps: " + this.timesteps.size()); }
@Override protected final void beforeFinishReplanningHook() { Gbl.printMemoryUsage(); }
private static void initLogging(String outputFilename, String warnLogfileName) throws IOException { Logger root = Logger.getRootLogger(); final boolean appendToExistingFile = false; FileAppender appender = new FileAppender(Controler.DEFAULTLOG4JLAYOUT, outputFilename, appendToExistingFile); appender.setName(LOGFILE); root.addAppender(appender); FileAppender warnErrorAppender = new FileAppender(Controler.DEFAULTLOG4JLAYOUT, warnLogfileName, appendToExistingFile); warnErrorAppender.setName(WARNLOGFILE); warnErrorAppender.setThreshold(Level.WARN); root.addAppender(warnErrorAppender); if (collectLogMessagesAppender != null) { for (LoggingEvent e : collectLogMessagesAppender.getLogEvents()) { appender.append(e); if (e.getLevel().isGreaterOrEqual(Level.WARN)) { warnErrorAppender.append(e); } } collectLogMessagesAppender.close(); collectLogMessagesAppender = null; } Gbl.printSystemInfo(); Gbl.printBuildInfo(); }
public NetworkRoutingModule( final String mode, final PopulationFactory populationFactory, final Network network, final LeastCostPathCalculator routeAlgo) { Gbl.assertNotNull(network); // Gbl.assertIf( network.getLinks().size()>0 ) ; // otherwise network for mode probably not defined // makes many tests fail. this.network = network; this.routeAlgo = routeAlgo; this.mode = mode; this.populationFactory = populationFactory; }
public static Trip findTripStartingAtActivity( final Activity activity, final Plan plan, StageActivityTypes stageActivities ) { Gbl.assertIf( ! stageActivities.isStageActivity( activity.getType()) ) ; List<Trip> trips = getTrips( plan, stageActivities ) ; for ( Trip trip : trips ) { if ( trip.getOriginActivity().equals( activity ) ) { return trip ; } } return null ; }
public static void main(String[] args) { Gbl.startMeasurement(); MutableScenario sc = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); String networkFile = "f:/p_runs/txl/network.final.xml.gz"; String inPlansFile = "f:/p_runs/txl/run71/it.380/run71.380.plans.xml.gz"; String outFilename = "f:/p_runs/txl/run71/it.380/actsFromParatransitUsers.txt"; new MatsimNetworkReader(sc.getNetwork()).readFile(networkFile); Population inPop = sc.getPopulation(); MatsimReader popReader = new PopulationReader(sc); popReader.readFile(inPlansFile); ActivityLocationsParatransitUser ana = new ActivityLocationsParatransitUser("para_", 100.0); ana.parsePopulation(inPop); ana.writeResults(outFilename); Gbl.printElapsedTime(); } }
Gbl.printCurrentThreadCpuTime(); return;
@Override protected final void beforeFinishReplanningHook() { Gbl.printMemoryUsage() ; }
public final void putAccessibilityContributionCalculator(String mode, AccessibilityContributionCalculator calculator) { LOG.info("Adding accessibility contribution calculator for " + mode + "."); Gbl.assertNotNull(calculator); this.calculators.put(mode , calculator) ; }
@Override public boolean handle(String agentID, String actionID, Object[] args) { // assertions: MobsimAgent mobsimAgent = model.getMobsimAgentFromIdString(agentID) ; Gbl.assertNotNull(mobsimAgent) ; Gbl.assertIf( args.length >= 1 ); Gbl.assertIf( args[0] instanceof MATSimModel.RoutingMode) ; // could have some default MATSimModel.RoutingMode routingMode = (MATSimModel.RoutingMode)args[0]; if (WithinDayAgentUtils.isOnReplannableCarLeg(mobsimAgent)) { model.getReplanner().editTrips().replanCurrentTrip(mobsimAgent, 0.0, routingMode.name()); } return true; } }
public static Trip findTripEndingAtActivity(Activity activity, Plan plan, StageActivityTypes stageActivities ) { Gbl.assertIf( ! stageActivities.isStageActivity( activity.getType()) ) ; List<Trip> trips = getTrips(plan.getPlanElements(), stageActivities ) ; for ( Trip trip : trips ) { if ( activity.equals( trip.getDestinationActivity() ) ) { return trip; } } return null ; } public static Trip findTripStartingAtActivity( final Activity activity, final Plan plan, StageActivityTypes stageActivities ) {
@Override public Boolean call() { // implementing "call" and "run" side by side because it seems the easier way to // experimentally switch between the two types of threading. // kai, jan'14 // Check if Simulation is still running. Otherwise print CPU usage and end thread. if (!this.simulationRunning) { Gbl.printCurrentThreadCpuTime(); return false; } if (this.movingNodes) { moveNodes(); } else { moveLinks(); } return true ; }