Skip to main content

Scripted simulations reference

In addition to the common methods described in Groovy reference, the scripts of the Scritped Simulation also define the following methods.

👷👷🏾 Document all the methods of ScriptSimBaseScript

Timetable transformations

The timetableTransformations method gives access to the builders and allows you to create the timetable transformations that can be used, for example, with withTimetableTransformations.

Now we will take a look at the available builders. We will also see if it is possible to concatenate a train matcher as well (withTrainMatcher method), a path entry matcher withEntryMatcher or a trainset matcher (withTrainsetMatcher method).

changeStationTrack

changeStationTrack(stationName, originalTrackName, newTrackName).withTrainMatcher('...').withEntryMatcher('...')

changeTrainset

Replaces the trainset with the name oldTrainsetName with the trainset with the name newTrainsetName, for all the trains that satisfy the train matcher, if specified. The first form allows specifying a different RollingStock from the default one.

changeTrainset(rollingStock, oldTrainsetName, newTrainsetName).withTrainMatcher('...')

changeTrainset(oldTrainsetName, newTrainsetName).withTrainMatcher('...')

setTrainset

Assignes the trainset with newTrainsetName name to all the trains that satisfy the given train matcher, if specified. The first form allows you to specify a RollingStock different from the default one.

setTrainset(rollingStock, newTrainsetName).withTrainMatcher('...')

setTrainset(newTrainsetName).withTrainMatcher('...')

duplicateTrain

Duplicate an existing train, moving the new train forward or backward in time.

duplicateTrain(existingTrainNumber).withOffset(seconds).withNewTrainNumber(newTrainNumber)

The method withNewTrainNumber requires a new train number, for example, withNewTrainNumber('1A23-bis'), or an expression Sed Search/Replace, for example, withNewTrainNumber('s/(.+)_(.+)/$1_bis_$2'). Each capture group of the expression Search can be referenced with $1, $2, etc. in the Replace expression.

Besides withNewTrainNumber, there are also withPrefix and withSuffix methods available used to add a prefix or a suffix to the name of the original train. If a prefix, a suffix or a new train number is not defined, the suffix -bis will be used instead.

If you want to specify the offset in minutes or hours, use the withOffsetMinutes(minutes) and withOffsetHours(hours) methods.

duplicateTrains

Duplicates all the trains, or only those that satisfy a train matcher, and moves the copies forward or backward in time.

duplicateTrains().withOffset(seconds).withNewTrainNumber('s/$/-copy/').withTrainMatcher('operator = XR')

The withNewTrainNumber method requres a new train number, for example, withNewTrainNumber('1A23-bis'), or an expression Sed Search/Replace, for example, withNewTrainNumber('s/(.+)_(.+)/$1_bis_$2'). Each capture group of the expression Search can be referenced with $1, $2, etc. in the Replace expression.

Besides withNewTrainNumber, there are also withPrefix and withSuffix methods available used to add a prefix or a suffix to the name of the original train. If a prefix, a suffix or a new train number is not defined, the suffix -bis will be used instead.

If you want to specify the offset in minutes or hours, use the withOffsetMinutes(minutes) and withOffsetHours(hours) methods.

shiftTrain

Moving the train forward or backward in time.

shiftTrain(existingTrainNumber).withOffset(seconds)

If you want to specify the offset in minutes or hours, use the withOffsetMinutes(minutes) and withOffsetHours(hours) methods.

shiftTrains

Move all the trains, or the ones that satisfy a train matcher, forward or backward in time.

shiftTrains().withOffset(seconds).withTrainMatcher('operator = XR')

If you want to specify the offset in minutes or hours, use the withOffsetMinutes(minutes) and withOffsetHours(hours) methods.

partialPath

This function allows you to change the train path by specifying two stations the path should be built of.

partialPath(fromStation, toStation)

setEntryType

setMinStopTime

changeDistribution

assignDelayDistribution

assignPerformancesDistribution

assignPerformancesDistribution

transformDelayDistribution

Modify the distributions of the delays of all trains and the entries that correspond to the matchers.

  • Increase by 15 seconds all the DWELL_TIME_DELAY:
    transformDelayDistribution(DelayType.DWELL_TIME_DELAY).incrementDelay(15)
  • Decrease by 15 seconds all the DWELL_TIME_DELAY::
    transformDelayDistribution(DelayType.DWELL_TIME_DELAY).decrementDelay(15)
  • Increase by 30% all the INITIAL_DELAY:
    transformDelayDistribution(DelayType.INITIAL_DELAY).incrementPercentage(30)
  • Decrease by 20% all the INITIAL_DELAY:
    transformDelayDistribution(DelayType.INITIAL_DELAY).decrementPercentage(20)
  • Apply 90% of INITIAL_DELAY (equivalent to -10%):
    transformDelayDistribution(DelayType.INITIAL_DELAY).percentage(90)
  • Apply 110% of INITIAL_DELAY (equivalent to +10%):
    transformDelayDistribution(DelayType.INITIAL_DELAY).percentage(110)