public class ScenarioGenerator
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
ScenarioGenerator.IncidentInfo
Class for comparing Incidents by severity.
|
class |
ScenarioGenerator.InvalidSeedDataException
Exception to indicate when the Seed file is not in an appropriate format
for reliability analysis.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String[] |
csvHeader |
private float |
dailyStudyPeriodDuration
Length (in hours) of the daily study period.
|
private boolean |
debug_output |
private DemandData |
demandData_GP
Data Structure holding the scenario generator GP segment demand
information for the Reliability Reporting Period.
|
private DemandData |
demandData_ML
Data structure holding the scenario generator ML segment demand
information for the Reliability Reporting Period.
|
private int[][] |
excludedDays
Array containing the number of each day type (Mon, Tue, etc) excluded in
each month.
|
private boolean |
incidentBool_GP
Boolean indicating if GP incident events should be included in the
Scenario Generation process.
|
private boolean |
incidentBool_ML
Boolean indicating if GP incident events should be included in the
Scenario Generation process.
|
private IncidentData |
incidentData_GP
Data structure holding the scenario generator GP segment incident
information for the Reliability Reporting Period.
|
private IncidentData |
incidentData_ML
Data structure holding the scenario generator ML segment incident
information for the Reliability Reporting Period.
|
private Scenario |
mlScenario
Scenario instance containing the Adjustment Factors for all generated ML
reliability scenarios.
|
private boolean |
mlUsed
Boolean indicating if the Scenario Generation process has managed lane
analysis.
|
static java.lang.String[] |
monthString
List of names of each month (used in MainWindow Log outputs).
|
private int |
numReplications
Number of replications for each Demand Combination (Default: 4).
|
private int |
numScenarios
Number of reliability scenarios generated.
|
private java.util.Random |
RNG
Instance of Java Random class used as the random number generator.
|
private long |
rngSeed
Random number generator seed used by the RNG variable.
|
private Scenario |
scenario
Scenario instance containing the Adjustment Factors for all generated GP
reliability scenarios.
|
private java.util.ArrayList<ScenarioInfo> |
scenarioInfos
List of ScenarioInfos for all generated reliability scenarios.
|
private Seed |
seed
Seed instance from which the scenarios will be generated.
|
private boolean |
weatherBool
Boolean indicating if weather events should be included in the Scenario
Generation process.
|
private WeatherData |
weatherData
Data Structure holding the scenario generator weather information for the
Reliability Reporting Period.
|
private java.util.ArrayList<WorkZone> |
workZoneData_GP
List of work zones (GP Only) for the Reliability Reporting Period.
|
private boolean |
wzBool
Boolean indicating if Work Zones should be included in the Scenario
Generation process.
|
Constructor and Description |
---|
ScenarioGenerator(Seed seed)
Constructor for the Scenario Generator Class
|
Modifier and Type | Method and Description |
---|---|
private boolean |
allInputValid()
Method to check if input is valid before the scenario generation
procedure can be run.
|
private int |
argMax(int[] arr)
Method to find the index of the maximum element of an array.
|
private int |
arraySum(java.util.ArrayList<java.lang.Integer> arr)
Method to sum an ArrayList.
|
private int |
arraySum(boolean[] arr)
Method to calculate the sum of an array.
|
private float |
arraySum(float[] arr)
Method to calculate the sum of an array.
|
private int |
arraySum(int[] arr)
Method to calculate the sum of an array.
|
private int |
arraySum(int[][] arr)
Method to calculate the sum of an array of arrays.
|
private void |
assignCurrMonthWeatherEvents(int[] expMonthFreqWT,
float[] currMonthScenCumProb,
int prevScenarioInfoMarker)
Method to assign the list of weather events (LWE) for the current month
to scenarios associated with the current month.
|
private void |
assignWorkZones()
Method that assigns all work zones (GP only) for the RRP.
|
private int |
calculateNumberOfScenarios(int[] numDayOfWeekInMonthAP)
Method to calculate the number of scenarios that will be generated by the
Hybrid Scenario Generation procedure with the current inputs.
|
private int[][] |
computeExpFreqOfWeatherEvents(int[] monthChangeIdx)
Method to calculate the expected frequency of events of each weather type
occur in each month.
|
private int[][] |
createAndAssignListIncidentEventsGP(int[] monthChangeIdx)
Method to create and assign the List of Incident Events (LIE) for GP
segments.
|
private int[][] |
createAndAssignListIncidentEventsML(int[] monthChangeIdx)
Method to create and assign the List of Incident Events (LIE) for ML
segments.
|
private void |
createAndAssignWeatherEvents(int[] monthChangeIdx)
Creates the List of Weather Events (LWE) and assigns the weather events
to the reliability scenarios.
|
private java.util.ArrayList<java.lang.Integer> |
createIntegerArrAscending(int length)
Method to create an ArrayList of integers ascending from 0 to one less
than the input length (0,1,..,length - 1).
|
private java.util.ArrayList<java.lang.Integer> |
createIntegerArrDist(int[] distArr)
Method to create an ArrayList of integer values matching a given
distribution.
|
private float[] |
createProbabilities(DemandData demandData)
Method to create the array of probabilities of each reliability scenario.
|
private float[] |
cumSumNormalize(float[] arr)
Method create an array of the normalized cumulative sums of the elements
of the input array.
|
private void |
excludeDays(int[] daysArr)
Method to exclude days from the array of the (12x7=84) array of active
days.
|
void |
excludeDaysInMonth(int[] numDays,
int month)
Method that excludes any days specified.
|
static void |
exportRawRLResults(Seed seed) |
private long |
factorial(int value)
Method to calculate the factorial of a non-negative integer.
|
private float[][] |
generateLogNormalDurationProbabilites(int[] numIncOfEachType)
Method to generate the probabilities of incident durations matching a log
normal distribution.
|
private float |
generateLogNormalProbability(float value,
float mean,
float stdev)
Calculates the value of a Log-Normal Probability Density Function (PDF)
with the input mean and standard deviation at the input value.
|
boolean |
generateScenarios()
Method to generate reliability scenarios for the RRP.
|
private int |
getColMax(int[][] arr,
int col)
Array to get the max of a column of a matrix (2D array).
|
Scenario |
getGPScenario()
Getter for GP Scenario object.
|
private float[][] |
getHCDurProbs()
Deprecated.
|
Scenario |
getMLScenario()
Getter for ML Scenario Object.
|
int |
getNumberOfReplications()
Getter for the number of replications of each Demand Combination that
will be generated.
|
private int[][] |
getNumScenAssignedDurationLength(int[] numIncOfEachType)
Method to calculate the number of scenarios assigned each duration
length.
|
long |
getRNGSeed()
Getter for the seed value used by the Random Number Generator during the
scenario generation process.
|
java.util.ArrayList<ScenarioInfo> |
getScenarioInfoList()
Getter for the ArrayList of ScenarioInfo objects.
|
static int[] |
getSeedDataFormatErrorLocation(Seed seed)
Finds the location of the first data format error for the specified seed.
|
void |
includeGPWorkZones(boolean val)
Method to indicate whether work zones are included in reliability
analysis.
|
void |
includeIncidentsGP(boolean val)
Method to indicate if GP incidents are included in reliability analysis.
|
void |
includeIncidentsML(boolean val)
Method to indicate if ML incidents are included in reliability analysis.
|
void |
includeWeather(boolean val)
Method to indicate if weather events are included in reliability
analysis.
|
private float |
logNormCDF(float value1,
float value2,
float step,
float mu,
float sigma)
Calculating the Log-Normal CDF between two values.
|
private void |
resetRNG()
Resets the Random number generator to a new one based on the RNG Seed.
|
private void |
resetRNG(long factor)
Resets the Random number generator to a new one based on the RNG Seed
times the input factor.
|
void |
setDemandDataGP(DemandData data)
Setter for the GP demand data used to generate scenarios
|
void |
setGPIncidentData(IncidentData data)
Setter for the GP segment incident data used to generate scenarios
|
void |
setMLDemandData(DemandData demandMLData)
Setter for the Managed Lane (ML) segment demand data information.
|
void |
setMLIncidentData(IncidentData incidentMLData)
Setter for the Managed Lane(ML) segment incident data used to generate
scenarios.
|
void |
setMLUsed(boolean mlUsed)
Setter for the boolean used to indicated if Managed Lanes should be
included in Scenario Generation.
|
void |
setNumberOfReplications(int numReplications)
Setter for the number of replications of each Demand Combination to be
generated.
|
void |
setRNGSeed(long newSeed)
Setter for the seed value for the Random Number Generator used in the
Scenario Generation process.
|
void |
setWeatherData(WeatherData data)
Setter for the weather data used to generate scenarios.
|
void |
setWorkZoneDataGP(java.util.ArrayList<WorkZone> data)
Setter the work zone data (GP Only) used in scenario generation.
|
static boolean |
validateSeedForReliabilityAnalysis(Seed seed)
Checks if the Seed data is valid for reliability analysis.
|
private final boolean debug_output
private Seed seed
private DemandData demandData_GP
private WeatherData weatherData
private IncidentData incidentData_GP
private java.util.ArrayList<WorkZone> workZoneData_GP
private boolean wzBool
private boolean weatherBool
private boolean incidentBool_GP
private boolean mlUsed
private IncidentData incidentData_ML
private DemandData demandData_ML
private boolean incidentBool_ML
private Scenario scenario
private java.util.ArrayList<ScenarioInfo> scenarioInfos
private Scenario mlScenario
private final float dailyStudyPeriodDuration
private int numReplications
private int numScenarios
private final int[][] excludedDays
private java.util.Random RNG
private long rngSeed
public static final java.lang.String[] monthString
private static final java.lang.String[] csvHeader
public ScenarioGenerator(Seed seed)
seed
- The Seed instance that will be used to generate scenarios.public static boolean validateSeedForReliabilityAnalysis(Seed seed)
seed
- Seed instance to check validity.public static int[] getSeedDataFormatErrorLocation(Seed seed)
seed
- Seed file to find any format errors any.public void setDemandDataGP(DemandData data)
data
- GP demand data information.public void setWorkZoneDataGP(java.util.ArrayList<WorkZone> data)
data
- ArrayList of GP Work Zones in the RRPpublic void setWeatherData(WeatherData data)
data
- Weather event generation information.public void setGPIncidentData(IncidentData data)
data
- GP Incident data information.public void setNumberOfReplications(int numReplications)
numReplications
- New number of replications for each Demand
Combination (must be greater than 0).public void setRNGSeed(long newSeed)
newSeed
- public void setMLUsed(boolean mlUsed)
mlUsed
- Boolean indicator of Managed Lane inclusion.public void setMLIncidentData(IncidentData incidentMLData)
incidentMLData
- Managed Lane segment incident information.public void setMLDemandData(DemandData demandMLData)
demandMLData
- Managed Lane segment demand information.public void includeGPWorkZones(boolean val)
val
- Boolean indicating the inclusion of work zone events in
reliability analysis.public void includeIncidentsGP(boolean val)
val
- Boolean indicating the inclusion of incident events in
reliability analysis.public void includeWeather(boolean val)
val
- Boolean indicating the inclusion of weather events in
reliability analysis.public void includeIncidentsML(boolean val)
val
- Boolean indicating the inclusion of ML incident events in
reliability analysis.public Scenario getGPScenario()
public Scenario getMLScenario()
public java.util.ArrayList<ScenarioInfo> getScenarioInfoList()
public int getNumberOfReplications()
public long getRNGSeed()
public void excludeDaysInMonth(int[] numDays, int month)
numDays
- Array of length 7 containing the number of each day type
excluded (0 - Mon, 1 - Tue, 2 - Wed, 3- Thu, 4 - Fri, 5 - Sat, 6 - Sun).month
- Month in which the days excluded occur (1- Jan, 2 - Feb,
etc.)private void excludeDays(int[] daysArr)
daysArr
- 84 length array of active dayspublic boolean generateScenarios()
private void assignWorkZones()
private void createAndAssignWeatherEvents(int[] monthChangeIdx)
monthChangeIdx
- List of indexes where each month ends (created
automatically in the generateScenarios method)private int[][] computeExpFreqOfWeatherEvents(int[] monthChangeIdx)
monthChangeIdx
- Array containing the final group number of
scenarios in each month. monthChangeIdx[0] should be the group number of
the final set of scenarios in January.private void assignCurrMonthWeatherEvents(int[] expMonthFreqWT, float[] currMonthScenCumProb, int prevScenarioInfoMarker)
expMonthFreqWT
- expected frequency of each weather type in each
monthcurrMonthScenCumProb
- float[] holding the cumulative sum array of
scenario probabilities for the current month.prevScenarioInfoMarker
- Marker for iterating through the
scenarioInfosprivate int[][] createAndAssignListIncidentEventsGP(int[] monthChangeIdx)
monthChangeIdx
- Indices at which the scenarios change month, i.e.
the value of monthChangeIdx[0] is the index of the first scenario of
February.private int[][] createAndAssignListIncidentEventsML(int[] monthChangeIdx)
monthChangeIdx
- Indices at which the scenarios change month, i.e.
the value of monthChangeIdx[0] is the index of the first scenario of
February.private boolean allInputValid()
private int calculateNumberOfScenarios(int[] numDayOfWeekInMonthAP)
numDayOfWeekInMonthAP
- Array with the number of each day type of
each month active in the Reliability Reporting Period (automatically
generated during the scenario generation process.private float[] createProbabilities(DemandData demandData)
demandData
- Instance of DemandData for the Reliability Reporting
Period.private int arraySum(int[] arr)
arr
- Array to sum.private int arraySum(int[][] arr)
arr
- Array of arrays to sum.private int arraySum(java.util.ArrayList<java.lang.Integer> arr)
arr
- ArrayList to sum.private float arraySum(float[] arr)
arr
- Array to sum.private int arraySum(boolean[] arr)
arr
- Array to sum.private int getColMax(int[][] arr, int col)
arr
- Matrix to extract the column sum from.col
- Column to sum.private int argMax(int[] arr)
arr
- Array of integersprivate float[] cumSumNormalize(float[] arr)
arr
- Array of floatsprivate long factorial(int value)
value
- Non-negative integerprivate java.util.ArrayList<java.lang.Integer> createIntegerArrAscending(int length)
length
- Desired length of the ascending value array.private java.util.ArrayList<java.lang.Integer> createIntegerArrDist(int[] distArr)
distArr
- Distribution the values of the returned ArrayList will
match.private float[][] generateLogNormalDurationProbabilites(int[] numIncOfEachType)
numIncOfEachType
- Number of each type of incident.private float generateLogNormalProbability(float value, float mean, float stdev)
value
- Value at which to find the value of the Log-Normal PDFmean
- Mean of the Log-Normal distribution.stdev
- Standard Deviation of the Log-Normal.private float logNormCDF(float value1, float value2, float step, float mu, float sigma)
value1
- Lower bound valuevalue2
- Upper bound valuestep
- Step-size for calculating the integral of the underlying PDF
(should be small)mu
- Log-scale/Location parametersigma
- Shape parameter.private float[][] getHCDurProbs()
private int[][] getNumScenAssignedDurationLength(int[] numIncOfEachType)
numIncOfEachType
- private void resetRNG()
private void resetRNG(long factor)
factor
- Integer by which the RNG seed is multiplied.public static void exportRawRLResults(Seed seed)