// private static ProgressBar progressBar = new ProgressBar(); static async Task Main(string[] args) { Host.Program.RunServer(args); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Gray; Console.Clear(); Console.SetCursorPosition(0, 1); Console.WriteLine(AsciiLogo.VSLogo); Console.ForegroundColor = ConsoleColor.Cyan; Console.SetCursorPosition(0, 1); Console.WriteLine(AsciiLogo.VSLogo2); Console.ForegroundColor = ConsoleColor.Cyan; Console.SetCursorPosition(71, 10); Console.WriteLine("Loading the Central Bureau of Statistics"); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(71, 12); Console.Write("Marriage Probabilities..."); MaritalStatusProbability.Init(); Console.WriteLine("Loaded"); Console.SetCursorPosition(71, 13); Console.Write("ChildBirth Probabilities..."); ChildrenProbability.Init(); Console.WriteLine("Loaded"); Console.SetCursorPosition(71, 14); Console.Write("Age Probabilities..."); AgeProbability.Init(); Console.WriteLine("Loaded"); Console.CursorVisible = false; Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Clear(); Console.ForegroundColor = ConsoleColor.Black; Console.SetCursorPosition(0, 7); Console.WriteLine(AsciiLogo.QR); Console.SetCursorPosition(0, 0); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(AsciiLogo.VSLogo3); var startDate = new DateTime(1950, 1, 1); endDate = new DateTime(2020, 1, 1).AddDays(-1); Console.ForegroundColor = ConsoleColor.White; env = new SimSharp.Simulation(new DateTime(1950, 1, 1), 42); var people = new Population(env, endDate, Statistics); startPerf = DateTime.UtcNow.AddYears(-1); Console.SetCursorPosition(0, 18); Console.WriteLine(AsciiLogo.Heartbeat); t = new Timer(Reporter, env, 1000, 250); env.RunFinished += Env_RunFinished; env.Run(endDate); // Console.Read(); }
public void ExportXYZ(float scale, int startYear, int endYear, int gender) { var frame = Frame.CreateEmpty <int, int>(); var length = AgeProbability.Source[gender, 0].Count; frame.AddColumn(-1, AgeProbability.Source[gender, 0]); for (int y = startYear; y <= endYear; y++) { var index = AgeProbability.YearIndex(y); frame.AddColumn(index, AgeProbability.Weights[gender, index]); } frame.SaveCsv($"./AgeTests/3d-{Constants.DisplayNames[gender]}.csv"); }
/// <summary> /// Warms up a society by scale. i.e. 0.1 will start a population on a 10% scale. /// </summary> /// <param name="scale"></param> public void Warmup(float scale) { // Recreate Total population by year counting number of people per age group. var index = AgeProbability.YearIndex(Environment.StartDate.Year); // Traverse all age categories for males and females. for (int age = 0; age < AgeProbability.Source[0, 0].Count; age++) { var people = (int)(AgeProbability.Weights[Constants.idx_gender_male, index][age] * scale); for (int j = 0; j < people; j++) { new Person(Environment, age); } } }
public void AgeDistribution(float scale, int startYear, int endYear, int gender) { // Arrange var env = new SimSharp.ThreadSafeSimulation(42); for (int y = startYear; y <= endYear; y++) { var index = AgeProbability.YearIndex(y); Helpers.Sample(this, scale, y.ToString(), gender, AgeProbability.Source[gender, index], AgeProbability.Weights[gender, index], "Age distribution" ); } }
static AgeTests() { AgeProbability.Init(); }