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


C# Time.ToMinutes方法代码示例

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


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

示例1: GetBucketIndex

 private int GetBucketIndex(Time time)
 {
     // find the time in minutes starting from 4 AM
     var minutes = (int)time.ToMinutes() - (60 * 4);
     return minutes / MinutesPerBucket;
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:6,代码来源:ProjectScheduleAnalysis.cs

示例2: GetLocation

 internal IZone GetLocation(IZone previousZone, IEpisode ep, IZone nextZone, Time startTime, Time availableTime, float[] calculationSpace, Random random)
 {
     var p = zoneSystem.GetFlatIndex(previousZone.ZoneNumber);
     var n = zoneSystem.GetFlatIndex(nextZone.ZoneNumber);
     var size = zones.Length;
     int index = GetTimePeriod(startTime);
     var rowTimes = Parent.TimePeriods[index].RowTravelTimes;
     var columnTimes = Parent.TimePeriods[index].ColumnTravelTimes;
     var from = From[index];
     var available = availableTime.ToMinutes();
     var to = To[index];
     var pIndex = FlatZoneToPDCubeLookup[p];
     var nIndex = FlatZoneToPDCubeLookup[n];
     var data = PDCube[pIndex][nIndex];
     int previousIndexOffset = p * size;
     int nextSizeOffset = n * size;
     float total = 0.0f;
     if(VectorHelper.IsHardwareAccelerated)
     {
         Vector<float> availableTimeV = new Vector<float>(available);
         Vector<float> totalV = Vector<float>.Zero;
         if(nIndex == pIndex)
         {
             for(int i = 0; i < calculationSpace.Length; i++)
             {
                 var odUtility = 1.0f;
                 var pdindex = data[FlatZoneToPDCubeLookup[i]];
                 if(pdindex >= 0)
                 {
                     odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? ODConstants[pdindex].ExpConstant * expSamePD : ODConstants[pdindex].ExpConstant;
                 }
                 else
                 {
                     odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? expSamePD : 1.0f;
                 }
                 calculationSpace[i] = odUtility;
             }
         }
         else
         {
             for(int i = 0; i < calculationSpace.Length; i++)
             {
                 var pdindex = data[FlatZoneToPDCubeLookup[i]];
                 calculationSpace[i] = pdindex >= 0 ? ODConstants[pdindex].ExpConstant : 1f;
             }
         }
         for(int i = 0; i <= calculationSpace.Length - Vector<float>.Count; i += Vector<float>.Count)
         {
             Vector<int> zeroMask = Vector.LessThanOrEqual(new Vector<float>(rowTimes, previousIndexOffset + i)
                 + new Vector<float>(rowTimes, previousIndexOffset + i), availableTimeV);
             Vector<float> calcV = new Vector<float>(calculationSpace, i);
             calcV = Vector.AsVectorSingle(Vector.BitwiseAnd(Vector.AsVectorInt32(calcV), zeroMask))
                 * new Vector<float>(to, previousIndexOffset + i)
                 * new Vector<float>(nextSizeOffset + i);
             calcV.CopyTo(calculationSpace, i);
             totalV += calcV;
         }
         float remainderTotal = 0.0f;
         for(int i = calculationSpace.Length - (calculationSpace.Length % Vector<float>.Count); i < calculationSpace.Length; i++)
         {
             if(rowTimes[previousIndexOffset + i] + columnTimes[nextSizeOffset + i] <= available)
             {
                 remainderTotal += (calculationSpace[i] = to[previousIndexOffset + i] * from[nextSizeOffset + i] * calculationSpace[i]);
             }
             else
             {
                 calculationSpace[i] = 0;
             }
         }
         total += remainderTotal + Vector.Dot(totalV, Vector<float>.One);
     }
     else
     {
         unsafe
         {
             fixed (float* pRowTimes = &rowTimes[0])
             fixed (float* pColumnTimes = &columnTimes[0])
             fixed (float* pTo = &to[0])
             fixed (float* pFrom = &from[0])
             fixed (int* pData = &data[0])
             {
                 if(nIndex == pIndex)
                 {
                     for(int i = 0; i < calculationSpace.Length; i++)
                     {
                         if(pRowTimes[previousIndexOffset + i] + pColumnTimes[nextSizeOffset + i] <= available)
                         {
                             var odUtility = 1.0f;
                             var pdindex = pData[FlatZoneToPDCubeLookup[i]];
                             if(pdindex >= 0)
                             {
                                 odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? ODConstants[pdindex].ExpConstant * expSamePD : ODConstants[pdindex].ExpConstant;
                             }
                             else
                             {
                                 odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? expSamePD : 1.0f;
                             }
                             total += calculationSpace[i] = pTo[previousIndexOffset + i] * pFrom[nextSizeOffset + i] * odUtility;
                         }
                         else
//.........这里部分代码省略.........
开发者ID:Cocotus,项目名称:XTMF,代码行数:101,代码来源:V4LocationChoice.cs

示例3: AddStartTime

 private bool AddStartTime(int[][] startTimeCount, int id, Time tripTime)
 {
     int startTime = (int)Math.Round((tripTime.ToMinutes() / 15) - 16, 0);
     if(startTime < 0)
     {
         startTime += this.StartTimeQuantums;
     }
     if(startTime >= this.StartTimeQuantums)
     {
         return false;
     }
     if(startTimeCount[id] == null)
     {
         lock (startTimeCount)
         {
             Thread.MemoryBarrier();
             if(startTimeCount[id] == null)
             {
                 startTimeCount[id] = new int[this.StartTimeQuantums];
             }
             Thread.MemoryBarrier();
         }
     }
     startTimeCount[id][startTime]++;
     return true;
 }
开发者ID:dianatle,项目名称:XTMF,代码行数:26,代码来源:MakingDistStartTimeFreq.cs

示例4: LunchPass

 private int LunchPass(ITashaPerson person, int[][][] eventCount, Time workStartTime, Time workEndTime)
 {
     int lunchCount = 0;
     // Lunch pass
     int workStartBucket = (int)((workStartTime.ToMinutes() / 15) - 16);
     int workEndBucket = (int)((workEndTime.ToMinutes() / 15) - 16);
     var chains = person.TripChains;
     var tripChains = chains.Count;
     for (int j = 0; j < tripChains - 1; j++)
     {
         var ThisTrip = chains[j].Trips[chains[j].Trips.Count - 1];
         var NextTrip = chains[j + 1].Trips[0];
         Time activityStartTime = ThisTrip.OriginalZone == null || ThisTrip.DestinationZone == null ? ThisTrip.TripStartTime : ThisTrip.ActivityStartTime;
         int startTime = (int)(activityStartTime.ToMinutes() / 15 - 16);
         var duration = (int)((NextTrip.TripStartTime - activityStartTime).ToMinutes() / 15);
         if (!PreProcessTimes(person, ref startTime, ref duration))
         {
             return 0;
         }
         if ((ThisTrip.Purpose == Activity.Home) | (ThisTrip.Purpose == Activity.ReturnFromWork))
         {
             if (startTime >= workStartBucket && startTime + duration <= workEndBucket)
             {
                 var id = Distribution.GetDistributionID(person, Activity.ReturnFromWork);
                 if (id != -1)
                 {
                     AddStartTimeDuration(eventCount, person, startTime, duration, id);
                     lunchCount++;
                 }
             }
         }
     }
     return lunchCount;
 }
开发者ID:dianatle,项目名称:XTMF,代码行数:34,代码来源:MakingDistrDuratFreq.cs

示例5: AddPimaryWorkEpisode

 private void AddPimaryWorkEpisode(ITashaPerson person, int[][][] eventCount, Time workStartTime, Time workEndTime)
 {
     if (workEndTime > Time.Zero)
     {
         var id = Distribution.GetDistributionID(person, Activity.PrimaryWork);
         if (id >= 0)
         {
             int startTime = (int)(workStartTime.ToMinutes() / 15 - 16);
             var duration = (int)((workEndTime - workStartTime).ToMinutes() / 15);
             if (duration >= 0)
             {
                 AddStartTimeDuration(eventCount, person, startTime, duration, id);
             }
         }
     }
 }
开发者ID:dianatle,项目名称:XTMF,代码行数:16,代码来源:MakingDistrDuratFreq.cs

示例6: ToMinutesTest

 public void ToMinutesTest()
 {
     Time target = new Time(10F);
     double expected = 0.16666666666666666;
     double actual;
     actual = target.ToMinutes();
     Assert.AreEqual(expected, actual);
 }
开发者ID:rmc00,项目名称:gsf,代码行数:8,代码来源:TimeTest.cs

示例7: CalculateLocationProbabilities

            /// <summary>
            /// 
            /// </summary>
            /// <param name="previousZone"></param>
            /// <param name="ep"></param>
            /// <param name="nextZone"></param>
            /// <param name="startTime"></param>
            /// <param name="availableTime"></param>
            /// <param name="calculationSpace"></param>
            /// <returns>The sum of the calculation space</returns>
            private float CalculateLocationProbabilities(IZone previousZone, IEpisode ep, IZone nextZone, Time startTime, Time availableTime, float[] calculationSpace)
            {
                var p = zoneSystem.GetFlatIndex(previousZone.ZoneNumber);
                var n = zoneSystem.GetFlatIndex(nextZone.ZoneNumber);
                var size = zones.Length;
                int index = GetTimePeriod(startTime);
                var rowTimes = Parent.TimePeriods[index].RowTravelTimes;
                var columnTimes = Parent.TimePeriods[index].ColumnTravelTimes;
                var from = From[index];
                var available = availableTime.ToMinutes();
                var to = To[index];
                var pIndex = FlatZoneToPDCubeLookup[p];
                var nIndex = FlatZoneToPDCubeLookup[n];
                var data = PDCube[index][pIndex][nIndex];
                int previousIndexOffset = p * size;
                int nextIndexOffset = n * size;
                float total = 0.0f;
                if (Vector.IsHardwareAccelerated)
                {
                    Vector<float> availableTimeV = new Vector<float>(available);
                    Vector<float> totalV = Vector<float>.Zero;
                    int i = 0;
                    if (nIndex == pIndex)
                    {
                        for (i = 0; i < calculationSpace.Length; i++)
                        {
                            var odUtility = 1.0f;
                            var pdindex = data[FlatZoneToPDCubeLookup[i]];
                            if (pdindex >= 0)
                            {
                                odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? TimePeriod[index].ODConstants[pdindex].ExpConstant * TimePeriod[index].expSamePD
                                    : TimePeriod[index].ODConstants[pdindex].ExpConstant;
                            }
                            else
                            {
                                odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? TimePeriod[index].expSamePD : 1.0f;
                            }
                            calculationSpace[i] = odUtility;
                        }
                    }
                    else
                    {
                        for (i = 0; i < calculationSpace.Length; i++)
                        {
                            var pdindex = data[FlatZoneToPDCubeLookup[i]];
                            calculationSpace[i] = pdindex >= 0 ? TimePeriod[index].ODConstants[pdindex].ExpConstant : 1f;
                        }
                    }

                    for (i = 0; i <= calculationSpace.Length - Vector<float>.Count; i += Vector<float>.Count)
                    {
                        var timeTo = new Vector<float>(rowTimes, previousIndexOffset + i);
                        var timeFrom = new Vector<float>(columnTimes, nextIndexOffset + i);
                        var utilityTo = new Vector<float>(to, previousIndexOffset + i);
                        var utilityFrom = new Vector<float>(from, nextIndexOffset + i);
                        Vector<float> calcV = new Vector<float>(calculationSpace, i);
                        Vector<int> zeroMask = Vector.LessThanOrEqual(timeTo + timeFrom, availableTimeV);
                        calcV = Vector.AsVectorSingle(Vector.BitwiseAnd(Vector.AsVectorInt32(calcV), zeroMask))
                            * utilityTo * utilityFrom;
                        calcV.CopyTo(calculationSpace, i);
                        totalV += calcV;
                    }
                    float remainderTotal = 0.0f;
                    for (; i < calculationSpace.Length; i++)
                    {
                        if (rowTimes[previousIndexOffset + i] + columnTimes[nextIndexOffset + i] <= available)
                        {
                            remainderTotal += (calculationSpace[i] = to[previousIndexOffset + i] * from[nextIndexOffset + i] * calculationSpace[i]);
                        }
                        else
                        {
                            calculationSpace[i] = 0;
                        }
                    }
                    total += remainderTotal + Vector.Dot(totalV, Vector<float>.One);
                }
                else
                {
                    unsafe
                    {
                        fixed (float* pRowTimes = &rowTimes[0])
                        fixed (float* pColumnTimes = &columnTimes[0])
                        fixed (float* pTo = &to[0])
                        fixed (float* pFrom = &from[0])
                        fixed (int* pData = &data[0])
                        {
                            if (nIndex == pIndex)
                            {
                                for (int i = 0; i < calculationSpace.Length; i++)
                                {
//.........这里部分代码省略.........
开发者ID:dianatle,项目名称:XTMF,代码行数:101,代码来源:V4LocationChoice.cs


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