public bool RuntimeValidation(ref string error)
 {
     OurTasha = Root.MainClient as ITashaRuntime;
     if (OurTasha == null)
     {
         error = "In '" + Name + "' the estimation's client model system is not an ITashaRuntime!";
         return(false);
     }
     return(true);
 }
Example #2
0
 public PassengerAlgo(ITashaRuntime runtime)
 {
     TashaRuntime = runtime;
 }
 public bool RuntimeValidation(ref string error)
 {
     OurTasha = Root.MainClient as ITashaRuntime;
     if(OurTasha == null)
     {
         error = "In '" + Name + "' the estimation's client model system is not an ITashaRuntime!";
         return false;
     }
     return true;
 }
Example #4
0
        /// <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)
        {
            // if our deep ancestor is in fact a tasha runtime
            this.TashaRuntime = this.Root as ITashaRuntime;
            IList <INetworkData> networks;

            if (this.TashaRuntime == null)
            {
                // check for a 4Step model system template
                var tdm = this.Root as ITravelDemandModel;
                // if it isn't report the error
                if (tdm == null)
                {
                    error = "The Tasha.Modes.Auto Module only works with ITashaRuntime's and ITravelDemandModel's!";
                    return(false);
                }
                networks = tdm.NetworkData;
            }
            else
            {
                if (String.IsNullOrWhiteSpace(this.VehicleTypeName))
                {
                    this.AutoType = this.TashaRuntime.AutoType;
                }
                else
                {
                    if (this.TashaRuntime.VehicleTypes != null)
                    {
                        foreach (var v in this.TashaRuntime.VehicleTypes)
                        {
                            if (v.VehicleName == this.VehicleTypeName)
                            {
                                this.AutoType = v;
                                break;
                            }
                        }
                    }
                }
                if (AutoType == null)
                {
                    error = "We were unable to find an vehicle type to use for '" + this.ModeName + "'!";
                    return(false);
                }
                networks = this.TashaRuntime.NetworkData;
            }
            if (String.IsNullOrWhiteSpace(this.NetworkType))
            {
                error = "There was no network type selected for the " + (String.IsNullOrWhiteSpace(this.ModeName) ? "Auto" : this.ModeName) + " mode!";
                return(false);
            }
            if (networks == null)
            {
                error = "There was no Auto Network loaded for the Auto Mode!";
                return(false);
            }
            bool found = false;

            foreach (var network in networks)
            {
                if (network.NetworkType == this.NetworkType)
                {
                    this.AutoData = network;
                    found         = true;
                    break;
                }
            }
            if (!found)
            {
                error = "In '" + Name + "' we were unable to find the network data with the name \"" + this.NetworkType + "\" in this Model System!";
                return(false);
            }

            return(true);
        }
