public static void BeginProgram() { var timer = new Timer("Starting DaySim Controller..."); Console.WriteLine("Run initial DaySim steps locally"); var settingsFactory = new SettingsFactory(Global.Configuration); Global.Settings = settingsFactory.Create(); ParallelUtility.Init(Global.Configuration); Engine.InitializeDaySim(); Engine.BeginInitialize(); Engine.BeginRunRawConversion(); Engine.BeginImportData(); Engine.BeginBuildIndexes(); BeginRunRemoteProcesses(); BeginMerge(); BeginLoadData(); Engine.BeginUpdateShadowPricing(); if (Global.Configuration.RemoteCopySPFilesToRemoteMachines) { BeginCopyFilesToRemoteMachines(); } timer.Stop("Total running time"); }
public void TestAutoOwnershipModel() { Global.Configuration = new Configuration { NProcessors = 1 }; ParallelUtility.Init(); Global.Configuration.AutoOwnershipModelCoefficients = "c:\\a.txt"; ParallelUtility.Register(Thread.CurrentThread.ManagedThreadId, 0); List <IPerson> persons = new List <IPerson> { new Person() }; CondensedParcel residenceParcel = new CondensedParcel(); HouseholdWrapper household = TestHelper.GetHouseholdWrapper(persons, residenceParcel: residenceParcel); household.Init(); AutoOwnershipModel model = new AutoOwnershipModel(); model.RunInitialize(new TestCoefficientsReader()); model.Run(household); }
public void TestAutoOwnershipModelNullHouseholdException() { Global.Configuration = new Configuration { NProcessors = 1 }; ParallelUtility.Init(); Global.Configuration.AutoOwnershipModelCoefficients = "c:\\a.txt"; ParallelUtility.Register(Thread.CurrentThread.ManagedThreadId, 0); List <IPerson> persons = new List <IPerson> { new Person() }; CondensedParcel residenceParcel = new CondensedParcel(); HouseholdWrapper household = TestHelper.GetHouseholdWrapper(persons, residenceParcel: residenceParcel); household.Init(); AutoOwnershipModel model = new AutoOwnershipModel(); model.RunInitialize(new TestCoefficientsReader()); ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => model.Run(null)); Assert.Equal("Value cannot be null.\r\nParameter name: household", ex.Message); }
private static void Main(string[] args) { try { var options = new OptionSet { { "c|configuration=", "Path to configuration file", v => _configurationPath = v }, { "p|printfile=", "Path to print file", v => _printFilePath = v }, { "s|start=", "Start index of household range", v => _start = int.Parse(v) }, { "e|end=", "End index of household range", v => _end = int.Parse(v) }, { "i|index=", "Cluser index", v => _index = int.Parse(v) }, { "h|?|help", "Show help and syntax summary", v => _showHelp = v != null } }; options.Parse(args); if (_showHelp) { options.WriteOptionDescriptions(Console.Out); Console.WriteLine(); Console.WriteLine("If you do not provide a configuration then the default is to use {0}, in the same directory as the executable.", ConfigurationManager.DEFAULT_CONFIGURATION_NAME); Console.WriteLine(); Console.WriteLine("If you do not provide a printfile then the default is to create {0}, in the same directory as the executable.", PrintFile.DEFAULT_PRINT_FILE_NAME); Console.WriteLine("Please press any key to exit"); Console.ReadKey(); Environment.Exit(0); } var configurationManager = new ConfigurationManager(_configurationPath); var configuration = configurationManager.Open(); var settingsFactory = new SettingsFactory(configuration); var settings = settingsFactory.Create(); var printFile = new PrintFile(_printFilePath, configuration); configurationManager.Write(configuration, printFile); ParallelUtility.Init(configuration); Global.Configuration = configuration; Global.Settings = settings; Global.PrintFile = printFile; Global.Kernel = new StandardKernel(new DaysimModule()); var moduleFactory = new ModuleFactory(configuration); var modelModule = moduleFactory.Create(); Global.Kernel.Load(modelModule); Engine.BeginProgram(_start, _end, _index); //Engine.BeginTestMode(); } catch (Exception e) { Console.WriteLine(); Console.WriteLine(e.GetBaseException().Message); Console.WriteLine(); Console.WriteLine(e.StackTrace); Console.WriteLine(); Console.WriteLine("Please press any key to exit"); if (Global.PrintFile != null) { Global.PrintFile.WriteLine(e.GetBaseException().Message); Global.PrintFile.WriteLine(); Global.PrintFile.WriteLine(e.StackTrace); } Console.ReadKey(); Environment.Exit(2); } finally { if (Global.PrintFile != null) { Global.PrintFile.Dispose(); } } Environment.Exit(0); }