Model.Run C# (CSharp) Method

Run() public method

public Run ( int seed, int limit ) : bool
seed int
limit int
return bool
    public bool Run(int seed, int limit)
    {
        logT = Math.Log(T);
        logProb = new double[T];
        for (int t = 0; t < T; t++) logProb[t] = Math.Log(stationary[t]);

        Clear();

        random = new Random(seed);

        for (int l = 0; l < limit || limit == 0; l++)
        {
            bool? result = Observe();
            if (result != null) return (bool)result;
            while (Propagate());
        }

        return true;
    }

Usage Example

Exemplo n.º 1
0
		public static int Main(string[] args)
		{
			try {
				UI.TextWriter = Console.Out;

				Assembly assembly = Assembly.GetExecutingAssembly();
				VersionRelease versionRelease = new VersionRelease(assembly);
				UI.WriteLine("Landis-II {0}", versionRelease);
				UI.WriteLine("Copyright 2004-2005 University of Wisconsin");
				UI.WriteLine();
	
				if (args.Length == 0) {
					UI.WriteLine("Error: No scenario file specified.");
					return 1;
				}
				if (args.Length > 1) {
					UI.WriteLine("Error: Extra argument(s) on command line:");
					StringBuilder argsList = new StringBuilder();
					argsList.Append(" ");
					for (int i = 1; i < args.Length; ++i)
						argsList.AppendFormat(" {0}", args[i]);
					UI.WriteLine(argsList.ToString());
					return 1;
				}

				string appDir = Application.Directory;
				PlugIns.Dataset plugIns = new PlugIns.Dataset(Path.Combine(appDir, "plug-ins.xml"));
				RasterIO.DriverManager driverMgr = new RasterIO.DriverManager(Path.Combine(appDir, "raster-drivers.xml"));
				Model model = new Model(plugIns, driverMgr);
				model.Run(args[0]);
				return 0;
			}
			catch (ApplicationException exc) {
				UI.WriteLine(exc.Message);
				return 1;
			}
			catch (Exception exc) {
				UI.WriteLine("Internal error occurred within the program:");
				UI.WriteLine("  {0}", exc.Message);
				if (exc.InnerException != null) {
					UI.WriteLine("  {0}", exc.InnerException.Message);
				}
				UI.WriteLine();
				UI.WriteLine("Stack trace:");
				UI.WriteLine(exc.StackTrace);
				return 1;
			}
		}
All Usage Examples Of Model::Run