示例#1
0
 public bool RuntimeValidation(ref string error)
 {
     AssignRequiredVehicle();
     if (RequiresVehicle == null)
     {
         error = $"In {Name} we were unable to find a vehicle type with the name {VehicleTypeName}!";
         return(false);
     }
     foreach (var network in Root.NetworkData)
     {
         if (network.NetworkType == AutoNetworkName)
         {
             AutoNetwork = network;
         }
         else if (network.NetworkType == TransitNetworkName)
         {
             TransitNetwork = network as ITripComponentData;
         }
     }
     if (AutoNetwork == null)
     {
         error = "In '" + Name + "' we were unable to find an auto network called '" + AutoNetworkName + "'";
         return(false);
     }
     if (TransitNetwork == null)
     {
         error = "In '" + Name + "' we were unable to find a transit network called '" + TransitNetworkName + "'";
         return(false);
     }
     return(true);
 }
 public bool RuntimeValidation(ref string error)
 {
     //search through the networks and load in the data based on their names
     foreach (var network in Root.NetworkData)
     {
         if (network.NetworkType == TransitNetworkString)
         {
             TransitNetwork = network as ITripComponentData;
         }
         if (network.NetworkType == AutoNetworkString)
         {
             AutoNetwork = network;
         }
     }
     // check to make sure that both networks were loaded in, if not report an error
     if (AutoNetwork == null)
     {
         error = "In '" + Name + "' a auto network named '" + AutoNetworkString + "' could not be found.";
         return(false);
     }
     if (TransitNetwork == null)
     {
         error = "In '" + Name + "' a transit network named '" + TransitNetworkString + "' could not be found.";
         return(false);
     }
     return(true);
 }
