-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prepare data before simulation (DrsData)
and refactoring: - remove .* imports - directly inject DrsConfigGroup where possible
- Loading branch information
1 parent
5e90f9d
commit 687ffae
Showing
12 changed files
with
131 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package at.ac.ait.matsim.drs.engine; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.matsim.api.core.v01.Scenario; | ||
import org.matsim.api.core.v01.network.Network; | ||
import org.matsim.contrib.common.zones.ZoneSystem; | ||
import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystem; | ||
import org.matsim.pt2matsim.tools.NetworkTools; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.google.inject.Inject; | ||
|
||
import at.ac.ait.matsim.drs.run.Drs; | ||
import at.ac.ait.matsim.drs.run.DrsConfigGroup; | ||
|
||
/** | ||
* Data that should only be prepared once (instead of each iteration) | ||
*/ | ||
public class DrsData { | ||
|
||
private static final Logger LOGGER = LogManager.getLogger(); | ||
|
||
private Network drsNetwork; | ||
private ZoneSystem zoneSystem; | ||
|
||
@Inject | ||
public DrsData(Scenario scenario, DrsConfigGroup drsConfig) { | ||
this.drsNetwork = NetworkTools.createFilteredNetworkByLinkMode(scenario.getNetwork(), | ||
ImmutableSet.of(Drs.DRIVER_MODE)); | ||
LOGGER.info("Filtered {} drs driver links from network with {} links", drsNetwork.getLinks().size(), | ||
scenario.getNetwork().getLinks().size()); | ||
|
||
this.zoneSystem = new SquareGridZoneSystem(scenario.getNetwork(), drsConfig.getCellSize()); | ||
LOGGER.info("Initialized zone system."); | ||
} | ||
|
||
public static Logger getLogger() { | ||
return LOGGER; | ||
} | ||
|
||
public Network getDrsNetwork() { | ||
return drsNetwork; | ||
} | ||
|
||
public ZoneSystem getZoneSystem() { | ||
return zoneSystem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.