/// <summary> /// Solves a file and adds to the processing queue. /// </summary> private void SolveFileTop(string tName) { string file; lock ( FilesQueue ) { if (FilesQueue.Count == 0) { return; } else { file = FilesQueue.Dequeue( ); } } System.Console.WriteLine("\tfile is {0} on thread {1}.", file, tName); if (Solve) { Solution solution = null; StreamReader s = null; AlgorithmRunner ar; try { s = new StreamReader(new FileStream(file, FileMode.Open, FileAccess.Read)); ar = new AlgorithmRunner(s, Loader, "", new Metric(1), true, null, 0); solution = ar.Solve(null); s.Close( ); } catch (Exception e) { System.Console.WriteLine(e.Message); s.Close( ); return; } if (solution.Path.Cost < new Metric(MinPathLength) || solution.Path.Cost > new Metric(MaxPathLength) || solution.Algorithm.Expansions < AStarMinExpansion || solution.Algorithm.Expansions > AStarMaxExpansion) { return; } WriteToOut(file + " " + solution.Path.Cost); } else { WriteToOut(file + " 0"); } }
/// <summary> /// Runs the demo mode. /// </summary> /// <param name="args"></param> public override void Run(string[] args) { if (Solve) { this.ParseArgs(args); } if (Demo.Equals("presentation")) { (vis as OpenGLStateVisualizer).Presentation(false, false, false); } else if (Demo.Equals("presentation-doors")) { (vis as OpenGLStateVisualizer).Presentation(true, true, false); } else if (Demo.Equals("presentation-questions")) { (vis as OpenGLStateVisualizer).Presentation(false, true, true); } else if (Demo.Equals("none")) { } try { Loader.LOS = LOS; var AR = new AlgorithmRunner(filestream, Loader, Algorithm, new Metric(Weight), false, vis, Seed); if (Solve) { var SOL = AR.Solve(null); OptimalPathLenth = SOL.Path.Cost; } AR.Resultss = Resultss; Results = AR.Run(refreshRate, false, 1000, Algorithm, computationLimit, OptimalPathLenth, file, Dynamic); System.Console.WriteLine(Results); } catch (PathNotFoundException) { System.Console.Out.WriteLine("Path Not Found"); } }
/// <summary> /// Runs the demo mode. /// </summary> /// <param name="args"></param> public override void Run( string[] args ) { if ( Solve ) { this.ParseArgs( args ); } if ( Demo.Equals( "presentation" ) ) { ( vis as OpenGLStateVisualizer ).Presentation( false, false, false ); } else if ( Demo.Equals( "presentation-doors" ) ) { ( vis as OpenGLStateVisualizer ).Presentation( true, true, false ); } else if ( Demo.Equals( "presentation-questions" ) ) { ( vis as OpenGLStateVisualizer ).Presentation( false, true, true ); } else if ( Demo.Equals( "none" ) ) { } try { Loader.LOS = LOS; var AR = new AlgorithmRunner( filestream, Loader, Algorithm, new Metric( Weight ), false, vis, Seed ); if ( Solve ) { var SOL = AR.Solve( null ); OptimalPathLenth = SOL.Path.Cost; } AR.Resultss = Resultss; Results = AR.Run( refreshRate, false, 1000, Algorithm, computationLimit, OptimalPathLenth, file, Dynamic ); System.Console.WriteLine( Results ); } catch ( PathNotFoundException ) { System.Console.Out.WriteLine( "Path Not Found" ); } }
/// <summary> /// Solves a file and adds to the processing queue. /// </summary> private void SolveFileTop( string tName ) { string file; lock ( FilesQueue ) { if ( FilesQueue.Count == 0 ) { return; } else { file = FilesQueue.Dequeue( ); } } System.Console.WriteLine( "\tfile is {0} on thread {1}.", file, tName ); if ( Solve ) { Solution solution = null; StreamReader s = null; AlgorithmRunner ar; try { s = new StreamReader( new FileStream( file, FileMode.Open, FileAccess.Read ) ); ar = new AlgorithmRunner( s, Loader, "", new Metric( 1 ), true, null, 0 ); solution = ar.Solve( null ); s.Close( ); } catch ( Exception e ) { System.Console.WriteLine( e.Message ); s.Close( ); return; } if ( solution.Path.Cost < new Metric( MinPathLength )|| solution.Path.Cost > new Metric( MaxPathLength ) || solution.Algorithm.Expansions < AStarMinExpansion || solution.Algorithm.Expansions > AStarMaxExpansion ) { return; } WriteToOut( file + " " + solution.Path.Cost ); } else { WriteToOut( file + " 0" ); } }