当前位置: 首页>>代码示例>>C#>>正文


C# ITashaHousehold.Attach方法代码示例

本文整理汇总了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;
        }
开发者ID:Cocotus,项目名称:XTMF,代码行数:79,代码来源:ModeChoice.cs


注:本文中的ITashaHousehold.Attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。