Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ src/main/python/reporting/abm_reports*/*
**/bin/**/*
*.user
*.pyc
*.hubstorinfo
27 changes: 17 additions & 10 deletions src/main/java/org/sandag/abm/airport/AirportDestChoiceModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class AirportDestChoiceModel
{

private double[][] sizeTerms; // by
// segment,
// tazNumber
Expand Down Expand Up @@ -390,7 +390,7 @@ public void calculateTazProbabilities(AirportDmuFactoryIf dmuFactory)
* Random number
* @return The chosen MGRA number
*/
public int chooseMGRA(int purpose, int income, double randomNumber)
public int chooseMGRA(int purpose, int income, AirportParty party)
{

// first find a TAZ
Expand All @@ -399,9 +399,10 @@ public int chooseMGRA(int purpose, int income, double randomNumber)
double[] tazCumProb = tazProbabilities[segment];
double altProb = 0;
double cumProb = 0;
double random = party.getRandom();
for (int i = 0; i < tazCumProb.length; ++i)
{
if (tazCumProb[i] > randomNumber)
if (tazCumProb[i] > random)
{
alt = i;
if (i != 0)
Expand All @@ -427,14 +428,18 @@ public int chooseMGRA(int purpose, int income, double randomNumber)
// mgra probabilities need to be scaled by the alternatives probability
int mgraNumber = 0;
double[] mgraCumProb = mgraProbabilities[segment][tazNumber];
random = party.getRandom(); // get a new random number for mgra, instead of using the same one from taz
for (int i = 0; i < mgraCumProb.length; ++i)
{
cumProb += mgraCumProb[i] * altProb;
if (cumProb > randomNumber)
// cumProb += mgraCumProb[i] * altProb;
cumProb = mgraCumProb[i];
if (cumProb > random)
{
mgraNumber = mgraArray[i];
break;
}
}

// return the chosen MGRA number
return mgraNumber;
}
Expand All @@ -448,17 +453,19 @@ public int chooseMGRA(int purpose, int income, double randomNumber)
*/
public void chooseOrigins(AirportParty[] airportParties)
{

// iterate through the array, choosing mgras and setting them
// iterate through the array, choosing mgras and setting them
for (AirportParty party : airportParties)
{

int income = party.getIncome();
int purpose = party.getPurpose();
double random = party.getRandom();
int mgra = -99;
if (purpose == AirportModelStructure.EMPLOYEE)
{
continue;
}
if (purpose < AirportModelStructure.INTERNAL_PURPOSES)
mgra = chooseMGRA(purpose, income, random);
mgra = chooseMGRA(purpose, income, party);

// if this is a departing travel party, the origin is the chosen
// mgra, and the destination is the airport terminal
Expand Down
Loading