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


C# Metric.Equals方法代码示例

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


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

示例1: Run


//.........这里部分代码省略.........
            step.Stop( );
            total.Stop( );
            long CurrentUsage = Process.GetCurrentProcess( ).PrivateMemorySize64;
            if ( CurrentUsage > MaxMemoryUsage ) {
              MaxMemoryUsage = CurrentUsage;
            }
            path = nextPath;
            if ( path != null ) {
              foreach ( var Action in path.Actions ) {
            var oldState = StaticState.InitialDynamicState;
            if ( !Action.IsValidOn( StaticState.InitialDynamicState, StaticState, true ) ) {
              throw new IllegalActionOnStateException(
                "Illegal Action Given By Algorithm" );
            }
            StaticState.InitialDynamicState = Action.PerformOn(
              StaticState.InitialDynamicState, StaticState ).First( );
            fullPath.Push( Action, oldState, StaticState.InitialDynamicState );
            if ( !Batch ) {
              var U =  StaticState.InitialDynamicState.FindUnit( 0 );
              StaticState.Tiles[U.Y][U.X].Hits++;
            #if OpenGl
              vis.Visualize( StaticState, StaticState.InitialDynamicState );
              vis.SetStepData( (int)Algorithm.Generations, (int)Algorithm.Expansions,
                total.ElapsedTicks, fullPath.Cost.ToDouble( ) + numStops,
                ComputationTimes.Count != 0 ? ComputationTimes.Average( ): 0,
                MaxMemoryUsage, ComputationTimeMax,
                Expansions.Count != 0 ? Expansions.Average( ): 0 );
            #else
              System.Console.WriteLine( StaticState.InitialDynamicState ) ;
            #endif
            }
            HandleChanges( Dynamic, StepNumber );
              }
            } else {
              numStops++;
              HandleChanges( Dynamic, StepNumber );
            #if OpenGl
              if ( !Batch ) {
            vis.Visualize( StaticState, StaticState.InitialDynamicState );
            ( vis as OpenGLStateVisualizer ).redraw( );
            vis.SetStepData( (int)Algorithm.Generations, (int)Algorithm.Expansions,
                total.ElapsedTicks, fullPath.Cost.ToDouble( )+ numStops,
                ComputationTimes.Count != 0 ? ComputationTimes.Average( ): 0,
                MaxMemoryUsage, ComputationTimeMax,
                Expansions.Count != 0 ? Expansions.Average( ): 0 );
              }
            #endif
            }
            Expansions.Add( Algorithm.Expansions - LastExpansions );
            LastExpansions = Algorithm.Expansions;
            ComputationTimes.Add( step.ElapsedTicks );
            if ( step.ElapsedTicks > ComputationTimeMax ) {
              ComputationTimeMax = step.ElapsedTicks;
            }
            if ( Goal.IsSatisfiedBy( StaticState, StaticState.InitialDynamicState ) ) {
              break;
            }
            long t = refreshRate - step.ElapsedMilliseconds;
            if ( t > 0 ) {
              Thread.Sleep( (int)t );
            }
            Metric maxPathLength = new Metric( computationLimitCeilingRatio *
              ( StaticState.Map != null && StaticState.Map.OptimalSolutionCostSpecified ?
            StaticState.Map.OptimalSolutionCost :
            OptimalPathLength.ToDouble( ) ) );
            if ( maxPathLength.Equals( Metric.Infinity  ) && fullPath.Cost + new Metric( numStops ) >= maxPathLength ) {
              throw new MaxPathLengthExceded(
            new Results( Alg, ComputationLimit, Algorithm.Generations,
            Algorithm.Expansions, total.ElapsedTicks, fullPath.Cost.ToDouble( )+ numStops,
            StaticState.Map != null && StaticState.Map.OptimalSolutionCostSpecified ?
            StaticState.Map.OptimalSolutionCost :
            OptimalPathLength.ToDouble( ), File, ComputationTimes.Average( ),
            MaxMemoryUsage, ComputationTimeMax, Expansions.Average( ) ) );
            }
            StepNumber++;
            step.Reset( );
            step.Start( );
            total.Start( );
              }
              total.Stop( );
              if ( !Batch ) {

            #if OpenGl
            if ( vis != null ) {
              vis.Cleanup( );
            }
            #else
            new GenericGridWorldPathVisualizer( ).Visualize(
              Console.Out, fullPath, StaticState, StaticState.InitialDynamicState );
            #endif

              }
              double AverageComputationTime = ComputationTimes.Average( );
              return new Results( Alg, ComputationLimit, Algorithm.Generations,
            Algorithm.Expansions, total.ElapsedTicks, fullPath.Cost.ToDouble( )+ numStops,
            StaticState.Map != null && StaticState.Map.OptimalSolutionCostSpecified ?
            StaticState.Map.OptimalSolutionCost :
            OptimalPathLength.ToDouble( ), File, AverageComputationTime,
            MaxMemoryUsage, ComputationTimeMax, Expansions.Average( ) );
        }
开发者ID:Mokon,项目名称:mai,代码行数:101,代码来源:AlgorithmRunner.cs


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