public void printRelocateCount() { this.relocateCounter.printCounter(); }
@Override public void endTag( final String name, final String content, final Stack<String> context) { if (name.equals( "plans" )) { counter.printCounter(); try { writer.close(); } catch (IOException e) { throw new UncheckedIOException( e ); } } } }
public final void run(final Population plans) { log.info("running " + this.getClass().getName() + " algorithm..."); Counter counter = new Counter(" person # "); for (Person p : plans.getPersons().values()) { counter.incCounter(); this.run(p); } counter.printCounter(); log.info("done running algorithm."); }
public final void run(final Households households) { log.info("Running " + this.getClass().getName() + " algorithm..."); Counter counter = new Counter(" household # "); for(Household h : households.getHouseholds().values()) { this.run(h); counter.incCounter(); } counter.printCounter(); log.info("Done running algorithm."); }
/** * Run all the algorithms added to the container. */ public final void runAlgorithms(Households hh){ for(int i = 0; i < this.householdAlgorithms.size(); i++){ HouseholdAlgorithm algorithm = this.householdAlgorithms.get(i); log.info("Running algorithm " + algorithm.getClass().getName()); Counter c = new Counter (" household # "); for(Household household : hh.getHouseholds().values()){ algorithm.run(household); c.incCounter(); } c.printCounter(); log.info("Done running algorithm."); } }
protected FixedGroupsIdentifier parse( final XMLStreamReader streamReader) throws XMLStreamException { final Counter counter = new Counter( "parsing group # " ); final List<Collection<Id<Person>>> groups = new ArrayList<>(); List<Id<Person>> currentGroup = new ArrayList<>(); groups.add( currentGroup ); while ( streamReader.hasNext() ) { if ( streamReader.next() != XMLStreamConstants.START_ELEMENT ) continue; if ( streamReader.getLocalName().equals( "clique" ) && currentGroup.size() > 0 ) { counter.incCounter(); currentGroup = new ArrayList<>(); groups.add( currentGroup ); } if ( streamReader.getLocalName().equals( "person" ) ) { currentGroup.add( parseId( streamReader , Person.class ) ); } } counter.printCounter(); return new FixedGroupsIdentifier( groups ); }
private void writeEgos() { log.info( "start writing egos..." ); final Counter counter = new Counter( "[SocialNetworkWriter] writing ego # " ); for ( Id ego : network.getEgos() ) { counter.incCounter(); final List<Tuple<String,String>> atts = new ArrayList<Tuple<String, String>>(); atts.add( createTuple( EGO_ATT , ego.toString() ) ); writeStartTag( EGO_TAG , atts , true ); } counter.printCounter(); log.info( "finished writing egos." ); }
public void readFileRunAlgorithmsAndWriteFile(String inputFile, String outputFile){ if (inputFile.equalsIgnoreCase(outputFile)){ throw new IllegalArgumentException("Inputfile and outputfile must not refer to the same filename!"); } hhWriter = new HouseholdsWriterV10(super.getHouseholds()); hhWriter.openFileAndWritePreamble(outputFile); super.readFile(inputFile); counter.printCounter(); hhWriter.writeEndAndCloseFile(); log.info("Done reading households, running algorithms, and writing file"); }
counter.printCounter();
private void writeNetwork() { log.info( "start writing ties..." ); final Counter counter = new Counter( "[SocialNetworkWriter] writing tie # " ); final Set<Id> dumpedEgos = new HashSet<Id>(); final boolean reflective = network.isReflective(); for ( Id ego : network.getEgos() ) { final Iterable<Id<Person>> alters = network.getAlters( ego ); for ( Id<Person> alter : alters ) { if ( reflective && dumpedEgos.contains( alter ) ) continue; counter.incCounter(); final List<Tuple<String,String>> atts = new ArrayList<Tuple<String, String>>(); atts.add( createTuple( EGO_ATT , ego.toString() ) ); atts.add( createTuple( ALTER_ATT , alter.toString() ) ); writeStartTag( TIE_TAG , atts , true ); } dumpedEgos.add( ego ); } counter.printCounter(); log.info( "finished writing ties." ); } }
private void writeHouseholds(Households basicHouseholds) throws UncheckedIOException { Counter counter = new Counter("[HouseholdsWriter] wrote household # "); for (Household h : basicHouseholds.getHouseholds().values()) { this.writeHousehold(h); counter.incCounter(); } counter.printCounter(); }
@Override public void endTag(String name, String content, Stack<String> context) { if (HouseholdsSchemaV10Names.HOUSEHOLD.equalsIgnoreCase(name)) { fillHousehold(); ((HouseholdsImpl)this.households).addHousehold(currentHousehold); this.currentHousehold = null; counter.incCounter(); } else if (HouseholdsSchemaV10Names.INCOME.equalsIgnoreCase(name)) { this.currentincome = this.builder.createIncome(Double.parseDouble(content.trim()), this.currentIncomePeriod); this.currentincome.setCurrency(this.currentincomeCurrency); } else if (HouseholdsSchemaV10Names.HOUSEHOLDS.equalsIgnoreCase(name)) { counter.printCounter(); } else if (name.equalsIgnoreCase(HouseholdsSchemaV10Names.ATTRIBUTES)) { this.currAttributes = null; } else if (name.equalsIgnoreCase(HouseholdsSchemaV10Names.ATTRIBUTE)) { this.attributesReader.endTag( name , content , context ); } }
@Override public void run(Network network) { if (!multiModalConfigGroup.isCreateMultiModalNetwork()) { log.warn("Creation of multi modal network is not enabled in the config group - network is not adapted!"); return; } double cutoffSpeed = multiModalConfigGroup.getCutoffValueForNonCarModes(); String simulatedModes = multiModalConfigGroup.getSimulatedModes(); Set<String> modes = CollectionUtils.stringToSet(simulatedModes); Counter counter = new Counter("Converted links to multi-modal links: "); for (Link link : network.getLinks().values()) { if (Math.round(link.getFreespeed()) <= cutoffSpeed) { Set<String> allowedModes = new HashSet<>(link.getAllowedModes()); allowedModes.addAll(modes); link.setAllowedModes(allowedModes); counter.incCounter(); } } counter.printCounter(); } }
private void createReceiverPoints() { Counter counter = new Counter("create receiver point #"); for (double y = yCoordMax + 100. ; y > yCoordMin - 100. - noiseParams.getReceiverPointGap() ; y = y - noiseParams.getReceiverPointGap()) { for (double x = xCoordMin - 100. ; x < xCoordMax + 100. + noiseParams.getReceiverPointGap() ; x = x + noiseParams.getReceiverPointGap()) { Id<ReceiverPoint> id = Id.create(counter.getCounter(), ReceiverPoint.class); Coord coord = new Coord(x, y); ReceiverPoint rp = new ReceiverPoint(id, coord); receiverPoints.put(id, rp); counter.incCounter(); } } counter.printCounter(); log.info("Total number of receiver points: " + receiverPoints.size()); }
private void setActivityCoord2NearestReceiverPointId () { double gap = noiseParams.getReceiverPointGap(); Counter counter = new Counter("fill quadtree #") ; QuadTree<ReceiverPoint> qTree = new QuadTree<>(xCoordMin - 4*gap, yCoordMin - 4* gap, xCoordMax + 4*gap, yCoordMax + 4*gap); for(ReceiverPoint p: receiverPoints.values()) { qTree.put(p.getCoord().getX(), p.getCoord().getY(), p); counter.incCounter(); } counter.printCounter(); counter = new Counter("compute nearest receiver-points #"); for (Coord coord : consideredActivityCoordsForSpatialFunctionality) { // TODO maybe add a check here so we consider only the rp in the 9 surrounding cells? ReceiverPoint rp = qTree.getClosest(coord.getX(), coord.getY()); if(rp != null) { if(activityCoord2receiverPointId.put(coord, rp.getId()) != null){ log.warn("this must not happen"); } } counter.incCounter(); } counter.printCounter(); }
private void write(final String file) { final Counter counter = new Counter( "[JointPlansXmlWriter] dumped jointPlan # " ); openFile( file ); writeXmlHead(); writeDoctype( ROOT_TAG , "jointplans_v1.dtd" ); writeStartTag( ROOT_TAG, Collections.<Tuple<String, String>>emptyList() ); for (JointPlan jp : jointPlansSet) { counter.incCounter(); writeJointPlan( jp ); } counter.printCounter(); writeEndTag( ROOT_TAG ); close(); }
public static SocialNetwork createNetworkOfUnknownFriendsOfFriends( final SocialNetwork socialNetwork ) { final Counter counter = new Counter( "search secondary friends of agent # "); final SocialNetwork secondaryNetwork = new SocialNetworkImpl( ); for ( Id ego : socialNetwork.getEgos() ) { final Set<Id<Person>> alters = socialNetwork.getAlters( ego ); counter.incCounter(); for ( Id<Person> alter : alters ) { final Set<Id<Person>> altersOfAlter = socialNetwork.getAlters( alter ); for ( Id<Person> alterOfAlter : altersOfAlter ) { // is the ego? if ( alterOfAlter.equals( ego ) ) continue; // already a friend? if ( alters.contains( alterOfAlter ) ) continue; secondaryNetwork.addBidirectionalTie( ego , alterOfAlter ); } } } counter.printCounter(); return secondaryNetwork; }
/** * Reads all Features in the file into the returned Set and initializes the instance of this class. */ public Collection<SimpleFeature> readFileAndInitialize(final String filename) throws UncheckedIOException { try { this.featureSource = ShapeFileReader.readDataFile(filename); this.init(); SimpleFeature ft = null; SimpleFeatureIterator it = this.featureSource.getFeatures().features(); this.featureSet = new ArrayList<SimpleFeature>(); log.info("features to read #" + this.featureSource.getFeatures().size()); Counter cnt = new Counter("features read #"); while (it.hasNext()) { ft = it.next(); this.featureSet.add(ft); cnt.incCounter(); } cnt.printCounter(); it.close(); return this.featureSet; } catch (IOException e) { throw new UncheckedIOException(e); } }
/** * Writes all plans to the file. */ @Override public final void write(final String filename) { try { this.openFile(filename); this.handler.writeHeaderAndStartElement(this.writer); this.handler.startPlans(this.population, this.writer); this.handler.writeSeparator(this.writer); this.writePersons(); this.handler.endPlans(this.writer); log.info("Population written to: " + filename); } catch (IOException e) { throw new UncheckedIOException(e); } finally { this.close(); counter.printCounter(); counter.reset(); } }
/** * Writes all plans to the output stream and closes it. * */ public final void write(OutputStream outputStream) { try { this.openOutputStream(outputStream); this.handler.writeHeaderAndStartElement(this.writer); this.handler.startPlans(this.population, this.writer); this.handler.writeSeparator(this.writer); this.writePersons(); this.handler.endPlans(this.writer); } catch (IOException e) { throw new UncheckedIOException(e); } finally { this.close(); counter.printCounter(); counter.reset(); } }