Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Adapting to SIMONA-API changes introduced by [PR#37](https://github.com/ie3-institute/simonaAPI/pull/37) [[#7](https://github.com/ie3-institute/MobilitySimulator/issues/7)]

[Unreleased]: https://github.com/ie3-institute/MobilitySimulator
53 changes: 26 additions & 27 deletions src/main/scala/edu/ie3/mobsim/MobilitySimulator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -619,21 +619,19 @@ object MobilitySimulator
* Time tick (as ArrayList) when simulation should be triggered again
*/
protected def doActivity(tick: Long): java.util.ArrayList[java.lang.Long] = {
/* Initialize the simulation in the first step */
if (tick == -1L) setup()
simulator
.map(_.doActivity(tick))
.getOrElse(
throw UninitializedException("Simulation is not yet initialized")
)
}

/** Setup the simulation using the args received from SIMONA. <p> Sets the
* paths for io with information received from SIMONA. Loads all necessary
* data such as probabilities, EV models, etc. and creates all objects such
* as EVs, POIs, and charging stations.
/** Initialize the simulation using the args received from SIMONA. <p> Sets
* the paths for io with information received from SIMONA. Loads all
* necessary data such as probabilities, EV models, etc. and creates all
* objects such as EVs, POIs, and charging stations.
*/
def setup(): Unit = {
protected def initialize(): java.util.ArrayList[java.lang.Long] = {

val availableEvData = evData.getOrElse(
throw InitializationException(
Expand Down Expand Up @@ -876,28 +874,29 @@ object MobilitySimulator
}
logger.debug("Done loading probabilities for trip distance")

simulator = Some(
new MobilitySimulator(
availableEvData,
chargingStations,
poisWithSizes,
startTime,
evs,
chargingHubTownIsPresent,
chargingHubHighwayIsPresent,
ioUtils,
categoricalLocation,
drivingSpeed,
firstDepartureOfDay,
lastTripOfDay,
parkingTime,
poiTransition,
tripDistance,
maxDistanceFromPoi,
thresholdChargingHubDistance
)
val mobSim = new MobilitySimulator(
availableEvData,
chargingStations,
poisWithSizes,
startTime,
evs,
chargingHubTownIsPresent,
chargingHubHighwayIsPresent,
ioUtils,
categoricalLocation,
drivingSpeed,
firstDepartureOfDay,
lastTripOfDay,
parkingTime,
poiTransition,
tripDistance,
maxDistanceFromPoi,
thresholdChargingHubDistance
)
simulator = Some(mobSim)

logger.info("Finished setup!")

mobSim.doActivity(-1L)
}
}