本文整理汇总了C#中ITashaHousehold.Attach方法的典型用法代码示例。如果您正苦于以下问题:C# ITashaHousehold.Attach方法的具体用法?C# ITashaHousehold.Attach怎么用?C# ITashaHousehold.Attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITashaHousehold
的用法示例。
在下文中一共展示了ITashaHousehold.Attach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public bool Run(ITashaHousehold household)
{
if(MaxTripChainSize > 0)
{
if(AnyOverMaxTripChainSize(household))
{
return false;
}
}
Random random = new Random( RandomSeed + household.HouseholdId );
ModeChoiceHouseholdData householdData = new ModeChoiceHouseholdData( household, AllModes.Length, VehicleTypes.Length + 1 );
HouseholdResourceAllocator householdResourceAllocator = new HouseholdResourceAllocator( household, AllModes );
PassengerMatchingAlgorithm passengerMatchingAlgorithm = null;
// attach this so analysis modules can look at it later
household.Attach( "ModeChoiceData", householdData );
household.Attach( "ResourceAllocator", householdResourceAllocator );
if ( PassengerMode != null )
{
passengerMatchingAlgorithm = new PassengerMatchingAlgorithm( household, householdData, PassengerMode, AllModes );
household.Attach( "PassengerMatchingAlgorithm", passengerMatchingAlgorithm );
}
for ( int i = 0; i < PostHouseholdIteration.Length; i++ )
{
PostHouseholdIteration[i].HouseholdStart( household, HouseholdIterations );
}
if ( !Pass1( householdData, random ) )
{
for ( int i = 0; i < PostHouseholdIteration.Length; i++ )
{
PostHouseholdIteration[i].HouseholdComplete( household, false );
}
return false;
}
for ( int householdIteration = 0; householdIteration < HouseholdIterations; householdIteration++ )
{
if ( householdIteration > 0 )
{
RegenerateErrorTerms( householdData, random );
}
// Start of Pass 2
AssignBestPerVehicle( Root.VehicleTypes, householdData, householdIteration );
var resolution = householdResourceAllocator.Resolve( householdData, VehicleTypes, householdIteration );
if ( resolution == null )
{
for ( int i = 0; i < PostHouseholdIteration.Length; i++ )
{
PostHouseholdIteration[i].HouseholdComplete( household, false );
}
// failure
return false;
}
AssignModes( resolution, householdData );
householdResourceAllocator.BuildVehicleAvailabilities( householdData, household.Vehicles );
// Start of Pass 2.5 ( rideshare )
ProcessRideshare( householdData );
// Start of Pass 3 (Passenger attaching to trip chains)
if ( passengerMatchingAlgorithm != null )
{
passengerMatchingAlgorithm.GeneratePotentialPassengerTrips( random, true );
passengerMatchingAlgorithm.ResolvePassengerTrips();
// Start of Pass 4 (Passenger attaching to new trips coming from home)
passengerMatchingAlgorithm.GeneratePotentialPassengerTrips( random, false, householdResourceAllocator );
passengerMatchingAlgorithm.ResolvePassengerTrips();
}
// Now at the end add to chosen modes (And assign joint trips)
FinalAssignment( householdData, householdIteration );
for ( int i = 0; i < PostHouseholdIteration.Length; i++ )
{
PostHouseholdIteration[i].HouseholdIterationComplete( household, householdIteration, HouseholdIterations );
}
}
for ( int i = 0; i < PostHouseholdIteration.Length; i++ )
{
PostHouseholdIteration[i].HouseholdComplete( household, true );
}
return true;
}