Skip to content

Commit e3a07fc

Browse files
authoredJan 23, 2021
Merge branch 'develop' into azure_dvrpc
2 parents b871843 + f9b46b7 commit e3a07fc

File tree

13 files changed

+129
-28
lines changed

13 files changed

+129
-28
lines changed
 

‎DaySim.Customizations/BKR/ChoiceModels/Default/Models/BKR_OtherTourDestinationModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace DaySim.ChoiceModels.Default.Models {
66
class BKR_OtherTourDestinationModel : OtherTourDestinationModel {
77

8-
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel) {
8+
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel, IPersonWrapper person) {
99

1010
//add any region-specific new terms in region-specific class, using coefficient numbers 114-120, or other unused variable #
1111
//Global.PrintFile.WriteLine("PSRC_OtherTourDestinationModel.RegionSpecificOtherTourDistrictCoefficients called");

‎DaySim.Customizations/DVRPC/ChoiceModels/Default/Models/DVRPC_OtherTourDestinationModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace DaySim.ChoiceModels.Default.Models {
88
internal class DVRPC_OtherTourDestinationModel : OtherTourDestinationModel {
99

10-
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel) {
10+
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel, IPersonWrapper person) {
1111

1212

1313
//areas

‎DaySim.Customizations/Fresno/ChoiceModels/Default/Models/Fresno_OtherTourDestinationModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace DaySim.ChoiceModels.Default.Models {
66
internal class Fresno_OtherTourDestinationModel : OtherTourDestinationModel {
77

8-
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel) {
8+
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel, IPersonWrapper person) {
99

1010

1111
//add any region-specific new terms in region-specific class, using coefficient numbers 114-120, or other unused variable #

‎DaySim.Customizations/JAX/ChoiceModels/Default/Models/JAX_OtherTourDestinationModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace DaySim.ChoiceModels.Default.Models {
77
internal class JAX_OtherTourDestinationModel : OtherTourDestinationModel {
88

9-
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel) {
9+
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel, IPersonWrapper person) {
1010

1111

1212
//add any region-specific new terms in region-specific class, using coefficient numbers 114-120, or other unused variable #

‎DaySim.Customizations/PSRC/ChoiceModels/Default/Models/PSRC_OtherHomeBasedTourModeModel.cs

+25-4
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,39 @@
22
using DaySim.Framework.Core;
33
using DaySim.Framework.DomainModels.Wrappers;
44

5-
namespace DaySim.ChoiceModels.Default.Models {
6-
internal class PSRC_OtherHomeBasedTourModeModel : OtherHomeBasedTourModeModel {
7-
protected override void RegionSpecificCustomizations(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper tour, int pathType, int mode, IParcelWrapper destinationParcel) {
5+
namespace DaySim.ChoiceModels.Default.Models
6+
{
7+
internal class PSRC_OtherHomeBasedTourModeModel : OtherHomeBasedTourModeModel
8+
{
9+
protected override void RegionSpecificCustomizations(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper tour, int pathType, int mode, IParcelWrapper destinationParcel)
10+
{
811

912
//Global.PrintFile.WriteLine("Default PSRC_OtherHomeBasedTourModeModel.RegionSpecificCustomizations2 called");
1013

11-
if (mode == Global.Settings.Modes.Transit && pathType != Global.Settings.PathTypes.LightRail && pathType != Global.Settings.PathTypes.CommuterRail && pathType != Global.Settings.PathTypes.Ferry) {
14+
if (mode == Global.Settings.Modes.Transit && pathType != Global.Settings.PathTypes.LightRail && pathType != Global.Settings.PathTypes.CommuterRail && pathType != Global.Settings.PathTypes.Ferry)
15+
{
1216

1317
alternative.AddUtilityTerm(200 + tour.OriginParcel.District, 1);//district specific transit calibration constant
1418
alternative.AddUtilityTerm(300 + destinationParcel.District, 1);//district specific transit calibration constant
1519
}
1620

21+
if (mode == Global.Settings.Modes.ParkAndRide)
22+
{
23+
alternative.AddUtilityTerm(250, pathType == 3 ? 1 : 0);
24+
alternative.AddUtilityTerm(251, pathType == 4 ? 1 : 0);
25+
alternative.AddUtilityTerm(252, pathType == 5 ? 1 : 0);
26+
alternative.AddUtilityTerm(253, pathType == 6 ? 1 : 0);
27+
alternative.AddUtilityTerm(254, pathType == 7 ? 1 : 0);
28+
29+
}
30+
else if (mode == Global.Settings.Modes.Transit)
31+
{
32+
alternative.AddUtilityTerm(255, pathType == 3 ? 1 : 0);
33+
alternative.AddUtilityTerm(256, pathType == 4 ? 1 : 0);
34+
alternative.AddUtilityTerm(257, pathType == 5 ? 1 : 0);
35+
alternative.AddUtilityTerm(258, pathType == 6 ? 1 : 0);
36+
alternative.AddUtilityTerm(259, pathType == 7 ? 1 : 0);
37+
}
1738

1839
}
1940
}

‎DaySim.Customizations/PSRC/ChoiceModels/Default/Models/PSRC_OtherTourDestinationModel.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using DaySim.Framework.ChoiceModels;
22
using DaySim.Framework.DomainModels.Wrappers;
3-
3+
using DaySim.DomainModels.Extensions;
4+
using DaySim.Framework.Core;
5+
using System;
46
namespace DaySim.ChoiceModels.Default.Models {
57
internal class PSRC_OtherTourDestinationModel : OtherTourDestinationModel {
68

7-
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel) {
9+
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel, IPersonWrapper person) {
810

911

1012
//add any region-specific new terms in region-specific class, using coefficient numbers 114-120, or other unused variable #
@@ -16,7 +18,9 @@ protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbab
1618
int origTacDestKit = origdist == 8 && destdist == 9 || destdist == 11 ? 1 : 0;
1719
int origKitDestNotKit = (origdist == 9 || origdist == 11) && (destdist != 9 && destdist != 11) ? 1 : 0;
1820
int origSTacWorkCBD = (origdist == 11 && destdist == 4) ? 1 : 0;
19-
21+
double distanceFromOrigin = _tour.OriginParcel.DistanceFromOrigin(destinationParcel, _tour.DestinationArrivalTime);
22+
double distanceFromOriginLog = Math.Log(1 + distanceFromOrigin);
23+
alternative.AddUtilityTerm(114, person.WorksAtHome().ToFlag() * distanceFromOriginLog);
2024
alternative.AddUtilityTerm(115, origEastDestCBD);
2125
alternative.AddUtilityTerm(116, origKitDestTRP);
2226
alternative.AddUtilityTerm(117, origTacDestKit);

‎DaySim.Customizations/PSRC/ChoiceModels/Default/Models/PSRC_SchoolTourModeModel.cs

+26-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,39 @@
22
using DaySim.Framework.Core;
33
using DaySim.Framework.DomainModels.Wrappers;
44

5-
namespace DaySim.ChoiceModels.Default.Models {
6-
internal class PSRC_SchoolTourModeModel : SchoolTourModeModel {
7-
protected override void RegionSpecificCustomizations(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper tour, int pathType, int mode, IParcelWrapper destinationParcel) {
5+
namespace DaySim.ChoiceModels.Default.Models
6+
{
7+
internal class PSRC_SchoolTourModeModel : SchoolTourModeModel
8+
{
9+
protected override void RegionSpecificCustomizations(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper tour, int pathType, int mode, IParcelWrapper destinationParcel)
10+
{
811
//Global.PrintFile.WriteLine("Default PSRC_SchoolTourModeModel.RegionSpecificCustomizations called");
912

10-
if (mode == Global.Settings.Modes.Transit && pathType != Global.Settings.PathTypes.LightRail && pathType != Global.Settings.PathTypes.CommuterRail && pathType != Global.Settings.PathTypes.Ferry) {
13+
if (mode == Global.Settings.Modes.Transit && pathType != Global.Settings.PathTypes.LightRail && pathType != Global.Settings.PathTypes.CommuterRail && pathType != Global.Settings.PathTypes.Ferry)
14+
{
1115

1216
alternative.AddUtilityTerm(200 + tour.OriginParcel.District, 1);//district specific transit calibration constant
1317
alternative.AddUtilityTerm(300 + destinationParcel.District, 1);//district specific transit calibration constant
1418
}
1519

20+
if (mode == Global.Settings.Modes.ParkAndRide)
21+
{
22+
alternative.AddUtilityTerm(250, pathType == 3 ? 1 : 0);
23+
alternative.AddUtilityTerm(251, pathType == 4 ? 1 : 0);
24+
alternative.AddUtilityTerm(252, pathType == 5 ? 1 : 0);
25+
alternative.AddUtilityTerm(253, pathType == 6 ? 1 : 0);
26+
alternative.AddUtilityTerm(254, pathType == 7 ? 1 : 0);
27+
28+
}
29+
else if (mode == Global.Settings.Modes.Transit)
30+
{
31+
alternative.AddUtilityTerm(255, pathType == 3 ? 1 : 0);
32+
alternative.AddUtilityTerm(256, pathType == 4 ? 1 : 0);
33+
alternative.AddUtilityTerm(257, pathType == 5 ? 1 : 0);
34+
alternative.AddUtilityTerm(258, pathType == 6 ? 1 : 0);
35+
alternative.AddUtilityTerm(259, pathType == 7 ? 1 : 0);
36+
}
37+
1638

1739
}
1840
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using DaySim.Framework.ChoiceModels;
2+
using DaySim.Framework.DomainModels.Wrappers;
3+
using DaySim.DomainModels.Extensions;
4+
using DaySim.Framework.Core;
5+
using System;
6+
namespace DaySim.ChoiceModels.Default.Models
7+
{
8+
internal class PSRC_WorkTourDestinationModel : WorkTourDestinationModel
9+
{
10+
11+
protected override void RegionSpecificWorkTourCustomCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel, IPersonWrapper person)
12+
{
13+
14+
15+
//add any region-specific new terms in region-specific class, using coefficient numbers 114-120, or other unused variable #
16+
//Global.PrintFile.WriteLine("PSRC_OtherTourDestinationModel.RegionSpecificOtherTourDistrictCoefficients called");
17+
double distanceFromOrigin = _tour.OriginParcel.DistanceFromOrigin(destinationParcel, _tour.DestinationArrivalTime);
18+
double distanceFromOriginLog = Math.Log(1 + distanceFromOrigin);
19+
alternative.AddUtilityTerm(100, person.WorksAtHome().ToFlag() * distanceFromOriginLog);
20+
21+
}
22+
}
23+
}

‎DaySim.Customizations/PSRC/ChoiceModels/Default/Models/PSRC_WorkTourModeModel.cs

+26-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,39 @@
22
using DaySim.Framework.Core;
33
using DaySim.Framework.DomainModels.Wrappers;
44

5-
namespace DaySim.ChoiceModels.Default.Models {
6-
internal class PSRC_WorkTourModeModel : WorkTourModeModel {
7-
protected override void RegionSpecificCustomizations(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper tour, int pathType, int mode, IParcelWrapper destinationParcel) {
5+
namespace DaySim.ChoiceModels.Default.Models
6+
{
7+
internal class PSRC_WorkTourModeModel : WorkTourModeModel
8+
{
9+
protected override void RegionSpecificCustomizations(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper tour, int pathType, int mode, IParcelWrapper destinationParcel)
10+
{
811
//Global.PrintFile.WriteLine("Default PSRC_WorkTourModeModel.RegionSpecificCustomizations called");
912

10-
if (mode == Global.Settings.Modes.Transit && pathType != Global.Settings.PathTypes.LightRail && pathType != Global.Settings.PathTypes.CommuterRail && pathType != Global.Settings.PathTypes.Ferry) {
13+
if (mode == Global.Settings.Modes.Transit && pathType != Global.Settings.PathTypes.LightRail && pathType != Global.Settings.PathTypes.CommuterRail && pathType != Global.Settings.PathTypes.Ferry)
14+
{
1115

1216
alternative.AddUtilityTerm(200 + tour.OriginParcel.District, 1);//district specific transit calibration constant
1317
alternative.AddUtilityTerm(300 + destinationParcel.District, 1);//district specific transit calibration constant
1418
}
1519

20+
if (mode == Global.Settings.Modes.ParkAndRide)
21+
{
22+
alternative.AddUtilityTerm(250, pathType == 3 ? 1 : 0);
23+
alternative.AddUtilityTerm(251, pathType == 4 ? 1 : 0);
24+
alternative.AddUtilityTerm(252, pathType == 5 ? 1 : 0);
25+
alternative.AddUtilityTerm(253, pathType == 6 ? 1 : 0);
26+
alternative.AddUtilityTerm(254, pathType == 7 ? 1 : 0);
27+
28+
}
29+
30+
else if (mode == Global.Settings.Modes.Transit)
31+
{
32+
alternative.AddUtilityTerm(255, pathType == 3 ? 1 : 0);
33+
alternative.AddUtilityTerm(256, pathType == 4 ? 1 : 0);
34+
alternative.AddUtilityTerm(257, pathType == 5 ? 1 : 0);
35+
alternative.AddUtilityTerm(258, pathType == 6 ? 1 : 0);
36+
alternative.AddUtilityTerm(259, pathType == 7 ? 1 : 0);
37+
}
1638

1739
}
1840
}

‎DaySim.Customizations/SFCTA/ChoiceModels/Default/Models/SFCTA_OtherTourDestinationModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace DaySim.ChoiceModels.Default.Models {
55
internal class SFCTA_OtherTourDestinationModel : OtherTourDestinationModel {
66

7-
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel) {
7+
protected override void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper _tour, IParcelWrapper destinationParcel, IPersonWrapper person) {
88

99

1010
//add any region-specific new terms in region-specific class, using coefficient numbers 114-120, or other unused variable #

‎DaySim/ChoiceModels/Default/Models/OtherTourDestinationModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public override void RunInitialize(ICoefficientsReader reader = null) {
3232
Initialize(CHOICE_MODEL_NAME, Global.Configuration.OtherTourDestinationModelCoefficients, sampleSize + 1, TOTAL_NESTED_ALTERNATIVES, TOTAL_LEVELS, MAX_PARAMETER);
3333
}
3434

35-
protected virtual void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper tour, IParcelWrapper destinationParcel) {
35+
protected virtual void RegionSpecificOtherTourDistrictCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper tour, IParcelWrapper destinationParcel, IPersonWrapper person) {
3636
//see PSRC_OtherTourDestinationModel for example
3737
//Global.PrintFile.WriteLine("Generic OtherTourDestinationModel.RegionSpecificOtherTourDistrictCoefficients being called so must not be overridden by CustomizationDll");
3838
}
@@ -382,7 +382,7 @@ public void SetUtilities(ISampleItem sampleItem, int sampleFrequency) {
382382
}
383383

384384
//add any region-specific new terms in region-specific class, using coefficient numbers 114-120, or other unused variable #
385-
_parentClass.RegionSpecificOtherTourDistrictCoefficients(alternative, _tour, destinationParcel);
385+
_parentClass.RegionSpecificOtherTourDistrictCoefficients(alternative, _tour, destinationParcel, person);
386386

387387
// OD shadow pricing
388388
if (Global.Configuration.ShouldUseODShadowPricing) {

‎DaySim/ChoiceModels/Default/Models/SchoolTourModeModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class SchoolTourModeModel : ChoiceModel {
2323
public const string CHOICE_MODEL_NAME = "SchoolTourModeModel";
2424
private const int TOTAL_NESTED_ALTERNATIVES = 6;
2525
private const int TOTAL_LEVELS = 2;
26-
private const int MAX_PARAMETER = 199;
26+
private const int MAX_PARAMETER = 299;
2727
private const int THETA_PARAMETER = 99;
2828

2929
private readonly int[] _nestedAlternativeIds = new[] { 0, 19, 19, 20, 21, 21, 22, 22, 23, 24 };

‎DaySim/ChoiceModels/Default/Models/WorkTourDestinationModel.cs

+14-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public override void RunInitialize(ICoefficientsReader reader = null) {
3232
Initialize(CHOICE_MODEL_NAME, Global.Configuration.WorkTourDestinationModelCoefficients, sampleSize + 1, TOTAL_NESTED_ALTERNATIVES, TOTAL_LEVELS, MAX_PARAMETER);
3333
}
3434

35+
protected virtual void RegionSpecificWorkTourCustomCoefficients(ChoiceProbabilityCalculator.Alternative alternative, ITourWrapper tour, IParcelWrapper destinationParcel, IPersonWrapper person)
36+
{
37+
//see PSRC_OtherTourDestinationModel for example
38+
//Global.PrintFile.WriteLine("Generic OtherTourDestinationModel.RegionSpecificOtherTourDistrictCoefficients being called so must not be overridden by CustomizationDll");
39+
}
40+
3541
public void Run(ITourWrapper tour, int sampleSize) {
3642
if (tour == null) {
3743
throw new ArgumentNullException("tour");
@@ -113,12 +119,13 @@ private void RunModel(ChoiceProbabilityCalculator choiceProbabilityCalculator, I
113119
int segment = Global.ContainerDaySim.GetInstance<SamplingWeightsSettingsFactory>().SamplingWeightsSettings.GetTourDestinationSegment(tour.DestinationPurpose, tour.IsHomeBasedTour ? Global.Settings.TourPriorities.HomeBasedTour : Global.Settings.TourPriorities.WorkBasedTour, Global.Settings.Modes.Sov, person.PersonType);
114120
IParcelWrapper excludedParcel = person.UsualWorkParcel == null || person.UsualWorkParcelId == household.ResidenceParcelId || tour.DestinationPurpose != Global.Settings.Purposes.Work || tour.GetTourCategory() == Global.Settings.TourCategories.WorkBased ? null : person.UsualWorkParcel;
115121
DestinationSampler destinationSampler = new DestinationSampler(choiceProbabilityCalculator, segment, sampleSize, choice, tour.OriginParcel, excludedParcel, excludedParcel);
116-
TourDestinationUtilities tourDestinationUtilities = new TourDestinationUtilities(tour, sampleSize, primaryFlag, secondaryFlag, fastestAvailableTimeOfDay, maxAvailableMinutes);
122+
TourDestinationUtilities tourDestinationUtilities = new TourDestinationUtilities(this, tour, sampleSize, primaryFlag, secondaryFlag, fastestAvailableTimeOfDay, maxAvailableMinutes);
117123

118124
destinationSampler.SampleTourDestinations(tourDestinationUtilities);
119125
}
120126

121127
private sealed class TourDestinationUtilities : ISamplingUtilities {
128+
private readonly WorkTourDestinationModel _parentClass;
122129
private readonly ITourWrapper _tour;
123130
private readonly int _sampleSize;
124131
private readonly int _primaryFlag;
@@ -127,7 +134,8 @@ private sealed class TourDestinationUtilities : ISamplingUtilities {
127134
private readonly int _maxAvailableMinutes;
128135
private readonly int[] _seedValues;
129136

130-
public TourDestinationUtilities(ITourWrapper tour, int sampleSize, int primaryFlag, int secondaryFlag, int fastestAvailableTimeOfDay, int maxAvailableMinutes) {
137+
public TourDestinationUtilities(WorkTourDestinationModel parentClass, ITourWrapper tour, int sampleSize, int primaryFlag, int secondaryFlag, int fastestAvailableTimeOfDay, int maxAvailableMinutes) {
138+
_parentClass = parentClass;
131139
_tour = tour;
132140
_sampleSize = sampleSize;
133141
_primaryFlag = primaryFlag;
@@ -292,8 +300,9 @@ public void SetUtilities(ISampleItem sampleItem, int sampleFrequency) {
292300
alternative.AddUtilityTerm(47, (!usualWorkParcel).ToFlag() * destinationParcel.EmploymentIndustrial + destinationParcel.EmploymentAgricultureConstruction);
293301
alternative.AddUtilityTerm(48, (!usualWorkParcel).ToFlag() * destinationParcel.Households);
294302
alternative.AddUtilityTerm(49, (!usualWorkParcel).ToFlag() * destinationParcel.StudentsUniversity);
295-
296-
303+
304+
_parentClass.RegionSpecificWorkTourCustomCoefficients(alternative, _tour, destinationParcel, person);
305+
297306
// OD shadow pricing
298307
if (!usualWorkParcel && Global.Configuration.ShouldUseODShadowPricing) {
299308
int ori = _tour.OriginParcel.District;
@@ -379,4 +388,4 @@ public static bool ShouldRunInEstimationModeForModel(ITourWrapper tour) {
379388
}
380389
}
381390
}
382-
}
391+
}

0 commit comments

Comments
 (0)
Please sign in to comment.