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


C# ITashaHousehold.Recycle方法代码示例

本文整理汇总了C#中ITashaHousehold.Recycle方法的典型用法代码示例。如果您正苦于以下问题:C# ITashaHousehold.Recycle方法的具体用法?C# ITashaHousehold.Recycle怎么用?C# ITashaHousehold.Recycle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITashaHousehold的用法示例。


在下文中一共展示了ITashaHousehold.Recycle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

 private void Run(int i, ITashaHousehold household)
 {
     var persons = household.Persons;
     Time[] workStartTimes = new Time[persons.Length];
     Time[] workEndTimes = new Time[persons.Length];
     for(int p = 0; p < persons.Length; p++)
     {
         AssignEpisodes(persons[p], ref workStartTimes[p], ref workEndTimes[p], null);
     }
     System.Threading.Tasks.Parallel.For(0, persons.Length, delegate (int personNumber)
     {
         ITashaPerson person = household.Persons[personNumber];
         Time workStartTime = workStartTimes[personNumber];
         Time workEndTime = workEndTimes[personNumber];
         bool invalidPerson = false;
         var eventCount = new int[this.NumberOfDistributionsLocal];
         var startTimeCount = new int[this.NumberOfDistributionsLocal][];
         foreach(var tripChain in person.TripChains)
         {
             List<ITrip> trips = tripChain.Trips;
             for(int t = 0; t < trips.Count; t++)
             {
                 if(trips[t].Purpose != Activity.PrimaryWork)
                 {
                     IncreaseID(ref invalidPerson, eventCount, startTimeCount, trips[t], GetID(person, trips[t]));
                 }
             }
         }
         if(workStartTime > Time.Zero)
         {
             var workID = Distribution.GetDistributionID(person, Activity.PrimaryWork);
             if(workID >= 0)
             {
                 eventCount[workID]++;
                 AddStartTime(startTimeCount, workID, workStartTime);
             }
         }
         int lunches = LunchPass(person, eventCount, startTimeCount, ref workStartTime, ref workEndTime);
         // if this person is invalid skip adding the data back to the final results
         if(invalidPerson)
         {
             return;
         }
         StoreResults(person.ExpansionFactor, eventCount, startTimeCount);
     });
     System.Threading.Interlocked.Increment(ref this.CurrentHousehold);
     this.Progress = ((float)this.CurrentHousehold / this.NumberOfHouseholds) / this.TotalIterations + this.CompletedIterationPercentage;
     household.Recycle();
 }
开发者ID:dianatle,项目名称:XTMF,代码行数:49,代码来源:MakingDistStartTimeFreq.cs

示例2: Run

        private void Run(int i, ITashaHousehold household)
        {
            int[][][] eventCount = new int[NumberOfDistributionsLocal][][];
            bool invalidHousehold = false;

            var numberOfPeople = household.Persons.Length;
            Time[] workStartTimes = new Time[numberOfPeople];
            Time[] workEndTimes = new Time[numberOfPeople];
            for (int p = 0; p < numberOfPeople; p++)
            {
                AssignEpisodes(household.Persons[p], ref workStartTimes[p], ref workEndTimes[p], null);
            }
            System.Threading.Tasks.Parallel.For(0, numberOfPeople, delegate (int personNumber)
            {
                ITashaPerson person = household.Persons[personNumber];
                Time workStartTime = workStartTimes[personNumber];
                Time workEndTime = workEndTimes[personNumber];
                FirstPass(eventCount, ref invalidHousehold, person);
                AddPimaryWorkEpisode(person, eventCount, workStartTime, workEndTime);
                LunchPass(person, eventCount, workStartTime, workEndTime);
            });

            // check to see if we have an invalid household, if we do we do not add the data!
            if (invalidHousehold)
            {
                return;
            }
            StoreResults(household.ExpansionFactor, eventCount);

            Interlocked.Increment(ref CurrentHousehold);
            Progress = ((float)CurrentHousehold / NumberOfHouseholds) / TotalIterations + CompletedIterationPercentage;
            household.Recycle();
        }
开发者ID:dianatle,项目名称:XTMF,代码行数:33,代码来源:MakingDistrDuratFreq.cs

示例3: Run

 private void Run(ITashaHousehold household, BlockingCollection<Result> resultList)
 {
     var numberOfPeople = household.Persons.Length;
     if ( household.NumberOfAdults >= 2 )
     {
         Time[] workStartTimes = new Time[numberOfPeople];
         Time[] workEndTimes = new Time[numberOfPeople];
         for ( int i = 0; i < numberOfPeople; i++ )
         {
             AssignEpisodes( household.Persons[i], ref workStartTimes[i], ref workEndTimes[i], null );
         }
         int[] jointMarket = new int[this.NumberOfAdults];
         int[] jointOther = new int[this.NumberOfAdults];
         bool any = false;
         foreach ( var person in household.Persons )
         {
             foreach ( var tc in person.TripChains )
             {
                 if ( tc.JointTripRep )
                 {
                     var chains = tc.JointTripChains;
                     int adults = 0;
                     for ( int i = 0; i < chains.Count; i++ )
                     {
                         if ( chains[i].Person.Adult )
                         {
                             adults++;
                         }
                     }
                     any = true;
                     adults = adults > this.NumberOfAdults ? this.NumberOfAdults : adults;
                     foreach ( var trip in tc.Trips )
                     {
                         switch ( trip.Purpose )
                         {
                             case Activity.JointOther:
                                 jointOther[adults]++;
                                 break;
                             case Activity.JointMarket:
                                 jointMarket[adults]++;
                                 break;
                         }
                     }
                 }
             }
         }
         if ( any )
         {
             resultList.Add( new Result()
             {
                 Adults = household.NumberOfAdults,
                 Children = household.Persons.Length - household.NumberOfAdults > 0,
                 ExpansionFactor = household.ExpansionFactor,
                 JointMarketAdults = jointMarket,
                 JointOthersAdults = jointOther
             } );
         }
     }
     System.Threading.Interlocked.Increment( ref this.CurrentHousehold );
     household.Recycle();
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:61,代码来源:MakingNumberOfAdultDistributions.cs

示例4: Run

        private void Run(int i, ITashaHousehold hhld)
        {
            if(!_ExitRequested)
            {
                if(Scheduler != null)
                {
                    Scheduler.Run(hhld);
                    if(PostScheduler != null)
                    {
                        foreach(var module in PostScheduler)
                        {
                            module.Execute(hhld);
                        }
                    }
                }

                if(ModeChoice != null)
                {
                    if(!ModeChoice.Run(hhld))
                    {
                        Interlocked.Increment(ref FailedModeChoice);
                    }
                }

                if(PostHousehold != null)
                {
                    foreach(var module in PostHousehold)
                    {
                        module.Execute(hhld, i);
                    }
                }
                System.Threading.Interlocked.Increment(ref CurrentHousehold);

                if(RecycleHouseholdData)
                {
                    ReleaseModeData(hhld);
                    hhld.Recycle();
                }
            }
        }
开发者ID:Cocotus,项目名称:XTMF,代码行数:40,代码来源:TashaRuntime.cs

示例5: Run

 private void Run(int i, ITashaHousehold household)
 {
     foreach ( var module in this.PostHousehold )
     {
         module.Execute( household, i );
     }
     System.Threading.Interlocked.Increment( ref this.CurrentHousehold );
     this.Progress = ( (float)this.CurrentHousehold / this.NumberOfHouseholds ) / this.TotalIterations + this.CompletedIterationPercentage;
     household.Recycle();
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:10,代码来源:TashaValidationDataAnalys.cs


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