/** * Adds a single network change event and applies it to the corresponding * links. * * @param event * a network change event. */ @Override public void addNetworkChangeEvent(final NetworkChangeEvent event) { this.networkChangeEvents.add(event); for (Link link : event.getLinks()) { if (link instanceof TimeVariantLinkImpl) { ((TimeVariantLinkImpl)link).applyEvent(event); } else { throw new IllegalArgumentException("Link " + link.getId().toString() + " is not timeVariant. " + "Did you make the network factory time variant? The easiest way to achieve this is " + "either in the config file, or syntax of the type\n" + "config.network().setTimeVariantNetwork(true);\n" + "Scenario scenario = ScenarioUtils.load/createScenario(config);\n" + "Note that the scenario needs to be created _after_ the config option is set, otherwise" + "the factory will already be there."); } } }
private void applyTheChangeEvent(NetworkChangeEvent changeEvent) { for (Link link : changeEvent.getLinks()) { final NetsimLink netsimLink = this.internalInterface.getMobsim().getNetsimNetwork().getNetsimLink(link.getId()); if ( netsimLink instanceof TimeVariantLink) { ((TimeVariantLink) netsimLink).recalcTimeVariantAttributes(); } else { throw new RuntimeException("link not time variant") ; } } }
public TtmobsimListener(NetworkChangeEvent nce) { if (nce.getLinks().size() > 1) { throw new RuntimeException("Expecting only one network change event for a single link. Aborting..."); } else { for (Link link : nce.getLinks()) { this.link = link; this.networkChangeEventTime = nce.getStartTime(); this.reducedFreespeed = nce.getFreespeedChange().getValue(); Assert.assertEquals(true, this.reducedFreespeed < this.link.getFreespeed()); } } }
private void addNetworkChangeEventToLocalDataStructure(NetworkChangeEvent networkChangeEvent) { ChangeValue freespeedChange = networkChangeEvent.getFreespeedChange(); if (freespeedChange != null) { double startTime = networkChangeEvent.getStartTime(); Map<Link,Double> newLinkSpeedsAtThisTime = changedLinksByTime.computeIfAbsent(startTime, k -> new HashMap<>()); for ( Link link : networkChangeEvent.getLinks() ) { // yy seems that the following should be available centrally. kai, dec'17 double newSpeed ; switch ( freespeedChange.getType() ) { case ABSOLUTE_IN_SI_UNITS: newSpeed = freespeedChange.getValue() ; break; case FACTOR: newSpeed = link.getFreespeed() * freespeedChange.getValue() ; break; case OFFSET_IN_SI_UNITS: newSpeed = link.getFreespeed() + freespeedChange.getValue() ; break; default: throw new RuntimeException("change event type not implemented") ; } if ( startTime > 0. ) { log.debug( "registering a change event for time=" + startTime + "; linkId=" + link.getId() ) ; } newLinkSpeedsAtThisTime.put( link, newSpeed ) ; } } }