示例#3
0
        public bool RuntimeValidation(ref string error)
        {
            if (String.IsNullOrWhiteSpace(this.ModeName))
            {
                error = "All modes require a mode name!";
                return(false);
            }
            bool found = false;
            IList <INetworkData> networks;

            networks = this.Root.NetworkData;
            foreach (var network in networks)
            {
                if (network.NetworkType == this.NetworkType)
                {
                    this.TransitData = network as ITripComponentData;
                    if (this.TransitData == null)
                    {
                        error = "The network data \"" + this.NetworkType + "\" does not support the ITransitNetworkData interface.  Please use a module that supports this!";
                        return(false);
                    }
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                error = "We were unable to find the network data with the name \"" + this.NetworkType + "\" in this Model System!";
                return(false);
            }
            return(true);
        }
示例#4
0
        public bool RuntimeValidation(ref string error)
        {
            foreach (var network in this.Root.NetworkData)
            {
                if (network.Name == this.AccessModeName)
                {
                    this.First = network;
                }

                if (network.Name == this.PrimaryModeName)
                {
                    var temp = network as ITripComponentData;
                    this.Second = temp == null ? this.Second : temp;
                }
            }
            if (this.First == null)
            {
                error = "In '" + this.Name + "' the name of the access network data type was not found!";
                return(false);
            }
            else if (this.Second == null)
            {
                error = "In '" + this.Name + "' the name of the primary network data type was not found or does not contain trip component data!";
                return(false);
            }
            return(true);
        }
示例#5
0
 public bool RuntimeValidation(ref string error)
 {
     foreach (var network in Root.NetworkData)
     {
         if (network.NetworkType == AutoNetworkName)
         {
             AutoNetwork = network;
         }
         else if (network.NetworkType == TransitNetworkName)
         {
             TransitNetwork = network as ITripComponentData;
         }
     }
     if (AutoNetwork == null)
     {
         error = "In '" + Name + "' we were unable to find an auto network called '" + AutoNetworkName + "'";
         return(false);
     }
     if (TransitNetwork == null)
     {
         error = "In '" + Name + "' we were unable to find a transit network called '" + TransitNetworkName + "'";
         return(false);
     }
     return(true);
 }
示例#6
0
        public bool RuntimeValidation(ref string error)
        {
            if (String.IsNullOrWhiteSpace(this.ModeName))
            {
                error = "In module '" + this.Name + "', please add in a 'Mode Name' for your nested choice!";
                return(false);
            }
            if (this.Correlation > 1 || this.Correlation < 0)
            {
                error = "Correlation must be between 0 and 1 for " + this.ModeName + "!";
                return(false);
            }
            if (MaxAccessStations <= 0)
            {
                error = "The number of feasible access stations must be greater than 0!";
                return(false);
            }
            foreach (var network in this.Root.NetworkData)
            {
                if (network.NetworkType == this.AccessModeName)
                {
                    this.First = network;
                }

                if (network.NetworkType == this.PrimaryModeName)
                {
                    var temp = network as ITripComponentData;
                    this.Second = temp == null ? this.Second : temp;
                }

                if (network.NetworkType == this.EgressNetworkName)
                {
                    var temp = network as ITripComponentData;
                    this.Third = temp == null ? this.Third : temp;
                }

                if (network.NetworkType == this.AlternativePrimaryModeName)
                {
                    this.FirstAlternative = network;
                }
            }
            if (this.First == null)
            {
                error = "In '" + this.Name + "' the name of the access network data type was not found!";
                return(false);
            }
            else if (this.Second == null)
            {
                error = "In '" + this.Name + "' the name of the primary network data type was not found or does not contain trip component data!";
                return(false);
            }
            else if (this.Third == null && this.ComputeEgressStation)
            {
                error = "In '" + this.Name + "' the name of the egress network data type was not found or does not contain trip component data!";
                return(false);
            }
            return(true);
        }
示例#7
0
            private void CalculateUtilities(RangeSet stationRanges, RangeSet spatialZones, float[] capacity, int[] closestStation)
            {
                INetworkData       autoNetwork    = GetNetwork(AutoNetworkName);
                ITripComponentData transitNetwork = GetNetwork(TransitNetworkName) as ITripComponentData;

                EnsureNetworks(autoNetwork, transitNetwork);
                var zoneArray = Root.ZoneSystem.ZoneArray;

                IZone[] zones              = zoneArray.GetFlatData();
                int[]   stationZones       = GetStationZones(stationRanges, capacity, zones);
                var     flatCapacityFactor = CapacityFactor.GetFlatData();

                if (AutoFromOriginToAccessStation == null || TransitFromAccessStationToDestination.Length != stationZones.Length * zones.Length)
                {
                    TransitFromAccessStationToDestination = new float[stationZones.Length * zones.Length];
                    AutoFromOriginToAccessStation         = new float[stationZones.Length * zones.Length];
                    TransitFromDestinationToAccessStation = new float[stationZones.Length * zones.Length];
                    AutoFromAccessStationToDestination    = new float[stationZones.Length * zones.Length];
                }
                // compute the toAccess utilities
                Parallel.For(0, zones.Length, (int originIndex) =>
                {
                    var zoneNumber = zones[originIndex].ZoneNumber;
                    if (spatialZones.Contains(zoneNumber))
                    {
                        for (int i = 0; i < stationZones.Length; i++)
                        {
                            var accessIndex = stationZones[i];
                            var factor      = (float)Math.Pow(flatCapacityFactor[accessIndex], CapacityFactorExp);
                            // calculate access' to access station this will include more factors
                            AutoFromOriginToAccessStation[originIndex * stationZones.Length + i] = (float)Math.Exp(ComputeUtility(autoNetwork, originIndex, accessIndex)
                                                                                                                   + (Capacity * capacity[accessIndex]
                                                                                                                      + ParkingCost * zones[accessIndex].ParkingCost
                                                                                                                      + (closestStation[originIndex] == accessIndex ? ClosestStationFactor : 0))) * factor;
                            // calculate egress' from access station
                            AutoFromAccessStationToDestination[originIndex * stationZones.Length + i] = (float)Math.Exp(ComputeUtility(autoNetwork, accessIndex, originIndex)) * factor;
                        }
                    }
                });

                // compute the toDesinstination utilities
                Parallel.For(0, zones.Length, (int destIndex) =>
                {
                    var zoneNumber = zones[destIndex].ZoneNumber;
                    if (spatialZones.Contains(zoneNumber))
                    {
                        for (int i = 0; i < stationZones.Length; i++)
                        {
                            var accessIndex = stationZones[i];
                            var factor      = (float)Math.Pow(flatCapacityFactor[accessIndex], CapacityFactorExp);
                            // calculate access' to destination
                            TransitFromAccessStationToDestination[destIndex * stationZones.Length + i] = (float)Math.Exp(ComputeUtility(transitNetwork, accessIndex, destIndex)) * factor;
                            // calculate egress' to access station
                            TransitFromDestinationToAccessStation[destIndex * stationZones.Length + i] = (float)Math.Exp(ComputeUtility(transitNetwork, destIndex, accessIndex)) * factor;
                        }
                    }
                });
            }
 private static float ComputeV(ITripComponentData data, int egress, int destination, Time time, float ivttWeight, float walkWeight, float waitWeight, float boardingWeight, float costWeight)
 {
     data.GetAllData(egress, destination, time, out Time ivtt, out Time walk, out Time wait, out Time boarding, out float cost);
     return(ivttWeight * ivtt.ToMinutes()
            + walkWeight * walk.ToMinutes()
            + waitWeight * wait.ToMinutes()
            + boardingWeight * boarding.ToMinutes()
            + costWeight * cost);
 }
示例#9
0
 private static float ComputeSubV(ITripComponentData data, int flatOrigin, int flatDestination, Time t, float ivttWeight, float walkWeight, float waitWeight, float boardingWeight, float costWeight)
 {
     data.GetAllData(flatOrigin, flatDestination, t, out float ivtt, out float walk, out float wait, out float boarding, out float cost);
     return(ivttWeight * ivtt
            + walkWeight * walk
            + waitWeight * wait
            + boardingWeight * boarding
            + costWeight * cost);
 }
示例#10
0
 private float ComputeUtility(ITripComponentData transitNetwork, int originIndex, int destIndex)
 {
     if (transitNetwork.GetAllData(originIndex, destIndex, StartTime, out float trueTravelTime, out float walk, out float wait, out float perceivedTravelTime, out float cost) && (perceivedTravelTime > 0))
     {
         return(PerceivedTransitTime * perceivedTravelTime
                + TransitFare * cost);
     }
     return(float.NegativeInfinity);
 }
示例#11
0
 private void EnsureNetworks(INetworkData autoNetwork, ITripComponentData transitNetwork)
 {
     if (autoNetwork == null)
     {
         throw new XTMFRuntimeException("In '" + Name + "' we were unable to find an auto network named '" + AutoNetworkName + "'!");
     }
     if (transitNetwork == null)
     {
         throw new XTMFRuntimeException("In '" + Name + "' we were unable to find an transit network named '" + TransitNetworkName + "'!");
     }
 }
示例#12
0
 /// <summary>
 /// Find and Load in the network data
 /// </summary>
 private void LoadNetworkData()
 {
     foreach (var dataSource in Root.NetworkData)
     {
         if (dataSource is ITripComponentData ds && dataSource.NetworkType == NetworkType)
         {
             NetworkData = ds;
             return;
         }
     }
 }
示例#13
0
        private static float ComputeSubV(ITripComponentData data, int flatOrigin, int flatDestination, Time t, float ivttWeight, float walkWeight, float waitWeight, float costWeight)
        {
            Time  ivtt, walk, wait, boarding;
            float cost;

            data.GetAllData(flatOrigin, flatDestination, t, out ivtt, out walk, out wait, out boarding, out cost);
            return(ivttWeight * ivtt.ToMinutes()
                   + walkWeight * walk.ToMinutes()
                   + waitWeight * wait.ToMinutes()
                   + costWeight * cost);
        }
示例#14
0
 /// <summary>
 /// Find and Load in the network data
 /// </summary>
 private void LoadNetworkData()
 {
     foreach ( var dataSource in this.Root.NetworkData )
     {
         var ds = dataSource as ITripComponentData;
         if ( ds != null && dataSource.NetworkType == this.NetworkType )
         {
             this.NetworkData = ds;
             return;
         }
     }
 }
示例#15
0
 private float ComputeUtility(ITripComponentData transitNetwork, int originIndex, int destIndex)
 {
     if (transitNetwork.GetAllData(originIndex, destIndex, StartTime, out float ivtt, out float walk, out float wait, out float boardingPenalty, out float cost) && (boardingPenalty > 0))
     {
         return(TIVTT * ivtt
                + Boarding * boardingPenalty
                + TWALK * walk
                + TWAIT * wait
                + TransitFare * cost);
     }
     return(float.NegativeInfinity);
 }
示例#16
0
 private bool AssignNetwork(IList <INetworkData> networks)
 {
     foreach (var network in networks)
     {
         if (network.NetworkType == NetworkType)
         {
             Network = network as ITripComponentData;
             return(Network != null);
         }
     }
     return(false);
 }
示例#17
0
 /// <summary>
 /// Find and Load in the network data
 /// </summary>
 private void LoadNetworkData()
 {
     foreach (var dataSource in this.Root.NetworkData)
     {
         var ds = dataSource as ITripComponentData;
         if (ds != null && dataSource.NetworkType == this.NetworkType)
         {
             this.NetworkData = ds;
             return;
         }
     }
 }
示例#18
0
 private static bool ComputeThird(ITripComponentData data, int flatOrigin, int flatDestination, Time t, float walkTime, float waitTime, out float result)
 {
     data.GetAllData(flatOrigin, flatDestination, t, out float ivtt, out float walk, out float wait, out float boarding, out float cost);
     if (walk <= 0)
     {
         result = float.PositiveInfinity;
         return(false);
     }
     result = walk * walkTime
              + wait * waitTime
              + ivtt;
     return(true);
 }
 public bool RuntimeValidation(ref string error)
 {
     foreach (var network in Root.NetworkData)
     {
         if (network.NetworkType == AutoNetworkName)
         {
             _autoNetwork = network as INetworkData;
         }
         else if (network.NetworkType == TransitNetworkName)
         {
             _transitNetwork = network as ITripComponentData;
         }
     }
     if (_autoNetwork == null)
     {
         error = "In '" + Name + "' we were unable to find an auto network called '" + AutoNetworkName + "'";
         return(false);
     }
     if (_transitNetwork == null)
     {
         error = "In '" + Name + "' we were unable to find a transit network called '" + TransitNetworkName + "'";
         return(false);
     }
     foreach (var mode in Root.AllModes)
     {
         if (mode.ModeName == DATModeName)
         {
             _dat = mode;
             break;
         }
     }
     foreach (var mode in Root.AllModes)
     {
         if (mode.ModeName == PassengerModeName)
         {
             _passenger = mode;
             break;
         }
     }
     if (_dat == null)
     {
         error = "In '" + Name + "' we were unable to find a DAT mode called '" + DATModeName + "'";
         return(false);
     }
     if (_passenger == null)
     {
         error = "In '" + Name + "' we were unable to find a Passenger mode called '" + DATModeName + "'";
         return(false);
     }
     return(true);
 }
示例#20
0
        private void LoadInVehicleTimes(SparseTwinIndex <float> data, ITripComponentData network)
        {
            var flatData = data.GetFlatData();
            var time     = TimeToLoad;

            for (int i = 0; i < flatData.Length; i++)
            {
                var row = flatData[i];
                for (int j = 0; j < row.Length; j++)
                {
                    row[j] = network.InVehicleTravelTime(i, j, time).ToMinutes();
                }
            }
        }
示例#21
0
        private static bool ComputeThird(ITripComponentData data, int flatOrigin, int flatDestination, Time t, float walkTime, float waitTime, out float result)
        {
            data.GetAllData(flatOrigin, flatDestination, t, out Time ivtt, out Time walk, out Time wait, out Time boarding, out float cost);
            var timeWalkingInMinutes = walk.ToMinutes();

            if (timeWalkingInMinutes <= 0)
            {
                result = float.PositiveInfinity;
                return(false);
            }
            result = timeWalkingInMinutes * walkTime
                     + wait.ToMinutes() * waitTime
                     + ivtt.ToMinutes();
            return(true);
        }
示例#22
0
 /// <summary>
 /// Find and Load in the network data
 /// </summary>
 private void LoadNetworkData()
 {
     foreach (var dataSource in Root.NetworkData)
     {
         if (dataSource.NetworkType == NetworkType)
         {
             NetworkData = dataSource;
             if (dataSource is ITripComponentData advancedData)
             {
                 AdvancedNetworkData = advancedData;
             }
             break;
         }
     }
 }
示例#23
0
        public bool RuntimeValidation(ref string error)
        {
            if (String.IsNullOrWhiteSpace(ModeName))
            {
                error = "In module '" + Name + "', please add in a 'Mode Name' for your nested choice!";
                return(false);
            }
            if (Correlation > 1 || Correlation < 0)
            {
                error = "Correlation must be between 0 and 1 for " + ModeName + "!";
                return(false);
            }
            foreach (var network in Root.NetworkData)
            {
                if (network.NetworkType == AccessModeName)
                {
                    First = network;
                }

                if (network.NetworkType == PrimaryModeName)
                {
                    var temp = network as ITripComponentData;
                    Second = temp ?? Second;
                }

                if (network.NetworkType == EgressNetworkName)
                {
                    var temp = network as ITripComponentData;
                    Third = temp ?? Third;
                }
            }
            if (First == null)
            {
                error = "In '" + Name + "' the name of the access network data type was not found!";
                return(false);
            }
            if (Second == null)
            {
                error = "In '" + Name + "' the name of the primary network data type was not found or does not contain trip component data!";
                return(false);
            }
            if (Third == null && ComputeEgressStation)
            {
                error = "In '" + Name + "' the name of the egress network data type was not found or does not contain trip component data!";
                return(false);
            }
            return(true);
        }
示例#24
0
 /// <summary>
 /// Find and Load in the network data
 /// </summary>
 private void LoadNetworkData()
 {
     foreach (var dataSource in this.Root.NetworkData)
     {
         if (dataSource.NetworkType == this.NetworkType)
         {
             this.NetworkData = dataSource;
             ITripComponentData advancedData = dataSource as ITripComponentData;
             if (advancedData != null)
             {
                 this.AdvancedNetworkData = advancedData;
             }
             break;
         }
     }
 }
示例#25
0
        public bool RuntimeValidation(ref string error)
        {
            if (String.IsNullOrWhiteSpace(ModeName))
            {
                error = "In module '" + Name + "', please add in a 'Mode Name' for your nested choice!";
                return(false);
            }
            if (Correlation > 1 || Correlation < 0)
            {
                error = "Correlation must be between 0 and 1 for " + ModeName + "!";
                return(false);
            }
            if (MaxAccessStations <= 0)
            {
                error = "The number of feasible access stations must be greater than 0!";
                return(false);
            }
            foreach (var network in Root.NetworkData)
            {
                if (network.NetworkType == AccessModeName)
                {
                    First = network;
                }

                if (network.NetworkType == PrimaryModeName)
                {
                    var temp = network as ITripComponentData;
                    Second = temp == null ? Second : temp;
                }
            }
            if (First == null)
            {
                error = "In '" + Name + "' the name of the access network data type was not found!";
                return(false);
            }
            if (Second == null)
            {
                error = "In '" + Name + "' the name of the primary network data type was not found or does not contain trip component data!";
                return(false);
            }
            // If everything is fine we can now Generate our children
            if (!GenerateChildren())
            {
                return(false);
            }
            return(true);
        }
示例#26
0
        public bool RuntimeValidation(ref string error)
        {
            foreach (var network in this.Root.NetworkData)
            {
                if (network.NetworkType == Auto)
                {
                    this.AutoData = network;
                }

                else if (network.NetworkType == Transit)
                {
                    var temp = network as ITripComponentData;
                    this.TransitData = temp == null ? this.TransitData : temp;
                }
            }
            return(true);
        }
示例#27
0
文件: Transit.cs 项目: lunaxi7/XTMF
 /// <summary>
 /// This is called before the start method as a way to pre-check that all of the parameters that are selected
 /// are in fact valid for this module.
 /// </summary>
 /// <param name="error">A string that should be assigned a detailed error</param>
 /// <returns>If the validation was successful or if there was a problem</returns>
 public bool RuntimeValidation(ref string error)
 {
     Data = null;
     foreach (var network in TashaRuntime.NetworkData)
     {
         if (network.NetworkType == NetworkType && network is ITripComponentData)
         {
             Data = network as ITripComponentData;
         }
     }
     if (Data == null)
     {
         error = "We were unable to find a transit network with the name \"" + NetworkType + "\"!";
         return(false);
     }
     return(true);
 }
示例#28
0
 /// <summary>
 /// Find and Load in the network data
 /// </summary>
 private bool LoadNetworkData(ref string error)
 {
     foreach (var dataSource in Root.NetworkData)
     {
         if (dataSource.NetworkType == NetworkType)
         {
             if (dataSource is ITripComponentData advancedData)
             {
                 NetworkData = advancedData;
                 return(true);
             }
             error = "In '" + Name + "' the given network data '" + NetworkType + "' is not ITripComponentData compliant!";
             return(false);
         }
     }
     error = "In '" + Name + "' we were unable to find any network data with the name '" + NetworkType + "'!";
     return(false);
 }
示例#29
0
        private static bool ComputeThird(ITripComponentData data, int flatOrigin, int flatDestination, Time t, float WalkTime, float WaitTime, out float result)
        {
            Time  ivtt, walk, wait, boarding;
            float cost;

            data.GetAllData(flatOrigin, flatDestination, t, out ivtt, out walk, out wait, out boarding, out cost);
            var walkTime = walk.ToMinutes();

            if (walkTime <= 0)
            {
                result = float.PositiveInfinity;
                return(false);
            }
            result = walkTime * WalkTime
                     + wait.ToMinutes() * WaitTime
                     + ivtt.ToMinutes();
            return(true);
        }
示例#30
0
 public bool RuntimeValidation(ref string error)
 {
     // load auto network + transit network
     foreach (var network in Root.NetworkData)
     {
         var networkName = network.NetworkType;
         if (networkName == AutoNetworkName)
         {
             AutoNetwork = network;
         }
         if (networkName == TransitNetworkName)
         {
             TransitNetwork = network as ITripComponentData;
         }
     }
     if (AutoNetwork == null)
     {
         error = "In '" + Name + "' the auto network could not be found!";
         return(false);
     }
     if (TransitNetwork == null)
     {
         error = "In '" + Name + "' the transit network could not be found!";
         return(false);
     }
     // check resources for proper types
     if (!EmployedPopulationResidenceByZone.CheckResourceType <SparseArray <float> >())
     {
         error = "In '" + Name + "' the Employed Population Residence By Zone is not of type SparseArray<float>!";
         return(false);
     }
     if (!JobsByZone.CheckResourceType <SparseArray <float> >())
     {
         error = "In '" + Name + "' the Jobs By Zone is not of type SparseArray<float>!";
         return(false);
     }
     if (KFactors != null && !KFactors.CheckResourceType <SparseTwinIndex <float> >())
     {
         error = "In '" + Name + "' the KFactors are not of type SparseTwinIndex<float>!";
         return(false);
     }
     return(true);
 }
示例#31
0
        public bool RuntimeValidation(ref string error)
        {
            foreach (var network in Root.NetworkData)
            {
                if (network.Name == AccessModeName)
                {
                    First          = network;
                    FirstComponent = network as ITripComponentData;
                }

                if (network.Name == PrimaryModeName)
                {
                    var temp = network as ITripComponentData;
                    Second = temp ?? Second;
                }

                if (network.NetworkType == EgressNetworkName)
                {
                    var temp = network as ITripComponentData;
                    Third = temp ?? Third;
                }
            }
            if (First == null)
            {
                error = "In '" + Name + "' the name of the access network data type was not found!";
                return(false);
            }
            if (Second == null)
            {
                error = "In '" + Name + "' the name of the primary network data type was not found or does not contain trip component data!";
                return(false);
            }
            if (Third == null && ComputeEgressStation)
            {
                error = "In '" + Name + "' the name of the egress network data type was not found or does not contain trip component data!";
                return(false);
            }
            return(true);
        }
示例#32
0
 private static float ComputeSubV(ITripComponentData data, int flatOrigin, int flatDestination, Time t, float ivttWeight, float walkWeight, float waitWeight, float boardingWeight, float costWeight)
 {
     float ivtt, walk, wait, boarding;
     float cost;
     data.GetAllData( flatOrigin, flatDestination, t, out ivtt, out walk, out wait, out boarding, out cost );
     return ivttWeight * ivtt
         + walkWeight * walk
         + waitWeight * wait
         + boardingWeight * boarding
         + costWeight * cost;
 }
示例#33
0
        public bool RuntimeValidation(ref string error)
        {
            foreach ( var network in this.Root.NetworkData )
            {
                if ( network.Name == this.AccessModeName )
                {
                    this.First = network;
                }

                if ( network.Name == this.PrimaryModeName )
                {
                    var temp = network as ITripComponentData;
                    this.Second = temp == null ? this.Second : temp;
                }

                if ( network.NetworkType == this.EgressNetworkName )
                {
                    var temp = network as ITripComponentData;
                    this.Third = temp == null ? this.Third : temp;
                }
            }
            if ( this.First == null )
            {
                error = "In '" + this.Name + "' the name of the access network data type was not found!";
                return false;
            }
            else if ( this.Second == null )
            {
                error = "In '" + this.Name + "' the name of the primary network data type was not found or does not contain trip component data!";
                return false;
            }
            else if ( this.Third == null && this.ComputeEgressStation )
            {
                error = "In '" + this.Name + "' the name of the egress network data type was not found or does not contain trip component data!";
                return false;
            }
            return true;
        }
示例#34
0
        public bool RuntimeValidation(ref string error)
        {
            if ( String.IsNullOrWhiteSpace( this.ModeName ) )
            {
                error = "In module '" + this.Name + "', please add in a 'Mode Name' for your nested choice!";
                return false;
            }
            if ( this.Correlation > 1 || this.Correlation < 0 )
            {
                error = "Correlation must be between 0 and 1 for " + this.ModeName + "!";
                return false;
            }
            if ( MaxAccessStations <= 0 )
            {
                error = "The number of feasible access stations must be greater than 0!";
                return false;
            }
            foreach ( var network in this.Root.NetworkData )
            {
                if ( network.NetworkType == this.AccessModeName )
                {
                    this.First = network;
                }

                if ( network.NetworkType == this.PrimaryModeName )
                {
                    var temp = network as ITripComponentData;
                    this.Second = temp == null ? this.Second : temp;
                }

                if ( network.NetworkType == this.EgressNetworkName )
                {
                    var temp = network as ITripComponentData;
                    this.Third = temp == null ? this.Third : temp;
                }

                if ( network.NetworkType == this.AlternativePrimaryModeName )
                {
                    this.FirstAlternative = network;
                }
            }
            if ( this.First == null )
            {
                error = "In '" + this.Name + "' the name of the access network data type was not found!";
                return false;
            }
            else if ( this.Second == null )
            {
                error = "In '" + this.Name + "' the name of the primary network data type was not found or does not contain trip component data!";
                return false;
            }
            else if ( this.Third == null && this.ComputeEgressStation )
            {
                error = "In '" + this.Name + "' the name of the egress network data type was not found or does not contain trip component data!";
                return false;
            }
            return true;
        }
示例#35
0
 protected float GetTravelLogsum(INetworkData autoNetwork, ITripComponentData transitNetwork, int i, int j, Time time)
 {
     float ivtt, cost;
     if(!autoNetwork.GetAllData(i, j, time, out ivtt, out cost))
     {
         return 0.0f;
     }
     return (float)(GetTransitUtility(transitNetwork, i, j, time)
         + Math.Exp(ivtt * AutoTime + cost * Cost));
 }
示例#36
0
 private static float ComputeV(ITripComponentData data, int egress, int destination, Time time, float ivttWeight, float walkWeight, float waitWeight, float boardingWeight, float costWeight)
 {
     Time ivtt, walk, wait, boarding;
     float cost;
     data.GetAllData( egress, destination, time, out ivtt, out walk, out wait, out boarding, out cost );
     return ivttWeight * ivtt.ToMinutes()
         + walkWeight * walk.ToMinutes()
         + waitWeight * wait.ToMinutes()
         + boardingWeight * boarding.ToMinutes()
         + costWeight * cost;
 }
 private float ComputeUtility(ITripComponentData transitNetwork, int originIndex, int destIndex)
 {
     float trueTravelTime, walk, wait, perceivedTravelTime, cost;
     if (transitNetwork.GetAllData(originIndex, destIndex, StartTime, out trueTravelTime, out walk, out wait, out perceivedTravelTime, out cost) && (perceivedTravelTime > 0))
     {
         return PerceivedTransitTime * perceivedTravelTime
             + TransitFare * cost;
     }
     return float.NegativeInfinity;
 }
示例#38
0
 private void EnsureNetworks(INetworkData autoNetwork, ITripComponentData transitNetwork)
 {
     if(autoNetwork == null)
     {
         throw new XTMFRuntimeException("In '" + Name + "' we were unable to find an auto network named '" + AutoNetworkName + "'!");
     }
     if(transitNetwork == null)
     {
         throw new XTMFRuntimeException("In '" + Name + "' we were unable to find an transit network named '" + TransitNetworkName + "'!");
     }
 }
示例#39
0
 public bool RuntimeValidation(ref string error)
 {
     foreach(var network in Root.NetworkData)
     {
         if(network.NetworkType == AutoNetworkName)
         {
             AutoNetwork = network;
         }
         else if(network.NetworkType == TransitNetworkName)
         {
             TransitNetwork = network as ITripComponentData;
         }
     }
     if(AutoNetwork == null)
     {
         error = "In '" + Name + "' we were unable to find an auto network called '" + AutoNetworkName + "'";
         return false;
     }
     if(TransitNetwork == null)
     {
         error = "In '" + Name + "' we were unable to find a transit network called '" + TransitNetworkName + "'";
         return false;
     }
     return true;
 }
示例#40
0
文件: Transit.cs 项目: Cocotus/XTMF
 public bool RuntimeValidation(ref string error)
 {
     if ( String.IsNullOrWhiteSpace( this.ModeName ) )
     {
         error = "All modes require a mode name!";
         return false;
     }
     bool found = false;
     IList<INetworkData> networks;
     networks = this.Root.NetworkData;
     foreach ( var network in networks )
     {
         if ( network.NetworkType == this.NetworkType )
         {
             this.TransitData = network as ITripComponentData;
             if ( this.TransitData == null )
             {
                 error = "The network data \"" + this.NetworkType + "\" does not support the ITransitNetworkData interface.  Please use a module that supports this!";
                 return false;
             }
             found = true;
             break;
         }
     }
     if ( !found )
     {
         error = "We were unable to find the network data with the name \"" + this.NetworkType + "\" in this Model System!";
         return false;
     }
     return true;
 }
示例#41
0
 private static bool ComputeThird(ITripComponentData data, int flatOrigin, int flatDestination, Time t, float walkTime, float waitTime, out float result)
 {
     float ivtt, walk, wait, boarding;
     float cost;
     data.GetAllData( flatOrigin, flatDestination, t, out ivtt, out walk, out wait, out boarding, out cost );
     if ( walk <= 0 )
     {
         result = float.PositiveInfinity;
         return false;
     }
     result = walk * walkTime
             + wait * waitTime
             + ivtt;
     return true;
 }
示例#42
0
        public bool RuntimeValidation(ref string error)
        {
            foreach ( var network in this.Root.NetworkData )
            {
                if ( network.NetworkType == Auto )
                {
                    this.AutoData = network;
                }

                else if ( network.NetworkType == Transit )
                {
                    var temp = network as ITripComponentData;
                    this.TransitData = temp == null ? this.TransitData : temp;
                }
            }
            return true;
        }
示例#43
0
        public bool RuntimeValidation(ref string error)
        {
            if(!ProfessionalFullTime.CheckResourceType<SparseArray<float>>())
            {
                error = "In '" + Name + "' the sub module Professional Full Time was not of type SparseArray<float>!";
                return false;
            }
            if(!ProfessionalPartTime.CheckResourceType<SparseArray<float>>())
            {
                error = "In '" + Name + "' the sub module Professional Part Time was not of type SparseArray<float>!";
                return false;
            }
            if(!ManufacturingFullTime.CheckResourceType<SparseArray<float>>())
            {
                error = "In '" + Name + "' the sub module Manufacturing Full Time was not of type SparseArray<float>!";
                return false;
            }
            if(!ManufacturingPartTime.CheckResourceType<SparseArray<float>>())
            {
                error = "In '" + Name + "' the sub module Manufacturing Part Time was not of type SparseArray<float>!";
                return false;
            }
            if(!GeneralFullTime.CheckResourceType<SparseArray<float>>())
            {
                error = "In '" + Name + "' the sub module General Full Time was not of type SparseArray<float>!";
                return false;
            }
            if(!GeneralPartTime.CheckResourceType<SparseArray<float>>())
            {
                error = "In '" + Name + "' the sub module General Part Time was not of type SparseArray<float>!";
                return false;
            }
            if(!RetailFullTime.CheckResourceType<SparseArray<float>>())
            {
                error = "In '" + Name + "' the sub module Retail Full Time was not of type SparseArray<float>!";
                return false;
            }
            if(!RetailPartTime.CheckResourceType<SparseArray<float>>())
            {
                error = "In '" + Name + "' the sub module Retail Part Time was not of type SparseArray<float>!";
                return false;
            }
            foreach(var network in Root.NetworkData)
            {
                if(network.NetworkType == AutoNetworkName)
                {
                    AutoNetwork = network;
                    break;
                }
            }
            if(AutoNetwork == null)
            {
                error = "In '" + Name + "' we were unable to find a network called '" + AutoNetworkName + "'";
            }

            foreach(var network in Root.NetworkData)
            {
                if(network.NetworkType == TransitNetworkName)
                {
                    TransitNetwork = network as ITripComponentData;
                    break;
                }
            }
            if(TransitNetwork == null)
            {
                error = "In '" + Name + "' we were unable to find a network called '" + AutoNetworkName + "'";
            }
            return true;
        }
示例#44
0
文件: BasicMode.cs 项目: Cocotus/XTMF
 /// <summary>
 /// Find and Load in the network data
 /// </summary>
 private void LoadNetworkData()
 {
     foreach ( var dataSource in this.Root.NetworkData )
     {
         if ( dataSource.NetworkType == this.NetworkType )
         {
             this.NetworkData = dataSource;
             ITripComponentData advancedData = dataSource as ITripComponentData;
             if ( advancedData != null )
             {
                 this.AdvancedNetworkData = advancedData;
             }
             break;
         }
     }
 }
示例#45
0
 private double GetTransitUtility(ITripComponentData network, int i, int j, Time time)
 {
     float ivtt, walk, wait, cost, boarding;
     if(!network.GetAllData(i, j, time, out ivtt, out walk, out wait, out boarding, out cost))
     {
         return 0f;
     }
     return Math.Exp(
           TransitTime * ivtt
         + TransitWalk * walk
         + TransitWait * wait
         + Cost * cost);
 }
示例#46
0
 private float ComputeUtility(ITripComponentData transitNetwork, int originIndex, int destIndex)
 {
     float ivtt, walk, wait, boardingPenalty, cost;
     if(transitNetwork.GetAllData(originIndex, destIndex, StartTime, out ivtt, out walk, out wait, out boardingPenalty, out cost) && (boardingPenalty > 0))
     {
         return TIVTT * ivtt
             + Boarding * boardingPenalty
             + TWALK * walk
             + TWAIT * wait
             + TransitFare * cost;
     }
     return float.NegativeInfinity;
 }
示例#47
0
文件: Transit.cs 项目: Cocotus/XTMF
 /// <summary>
 /// This is called before the start method as a way to pre-check that all of the parameters that are selected
 /// are in fact valid for this module.
 /// </summary>
 /// <param name="error">A string that should be assigned a detailed error</param>
 /// <returns>If the validation was successful or if there was a problem</returns>
 public bool RuntimeValidation(ref string error)
 {
     this.Data = null;
     foreach ( var network in this.TashaRuntime.NetworkData )
     {
         if ( network.NetworkType == this.NetworkType && network is ITripComponentData )
         {
             this.Data = network as ITripComponentData;
         }
     }
     if ( this.Data == null )
     {
         error = "We were unable to find a transit network with the name \"" + this.NetworkType + "\"!";
         return false;
     }
     return true;
 }
示例#48
0
 private bool AssignNetwork(IList<INetworkData> networks)
 {
     foreach(var network in networks)
     {
         if(network.NetworkType == NetworkType)
         {
             Network = network as ITripComponentData;
             return Network != null;
         }
     }
     return false;
 }