Example #5
0
        /// <summary>
        /// Load the data we only need to get once
        /// </summary>
        public void LoadOneTimeLocalData()
        {
            if ( this.AlternativeTravelModeName != null && this.AlternativeTravelModeName != String.Empty )
            {
                var allModes = this.TashaRuntime.AllModes;
                bool found = false;
                foreach ( var mode in allModes )
                {
                    if ( mode.ModeName == this.AlternativeTravelModeName )
                    {
                        this.AlternativeTravelMode = mode;
                        found = true;
                        break;
                    }
                }
                if ( !found )
                {
                    throw new XTMFRuntimeException( "Unable to find the Alternative Travel Mode called " + this.AlternativeTravelModeName );
                }
            }
            Scheduler.LocalScheduler = this;
            Scheduler.Tasha = this.TashaRuntime;
            Scheduler.MinimumWorkingAge = this.MinWorkingAgeLocal;
            Scheduler.EpisodeSchedulingAttempts = this.EpisodeSchedulingAttemptsLocal;
            Scheduler.ActivityLevels = this.GetFullPath( this.ActivityLevelsLocal );
            Scheduler.SchoolMorningStart = this.SchoolMorningStartDateTime;
            Scheduler.SchoolMorningEnd = this.SchoolMorningEndDateTime;
            Scheduler.SchoolAfternoonStart = this.SchoolAfternoonStartDateTime;
            Scheduler.SchoolAfternoonEnd = this.SchoolAfternoonEndDateTime;
            Scheduler.SecondaryWorkThreshold = this.SecondaryWorkThresholdDateTime;
            Scheduler.StartTimeQuanta = this.StartTimeQuantaLocal;
            Scheduler.StartTimeQuantaInterval = (short)( ( 24 * 60 ) / Scheduler.StartTimeQuanta );
            Time.OneQuantum = this.MinimumDurationDateTime;
            Time.StartOfDay = new Time() { Hours = 4 };
            Time.EndOfDay = new Time() { Hours = 28 };
            Scheduler.PercentOverlapAllowed = this.PercentOverlapAllowedLocal;
            Scheduler.SecondaryWorkMinStartTime = this.SecondaryWorkMinStartTimeDateTime;
            Scheduler.MinPrimaryWorkDurationForReturnHomeFromWork = this.MinPrimaryWorkDurationForReturnHomeFromWorkDateTime;
            Scheduler.MaxPrimeWorkStartTimeForReturnHomeFromWork = this.MaxPrimeWorkStartTimeForReturnHomeFromWorkDateTime;
            Scheduler.ReturnHomeFromWorkMaxEndTime = this.ReturnHomeFromWorkMaxEndTimeDateTime;
            Scheduler.FullTimeActivity = this.FullTimeActivityDateTime;
            Scheduler.LocationChoiceModel = this.LocationChoiceModelLocal;
            Scheduler.LocationChoiceModel.LoadLocationChoiceCache();
            //Distributions
            Scheduler.AdultDistributionsFile = this.GetFullPath( this.AdultDistributionsFileLocal );
            Scheduler.FrequencyDistributionsFile = this.GetFullPath( this.FrequencyDistributionsFileLocal );
            Scheduler.NumberOfDistributions = this.NumberOfDistributionsLocal;
            Scheduler.NumberOfAdultFrequencies = this.NumberOfAdultFrequenciesLocal;
            Scheduler.NumberOfAdultDistributions = this.NumberOfAdultDistributionsLocal;

            Scheduler.MaxFrequency = this.MaxFrequencyLocal;
            Distribution.TashaRuntime = this.TashaRuntime;
            Distribution.InitializeDistributions();

            HouseholdExtender.TashaRuntime = this.TashaRuntime;
            // references in scheduler
            SchedulerHousehold.TashaRuntime = this.TashaRuntime;
            Schedule.Scheduler = this;
        }
