本文整理汇总了C#中ITashaHousehold类的典型用法代码示例。如果您正苦于以下问题:C# ITashaHousehold类的具体用法?C# ITashaHousehold怎么用?C# ITashaHousehold使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITashaHousehold类属于命名空间,在下文中一共展示了ITashaHousehold类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute(ITashaHousehold household, int iteration)
{
foreach(var period in TimePeriods)
{
period.Execute(household);
}
}
示例2: GetWorkSchoolProjectStatus
public static HouseholdWorkSchoolProjectStatus GetWorkSchoolProjectStatus(ITashaHousehold household)
{
bool evening_workschool = false;
bool morning_workschool = false;
bool any_workschool = false;
foreach(var person in household.Persons)
{
PersonWorkSchoolProjectStatus workschoolProjectStatus = SchedulerPerson.GetWorkSchoolProjectStatus(person);
if(workschoolProjectStatus == PersonWorkSchoolProjectStatus.FullTimeEveningWorkOrSchool ||
workschoolProjectStatus == PersonWorkSchoolProjectStatus.FullTimeDayAndEveningWorkOrSchool ||
workschoolProjectStatus == PersonWorkSchoolProjectStatus.Other)
evening_workschool = true;
if(workschoolProjectStatus == PersonWorkSchoolProjectStatus.FullTimeNoEveningWorkOrSchool ||
workschoolProjectStatus == PersonWorkSchoolProjectStatus.FullTimeDayAndEveningWorkOrSchool ||
workschoolProjectStatus == PersonWorkSchoolProjectStatus.PartTimeDay ||
workschoolProjectStatus == PersonWorkSchoolProjectStatus.PartTimeEvening)
morning_workschool = true;
if(workschoolProjectStatus > 0) any_workschool = true;
}
if(!any_workschool) return HouseholdWorkSchoolProjectStatus.NoWorkOrSchool; // noone in hhld works or attends school today
else if(!evening_workschool) return HouseholdWorkSchoolProjectStatus.NoEveningWorkOrSchool; //there is work/school, but none after 6:00pm
else if(!morning_workschool) return HouseholdWorkSchoolProjectStatus.EveningWorkOrSchool; //there is evening work/school, but no work/school before 1:00pm
else return HouseholdWorkSchoolProjectStatus.DayAndEveningWorkOrSchool; // there is work/school before 1pm and after 6pm
}
示例3: Execute
public void Execute(ITashaHousehold household, int iteration)
{
lock ( this )
{
foreach ( var person in household.Persons )
{
foreach ( var tripChain in person.TripChains )
{
int CurrentNumberOfTrips = tripChain.Trips.Count;
if ( NumberOfTrips.ContainsKey( CurrentNumberOfTrips ) ) // Has this scenario occured previously?
{
NumberOfTrips[CurrentNumberOfTrips] += 1; // If it has, add one more occurence to it.
}
else
{
NumberOfTrips.Add( CurrentNumberOfTrips, 1 ); // If it hasn't, create the scenario and give it a value of one occurence at this point.
}
if ( CurrentNumberOfTrips == 1 )
{
throw new XTMFRuntimeException( "Household " + household.HouseholdId + " has a trip chain with only one trip. The trip chain belongs to person number " + person.Id );
}
}
}
}
}
示例4: Execute
public void Execute(ITashaHousehold household)
{
lock (this)
{
foreach(var person in household.Persons)
{
var expFactor = person.ExpansionFactor;
foreach(var tripChain in person.TripChains)
{
foreach(var trip in tripChain.Trips)
{
Dictionary<int, float> activityDictionary = GetDictionary(trip.Purpose);
int hour = trip.ActivityStartTime.Hours;
if(activityDictionary.ContainsKey(hour))
{
activityDictionary[hour] += expFactor;
}
else
{
activityDictionary.Add(hour, expFactor);
}
}
}
}
}
}
示例5: Execute
public void Execute(ITashaHousehold household, int iteration)
{
var persons = household.Persons;
bool taken = false;
WriteLock.Enter(ref taken);
for(int i = 0; i < persons.Length; i++)
{
var expanionFactor = persons[i].ExpansionFactor;
var tripChains = persons[i].TripChains;
for(int j = 0; j < tripChains.Count; j++)
{
var tripChain = tripChains[j].Trips;
for(int k = 0; k < tripChain.Count; k++)
{
var mode = tripChain[k].Mode;
for(int l = 0; l < Modes.Length; l++)
{
if(Modes[l] == mode)
{
Counts[l] += expanionFactor;
break;
}
}
}
}
}
if(taken) WriteLock.Exit(true);
}
示例6: HouseholdComplete
public void HouseholdComplete(ITashaHousehold household, bool success)
{
if ( success )
{
lock ( this )
{
var writeHeader = !File.Exists( OutputFile );
using ( StreamWriter writer = new StreamWriter( OutputFile, true ) )
{
if ( writeHeader )
{
writer.WriteLine( "HouseholdID,HouseholdIteration,Household Utility" );
}
var util = Utilities[household.HouseholdId];
for ( int i = 0; i < util.Length; i++ )
{
writer.Write( household.HouseholdId );
writer.Write( ',' );
writer.Write( i );
writer.Write( ',' );
writer.WriteLine( util[i] );
}
}
}
}
else
{
throw new XTMFRuntimeException( "A household was not able to be resolved." );
}
}
示例7: Execute
public void Execute(ITashaHousehold household)
{
lock ( this )
{
var householdData = household["SData"] as Tasha.Scheduler.SchedHouseholdData;
ResultDict["JointMarket"] += household.ExpansionFactor * householdData.JointMarketProject.Schedule.EpisodeCount;
NumberDict["JointMarket"] += householdData.JointMarketProject.Schedule.EpisodeCount;
ResultDict["JointOther"] += household.ExpansionFactor * householdData.JointOtherProject.Schedule.EpisodeCount;
NumberDict["JointOther"] += householdData.JointOtherProject.Schedule.EpisodeCount;
foreach ( var person in household.Persons )
{
var schedData = person["SData"];
var personData = person["SData"] as Tasha.Scheduler.SchedulerPersonData;
var workSched = personData.WorkSchedule.Schedule;
var schoolSched = personData.SchoolSchedule.Schedule;
var marketSched = personData.MarketSchedule.Schedule;
var otherSched = personData.OtherSchedule.Schedule;
ResultDict["Work"] += household.ExpansionFactor * workSched.EpisodeCount;
NumberDict["Work"] += workSched.EpisodeCount;
ResultDict["School"] += schoolSched.EpisodeCount * household.ExpansionFactor;
NumberDict["School"] += schoolSched.EpisodeCount;
ResultDict["Market"] += marketSched.EpisodeCount * household.ExpansionFactor;
NumberDict["Market"] += marketSched.EpisodeCount;
ResultDict["Other"] += household.ExpansionFactor * otherSched.EpisodeCount;
NumberDict["Other"] += otherSched.EpisodeCount;
}
}
}
示例8: Execute
public void Execute(ITashaHousehold household, int iteration)
{
lock ( this )
{
foreach ( var person in household.Persons )
{
foreach ( var tripChain in person.TripChains )
{
foreach ( var trip in tripChain.Trips )
{
var householdIterations = trip.ModesChosen == null ? 1 : trip.ModesChosen.Length;
for ( int i = 0; i < householdIterations; i++ )
{
if ( trip.ModesChosen[i] == null )
{
this.Validate1.Write( "Problem in household #" );
this.Validate1.WriteLine( household.HouseholdId );
}
else
{
if ( trip.ModesChosen[i].ModeName == "Auto" )
{
Count += 1;
}
}
}
}
}
}
}
}
示例9: Execute
public void Execute(ITashaHousehold household, int iteration)
{
var autoNetworkData = this.Root.NetworkData.FirstOrDefault( (network) => network.NetworkType == this.NetworkName );
var zones = this.Root.ZoneSystem.ZoneArray.GetFlatData();
if ( autoNetworkData == null )
{
throw new XTMFRuntimeException( "We could not find the '" + this.NetworkName + "' network!" );
}
foreach ( var person in household.Persons )
{
foreach ( var tripChain in person.TripChains )
{
for ( int i = 0; i < tripChain.Trips.Count - 1; i++ )
{
var trip = tripChain.Trips[i];
var nextTrip = tripChain.Trips[i + 1];
if ( trip.Purpose == Activity.Market && nextTrip.Purpose == Activity.Market )
{
var originIndex = this.Root.ZoneSystem.ZoneArray.GetFlatIndex( trip.OriginalZone.ZoneNumber );
// run my logic here
for(int j = 0; j < zones.Length; j++)
{
var travelTime = autoNetworkData.TravelTime( originIndex, j, trip.TripStartTime );
}
}
}
}
}
}
示例10: Execute
public void Execute(ITashaHousehold household, int iteration)
{
var persons = household.Persons;
for (int i = 0; i < persons.Length; i++)
{
if (persons[i].Age >= MinimumAge)
{
var expansionFactor = persons[i].ExpansionFactor;
var tripChains = persons[i].TripChains;
for (int j = 0; j < tripChains.Count; j++)
{
var tripChain = tripChains[j].Trips;
for (int k = 0; k < tripChain.Count; k++)
{
int index = (((int)(TripStartTime ? tripChain[k].TripStartTime : tripChain[k].ActivityStartTime).ToMinutes()) / 30);
var tripStartIndex = index < 0 ? (index % NumberOfTimeBins + NumberOfTimeBins) % NumberOfTimeBins : index % NumberOfTimeBins;
var array = GetPurposeCount(tripChain, k);
var tripModeIndex = GetTripModeIndex(tripChain[k].Mode);
if (tripModeIndex >= 0)
{
var row = array[tripStartIndex];
lock (array[tripStartIndex])
{
row[tripModeIndex] += expansionFactor;
}
}
}
}
}
}
}
示例11: Execute
public void Execute(ITashaHousehold household, int iteration)
{
//Determine the worker category
int nVehicles = household.Vehicles.Length;
int nDrivers = household.Persons.Count((ITashaPerson p) => p.Licence);
int wcat;
if (nVehicles == 0)
{
wcat = 0;
}
else
{
wcat = (nVehicles > nDrivers) ? 2 : 1;
}
foreach (var person in household.Persons)
{
var empStat = person.EmploymentStatus;
if (empStat == TMG.TTSEmploymentStatus.FullTime | empStat == TMG.TTSEmploymentStatus.PartTime) continue; //Skip unemployed persons
IZone employmentZone = person.EmploymentZone;
if ( employmentZone == null ) continue;
var distance = (int) (this._ZoneDistances[household.HomeZone.ZoneNumber, employmentZone.ZoneNumber] * this.CoordinateFactor);
int index = this.HistogramBins.IndexOf(distance);
if (index < 0)
{
index = this.HistogramBins.Count;
}
bool taken = false;
WriteLock.Enter(ref taken);
this._BinData[index][wcat] += person.ExpansionFactor;
if (taken) WriteLock.Exit(true);
}
}
示例12: HouseholdIterationComplete
public void HouseholdIterationComplete(ITashaHousehold household, int hhldIteration, int totalHouseholdIterations)
{
for ( int i = 0; i < household.Persons.Length; i++ )
{
for ( int j = 0; j < household.Persons[i].TripChains.Count; j++ )
{
if ( household.Persons[i].TripChains[j].JointTrip && !household.Persons[i].TripChains[j].JointTripRep )
{
continue;
}
for ( int k = 0; k < household.Persons[i].TripChains[j].Trips.Count; k++ )
{
var trip = household.Persons[i].TripChains[j].Trips[k];
if ( trip.Mode == this.Root.AllModes[PassengerIndex] )
{
using ( StreamWriter Writer = new StreamWriter( this.OutputFile, true ) )
{
var originalTrip = trip["Driver"] as ITrip;
var originalDistance = this.Root.ZoneSystem.Distances[originalTrip.OriginalZone.ZoneNumber, originalTrip.DestinationZone.ZoneNumber];
var passengerDistance = this.Root.ZoneSystem.Distances[trip.OriginalZone.ZoneNumber, trip.DestinationZone.ZoneNumber];
float firstLeg;
float secondLeg;
if ( originalTrip.OriginalZone == trip.OriginalZone )
{
firstLeg = 0;
}
if ( originalTrip.DestinationZone == trip.DestinationZone )
{
secondLeg = 0;
}
firstLeg = this.Root.ZoneSystem.Distances[originalTrip.OriginalZone.ZoneNumber, trip.OriginalZone.ZoneNumber];
secondLeg = this.Root.ZoneSystem.Distances[trip.DestinationZone.ZoneNumber, originalTrip.DestinationZone.ZoneNumber];
var newDistance = ( passengerDistance + firstLeg + secondLeg );
if ( Data.Keys.Contains( passengerDistance ) )
{
Data[passengerDistance].Add( newDistance );
}
else
{
Data.TryAdd( passengerDistance, new List<float>() );
Data[passengerDistance].Add( newDistance );
}
//Writer.WriteLine( "{0}, {1}, {2}, {3}, {4}", household.HouseholdId, household.Persons[i].Id, originalTrip.TripChain.Person.Id, passengerDistance, newDistance );
}
}
}
}
}
}
示例13: Run
public void Run(ITashaHousehold household)
{
Random householdRandom = new Random( this.Seed * household.HouseholdId );
var persons = household.Persons;
List<IActivityEpisode>[] episodes = InitializeEpisodes( persons );
GenerateEpisodes( household, householdRandom, persons, episodes );
OrderPriorities( episodes );
ScheduleEpisodes( household, householdRandom, persons, episodes );
}
示例14: Execute
public void Execute(ITashaHousehold household, int iteration)
{
var householdFitness = (float)EvaluateHousehold(household);
bool taken = false;
FitnessUpdateLock.Enter(ref taken);
Thread.MemoryBarrier();
Fitness += householdFitness;
if(taken) FitnessUpdateLock.Exit(true);
}
示例15: ModeChoiceHouseholdData
public ModeChoiceHouseholdData(ITashaHousehold household, int numberOfModes, int numberOfVehicleTypes)
{
var persons = household.Persons;
var personData = PersonData = new ModeChoicePersonData[persons.Length];
for ( int i = 0; i < personData.Length; i++ )
{
personData[i] = new ModeChoicePersonData( persons[i].TripChains, numberOfModes, numberOfVehicleTypes );
}
}