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


C# Metric.ToDouble方法代码示例

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


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

示例1: Run

        /// <summary>
        /// Runs the algorithm.
        /// </summary>
        /// <param name="refreshRate"></param>
        /// <param name="ComputationLimit"></param>
        /// <param name="Batch"></param>
        /// <param name="maxPathLength"></param>
        /// <returns></returns>
        public Results Run( long refreshRate, bool Batch, double computationLimitCeilingRatio,
            string Alg, int ComputationLimit, Metric OptimalPathLength, string File,
            bool Dynamic)
        {
            if ( Algorithm is RealTimeAlgorithm<GenericGridWorldStaticState,
            GenericGridWorldDynamicState> ) {
            ( Algorithm as RealTimeAlgorithm<GenericGridWorldStaticState,
              GenericGridWorldDynamicState> ).SetComputationLimit( ComputationLimit );
              }
              Path<GenericGridWorldStaticState, GenericGridWorldDynamicState> path = null;
              Path<GenericGridWorldStaticState, GenericGridWorldDynamicState> fullPath =
            new Path<GenericGridWorldStaticState, GenericGridWorldDynamicState>(
              (GenericGridWorldDynamicState)null );
              long MaxMemoryUsage = 0;
              int numStops = 0;
              List<double> ComputationTimes = new List<double>( );
              List<double> Expansions = new List<double>( );
              double LastExpansions = 0;
              long ComputationTimeMax = long.MinValue;
              if ( !Batch ) {
            #if OpenGl
            if ( vis != null ) {
              vis.Visualize( StaticState, StaticState.InitialDynamicState );
              vis.SetInitData( Alg, ComputationLimit,
            StaticState.Map != null && StaticState.Map.OptimalSolutionCostSpecified ?
            StaticState.Map.OptimalSolutionCost :
            OptimalPathLength.ToDouble( ), File, Resultss );
            }
            #else
              System.Console.WriteLine( StaticState.InitialDynamicState ) ;
            #endif
              }

              int StepNumber = 0;
              UncoverMap( );
              Stopwatch total = Stopwatch.StartNew( );
              Stopwatch step = Stopwatch.StartNew( );
              foreach ( var nextPath in
            Algorithm.Compute( StaticState, StaticState.InitialDynamicState, Goal,
              Actions ) ) {
            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 ) {
//.........这里部分代码省略.........
开发者ID:Mokon,项目名称:mai,代码行数:101,代码来源:AlgorithmRunner.cs


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