Example #6
0
        /// <summary>
        /// Load the data we only need to get once
        /// </summary>
        public void LoadOneTimeLocalData()
        {
            if (this.AlternativeTravelModeName != null && this.AlternativeTravelModeName != String.Empty)
            {
                var  allModes = this.TashaRuntime.AllModes;
                bool found    = false;
                foreach (var mode in allModes)
                {
                    if (mode.ModeName == this.AlternativeTravelModeName)
                    {
                        this.AlternativeTravelMode = mode;
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    throw new XTMFRuntimeException("Unable to find the Alternative Travel Mode called " + this.AlternativeTravelModeName);
                }
            }
            Scheduler.LocalScheduler            = this;
            Scheduler.Tasha                     = this.TashaRuntime;
            Scheduler.MinimumWorkingAge         = this.MinWorkingAgeLocal;
            Scheduler.EpisodeSchedulingAttempts = this.EpisodeSchedulingAttemptsLocal;
            Scheduler.ActivityLevels            = this.GetFullPath(this.ActivityLevelsLocal);
            Scheduler.SchoolMorningStart        = this.SchoolMorningStartDateTime;
            Scheduler.SchoolMorningEnd          = this.SchoolMorningEndDateTime;
            Scheduler.SchoolAfternoonStart      = this.SchoolAfternoonStartDateTime;
            Scheduler.SchoolAfternoonEnd        = this.SchoolAfternoonEndDateTime;
            Scheduler.SecondaryWorkThreshold    = this.SecondaryWorkThresholdDateTime;
            Scheduler.StartTimeQuanta           = this.StartTimeQuantaLocal;
            Scheduler.StartTimeQuantaInterval   = (short)((24 * 60) / Scheduler.StartTimeQuanta);
            Time.OneQuantum                     = this.MinimumDurationDateTime;
            Time.StartOfDay                     = new Time()
            {
                Hours = 4
            };
            Time.EndOfDay = new Time()
            {
                Hours = 28
            };
            Scheduler.PercentOverlapAllowed     = this.PercentOverlapAllowedLocal;
            Scheduler.SecondaryWorkMinStartTime = this.SecondaryWorkMinStartTimeDateTime;
            Scheduler.MinPrimaryWorkDurationForReturnHomeFromWork = this.MinPrimaryWorkDurationForReturnHomeFromWorkDateTime;
            Scheduler.MaxPrimeWorkStartTimeForReturnHomeFromWork  = this.MaxPrimeWorkStartTimeForReturnHomeFromWorkDateTime;
            Scheduler.ReturnHomeFromWorkMaxEndTime = this.ReturnHomeFromWorkMaxEndTimeDateTime;
            Scheduler.FullTimeActivity             = this.FullTimeActivityDateTime;
            Scheduler.LocationChoiceModel          = this.LocationChoiceModelLocal;
            Scheduler.LocationChoiceModel.LoadLocationChoiceCache();
            //Distributions
            Scheduler.AdultDistributionsFile     = this.GetFullPath(this.AdultDistributionsFileLocal);
            Scheduler.FrequencyDistributionsFile = this.GetFullPath(this.FrequencyDistributionsFileLocal);
            Scheduler.NumberOfDistributions      = this.NumberOfDistributionsLocal;
            Scheduler.NumberOfAdultFrequencies   = this.NumberOfAdultFrequenciesLocal;
            Scheduler.NumberOfAdultDistributions = this.NumberOfAdultDistributionsLocal;

            Scheduler.MaxFrequency    = this.MaxFrequencyLocal;
            Distribution.TashaRuntime = this.TashaRuntime;
            Distribution.InitializeDistributions();

            HouseholdExtender.TashaRuntime = this.TashaRuntime;
            // references in scheduler
            SchedulerHousehold.TashaRuntime = this.TashaRuntime;
            Schedule.Scheduler = this;
        }
Example #7
0
File: Auto.cs Project: 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)
        {
            // if our deep ancestor is in fact a tasha runtime
            this.TashaRuntime = this.Root as ITashaRuntime;
            IList<INetworkData> networks;
            if(this.TashaRuntime == null)
            {
                // check for a 4Step model system template
                var tdm = this.Root as ITravelDemandModel;
                // if it isn't report the error
                if(tdm == null)
                {
                    error = "The Tasha.Modes.Auto Module only works with ITashaRuntime's and ITravelDemandModel's!";
                    return false;
                }
                networks = tdm.NetworkData;
            }
            else
            {
                if(String.IsNullOrWhiteSpace(this.VehicleTypeName))
                {
                    this.AutoType = this.TashaRuntime.AutoType;
                }
                else
                {
                    if(this.TashaRuntime.VehicleTypes != null)
                    {
                        foreach(var v in this.TashaRuntime.VehicleTypes)
                        {
                            if(v.VehicleName == this.VehicleTypeName)
                            {
                                this.AutoType = v;
                                break;
                            }
                        }
                    }
                }
                if(AutoType == null)
                {
                    error = "We were unable to find an vehicle type to use for '" + this.ModeName + "'!";
                    return false;
                }
                networks = this.TashaRuntime.NetworkData;
            }
            if(String.IsNullOrWhiteSpace(this.NetworkType))
            {
                error = "There was no network type selected for the " + (String.IsNullOrWhiteSpace(this.ModeName) ? "Auto" : this.ModeName) + " mode!";
                return false;
            }
            if(networks == null)
            {
                error = "There was no Auto Network loaded for the Auto Mode!";
                return false;
            }
            bool found = false;
            foreach(var network in networks)
            {
                if(network.NetworkType == this.NetworkType)
                {
                    this.AutoData = network;
                    found = true;
                    break;
                }
            }
            if(!found)
            {
                error = "In '" + Name + "' we were unable to find the network data with the name \"" + this.NetworkType + "\" in this Model System!";
                return false;
            }

            return true;
        }