private TashaPerson LoadPerson(BinaryReader reader, Datastructure.SparseArray <IZone> zoneArray, TashaHousehold household, int personID)
        {
            TashaPerson person = new TashaPerson();

            person.Household        = household;
            person.Id               = personID;
            person.Age              = reader.ReadInt32();
            person.Female           = reader.ReadBoolean();
            person.EmploymentStatus = (TTSEmploymentStatus)reader.ReadInt32();
            person.Occupation       = (Occupation)reader.ReadInt32();
            person.EmploymentZone   = zoneArray[reader.ReadInt32()];
            person.StudentStatus    = (StudentStatus)reader.ReadInt32();
            person.SchoolZone       = zoneArray[reader.ReadInt32()];
            person.Licence          = reader.ReadBoolean();
            person.FreeParking      = reader.ReadBoolean();
            int numberOfTripChains;

            LoadKeys(reader, person);
            person.TripChains = new List <ITripChain>(numberOfTripChains = reader.ReadInt32());
            for (int i = 0; i < numberOfTripChains; i++)
            {
                person.TripChains.Add(LoadTripChain(reader, zoneArray, person));
            }
            return(person);
        }
Example #2
0
        private void GraphTripPurpose(Distribution.DistributionInformation[] distributionData)
        {
            TashaHousehold Household   = new TashaHousehold();
            TashaPerson    person      = new TashaPerson();
            List <int>     primaryWork = new List <int>();

            person.Licence = false;
            person.Male    = GenderLocal;

            SchedulerHousehold.CreateHouseholdProjects(Household);
            SchedulerPerson.InitializePersonalProjects(person);
            SchedulerPerson.GenerateWorkSchoolSchedule(person, null);
            SchedulerTripChain.GetTripChain(person);
            var trip = SchedulerTrip.GetTrip(0);

            Occupation[] Occupations = { Occupation.Professional, Occupation.Manufacturing, Occupation.Retail, Occupation.Office, Occupation.Unknown, Occupation.NotEmployed };

            LoadDistributioNumbers(person, primaryWork, Occupations);

            float[] data = new float[this.StartTimeQuantums];
            foreach (int ID in primaryWork)
            {
                var table = distributionData[ID].StartTimeFrequency;
                for (int i = 0; i < this.StartTimeQuantums; i++)
                {
                    for (int j = 0; j < this.MaxFrequencyLocal; j++)
                    {
                        data[i] += table[i][j];
                    }
                }
            }

            // Make all data in terms of percentages of total.

            float sum = data.Sum();

            for (int number = 0; number < data.Length; number++)
            {
                data[number] = data[number] / sum * 100;
                Writer.WriteLine("{0}, {1}", (Time.FromMinutes((60 * 4) + number * (1440 / this.StartTimeQuantums))), data[number]);
            }

            GenerateChart(String.Format("OfficeDur.png"), data, "Time of Day", "Probability");
        }
Example #3
0
        private static void LoadDistributioNumbers(TashaPerson person, List <int> primaryWork, Occupation[] occupations)
        {
            foreach (Occupation current in occupations)
            {
                person.Occupation = current;
                for (person.Age = 11; person.Age < 100; person.Age++)
                {
                    if (person.Age >= 16 && person.Licence == false)
                    {
                        person.Licence = true;
                    }

                    if (primaryWork.Contains(Distribution.GetDistributionID(person, Activity.PrimaryWork)))
                    {
                    }

                    else
                    {
                        primaryWork.Add(Distribution.GetDistributionID(person, Activity.PrimaryWork));
                    }
                }
            }
        }
        private SchedulerTripChain LoadTripChain(BinaryReader reader, Datastructure.SparseArray <IZone> zoneArray, TashaPerson person)
        {
            SchedulerTripChain chain = SchedulerTripChain.GetTripChain(person);

            chain.JointTripID  = reader.ReadInt32();
            chain.JointTripRep = reader.ReadBoolean();
            LoadKeys(reader, chain);
            int numberOfTrips = reader.ReadInt32();

            for (int i = 0; i < numberOfTrips; i++)
            {
                SchedulerTrip trip = LoadTrip(reader, zoneArray, chain, i);
                // Now that we have all of the data that we need, add ourselves to the trip chain
                chain.Trips.Add(trip);
            }
            return(chain);
        }