public LayoutGenerator( LayoutConfiguration layoutConfiguration, IRandomizer rand, SettingConfiguration baseConfiguration, ControlConfiguration controlConfiguration, Action <string> logAction = null) { _logAction = logAction; String errorMessage = ""; if (!layoutConfiguration.isValid(out errorMessage)) { throw new ArgumentException("LayoutConfiguration is not valid. " + errorMessage); } baseConfiguration.InventoryConfiguration.autogenerate(); if (!baseConfiguration.InventoryConfiguration.isValid(layoutConfiguration.PodCapacity, out errorMessage)) { throw new ArgumentException("InventoryConfiguration is not valid. " + errorMessage); } if (!controlConfiguration.IsValid(out errorMessage)) { throw new ArgumentException("ControlConfiguration is not valid. " + errorMessage); } this.rand = rand; this.baseConfiguration = baseConfiguration; elevatorPositions = new Dictionary <Tuple <double, double>, Elevator>(); elevatorWaypoints = new Dictionary <Elevator, List <Waypoint> >(); elevatorSemaphores = new Dictionary <Waypoint, QueueSemaphore>(); instance = Instance.CreateInstance(this.baseConfiguration, controlConfiguration); instance.Name = layoutConfiguration.NameLayout; this.lc = layoutConfiguration; }
private void btnSaveChanged_Click(object sender, EventArgs e) { string dirLog = txtFolderLogs.Text.Trim(); string dirOutLog = txtFolderOutLog.Text.Trim(); string processName = gridLookUpProcess.EditValue.ToString(); string stationNo = txtStationNo.Text; string barcodeLength = txtBarcodeLength.Text; if (dirLog.Length > 0) { SettingConfiguration.F_UpdateKey("PathInput", dirLog); } if (dirOutLog.Length > 0) { SettingConfiguration.F_UpdateKey("PathOutput", dirOutLog); } if (processName.Length > 0) { SettingConfiguration.F_UpdateKey("ProcessName", processName); } if (stationNo.Length > 0) { SettingConfiguration.F_UpdateKey("StationNo", stationNo); } if (barcodeLength.Length > 1) { SettingConfiguration.F_UpdateKey("BarcodeLength", barcodeLength); } MessageBox.Show("Cập nhật cấu hình thành công. Chương trình sẽ tự động tắt, vui lòng chạy lại!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit(); }
private void SaveAction(object obj) { try { if (Helpers.ShowMessage("Yakin Menyimpan Data ? ", "Pilih", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (IsBusy) { return; } IsBusy = true; pti model = (pti)this; model.FromId = SettingConfiguration.GetIntValue("CityId"); if (IsListValid(model.Collies)) { context.SaveChange(model); Saved = true; PTI p = new PTI { ShiperID = this.ShiperID, RecieverId = this.RecieverId, CreatedDate = this.CreatedDate, Id = this.Id, PayType = this.PayType, Pcs = this.Collies.Sum(O => O.Pcs), Weight = this.Collies.Sum(O => O.Weight), RecieverName = this.Reciever.Name, ShiperName = this.Shiper.Name, Biaya = this.Collies.Sum(O => O.Biaya), User = Authorization.User.Name }; ParentSource.Add(p); Helpers.ShowMessage("PTI Berhasil Disimpan"); if (Helpers.ShowMessage("Input PTI Baru ? ", "Pilih", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { SetNew(); } else { WindowClose(); } } else { Helpers.ShowErrorMessage("Item Data Tidak Lengkap, Periksa Kembali"); } } } catch (Exception ex) { MyMessage.Show(ex.Message, "Error", MessageBoxButton.OK); } finally { IsBusy = false; } }
private void btnSaveChanged_Click(object sender, EventArgs e) { string dirLog = txtDirFolderLog.Text.Trim(); string dirOutLog = txtDirFolderOutLog.Text.Trim(); string processName = cboWindows.Text; string stationNo = cboStationNo.Text; if (dirLog.Length > 0) { SettingConfiguration.F_UpdateKey("PathInput", dirLog); } if (dirOutLog.Length > 0) { SettingConfiguration.F_UpdateKey("PathOutput", dirOutLog); } if (processName.Length > 0) { SettingConfiguration.F_UpdateKey("ProcessName", processName); } if (stationNo.Length > 0) { SettingConfiguration.F_UpdateKey("StationNo", stationNo); } MessageBox.Show("Save success!"); LoadSetting(); RefeshSettings(); }
private async void LoadData() { var planes = await context.GetPlanes(); var ports = await context.GetPorts(); foreach (var item in ports) { Ports.Add(item); } Destinations.Refresh(); Origins.Refresh(); foreach (var item in planes) { Planes.Add(item); } PlanesView.Refresh(); this.PortFrom = SettingConfiguration.GetIntValue("PortId"); var portTo = ports.Where(O => O.Id != SettingConfiguration.GetIntValue("PortId")).FirstOrDefault(); if (portTo != null) { this.PortTo = portTo.Id; } }
public CustomerInsurance( SettingConfiguration settingConfiguration, ZurichContext dbContext, IMapper mapper) { _settingConfiguration = settingConfiguration; _dbContext = dbContext; _mapper = mapper; }
private void Btn_ResetTotal_Click(object sender, EventArgs e) { SettingConfiguration.F_UpdateKey("PASS", 0.ToString()); Tbx_Pass.Text = Convert.ToDecimal(0).ToString("N0") + " "; SettingConfiguration.F_UpdateKey("NG", 0.ToString()); Tbx_NG.Text = Convert.ToDecimal(0).ToString("N0") + " "; SettingConfiguration.F_UpdateKey("TOTAL", 0.ToString()); Tbx_Total.Text = Convert.ToDecimal(0).ToString("N0") + " "; v_Total = v_Pass = v_NG = 0; }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="settingConfig">The configuration for the setting to emulate.</param> /// <param name="controlConfig">The configuration for the controllers.</param> /// <returns>The newly created instance.</returns> public static Instance CreateInstance(SettingConfiguration settingConfig, ControlConfiguration controlConfig) { Instance instance = new Instance() { SettingConfig = (settingConfig != null) ? settingConfig : new SettingConfiguration(), ControllerConfig = (controlConfig != null) ? controlConfig : new ControlConfiguration(), }; return(instance); }
private void Btn_SavePath_Click(object sender, EventArgs e) { if (Lbl_PathFolderInput.Text.Trim().Trim().Length > 0) { SettingConfiguration.F_UpdateKey("PathInput", Lbl_PathFolderInput.Text.Trim()); } if (Lbl_PathFolderOutput.Text.Trim().Trim().Length > 0) { SettingConfiguration.F_UpdateKey("PathOutput", Lbl_PathFolderOutput.Text.Trim()); } }
private void Button_Click(object sender, RoutedEventArgs e) { var f = new FolderBrowserDialog(); f.SelectedPath = SettingConfiguration.GetStringValue("BackupPath"); f.ShowDialog(); if (f != null && !string.IsNullOrEmpty(f.SelectedPath)) { SettingConfiguration.UpdateKey("BackupPath", f.SelectedPath); vm.DataPath = f.SelectedPath + vm.GetFileName(); } }
/// <summary> /// Generates an instance with the given layout and configuration attached. /// </summary> /// <param name="layoutConfiguration">The layout configuration defining all the instance characteristics.</param> /// <param name="rand">A randomizer that is used during generation.</param> /// <param name="settingConfig">The configuration for the setting to emulate that will be attached for executing the simulation afterwards.</param> /// <param name="controlConfig">The configuration for the controlling mechanisms that will be attached for executing the simulation afterwards.</param> /// <param name="logAction">An optional action for logging.</param> /// <returns>The generated instance.</returns> public static Instance GenerateLayout( LayoutConfiguration layoutConfiguration, IRandomizer rand, SettingConfiguration settingConfig, ControlConfiguration controlConfig, Action <string> logAction = null) { LayoutGenerator layoutGenerator = new LayoutGenerator(layoutConfiguration, rand, settingConfig, controlConfig, logAction); Instance instance = layoutGenerator.GenerateLayout(); InitializeInstance(instance); return(instance); }
private void SaveAction(object obj) { try { SettingConfiguration.UpdateKey("Company", Company); SettingConfiguration.UpdateKey("PortId", PortId.ToString()); SettingConfiguration.UpdateKey("CityId", CityId.ToString()); WindowClose(); } catch (Exception ex) { Helpers.ShowMessage(ex.Message); } }
public BackUpViewModel() { MyTitle = "Backup Data"; this.OnError += BackUpViewModel_OnError; this.OnComplete += BackUpViewModel_OnComplete; TotalData = 100; ProgressValue = 0; var path = SettingConfiguration.GetStringValue("BackupPath"); if (!string.IsNullOrEmpty(path)) { DataPath = path + GetFileName(); } }
private void F_CountModelsChecked(string i_Status) { if (i_Status == "P") { v_Pass = v_Pass + 1; SettingConfiguration.F_UpdateKey("PASS", v_Pass.ToString()); Tbx_Pass.Text = Convert.ToDecimal(v_Pass).ToString("N0") + " "; } else if (i_Status == "F") { v_NG = v_NG + 1; SettingConfiguration.F_UpdateKey("NG", v_NG.ToString()); Tbx_NG.Text = Convert.ToDecimal(v_NG).ToString("N0") + " "; } v_Total = v_Total + 1; SettingConfiguration.F_UpdateKey("TOTAL", v_Total.ToString()); Tbx_Total.Text = Convert.ToDecimal(v_Total).ToString("N0") + " "; }
/// <summary> /// Generates the nano default layout. /// </summary> /// <param name="rand">A randomizer that is used during generation.</param> /// <param name="settingConfig">The configuration for the setting to emulate that will be attached for executing the simulation afterwards.</param> /// <param name="controlConfig">The configuration for the controlling mechanisms that will be attached for executing the simulation afterwards.</param> /// <returns>The generated instance.</returns> public static Instance GenerateMaTiLayoutNano(IRandomizer rand, SettingConfiguration settingConfig, ControlConfiguration controlConfig) { LayoutConfiguration layoutConfiguration = GenerateMaTiLayoutConfiguration(); layoutConfiguration.BotCount = 8; layoutConfiguration.NameLayout = "MaTiNano"; layoutConfiguration.NrHorizontalAisles = 4; layoutConfiguration.NrVerticalAisles = 4; layoutConfiguration.NPickStationWest = 0; layoutConfiguration.NPickStationEast = 2; layoutConfiguration.NPickStationSouth = 0; layoutConfiguration.NPickStationNorth = 0; layoutConfiguration.NReplenishmentStationWest = 2; layoutConfiguration.NReplenishmentStationEast = 0; layoutConfiguration.NReplenishmentStationSouth = 0; layoutConfiguration.NReplenishmentStationNorth = 0; return(GenerateLayout(layoutConfiguration, rand, settingConfig, controlConfig)); }
/// <summary> /// 初始化 /// </summary> public static void Initialize() { SettingConfiguration settings; if (!SettingConfiguration.TryParse(SystemConfigurations.Configuration, out settings)) { settings = new SettingConfiguration(); settings.TransactionTimeout = TimeSpan.Parse("00:00:30"); settings.TransactionCheckInterval = 30000; settings.MaximumConnectionCount = 3; settings.MinimumConnectionCount = 1; settings.ConnectionLoadBalanceStrategy = ConnectionLoadBalanceStrategies.Sequential; } _settings = settings; TransactionTimeout = _settings.TransactionTimeout; TransactionCheckInterval = _settings.TransactionCheckInterval; MaximumConnectionCount = _settings.MaximumConnectionCount; MinimumConnectionCount = _settings.MinimumConnectionCount; ConnectionLoadBalanceStrategy = _settings.ConnectionLoadBalanceStrategy; }
private async void LoadDataCities() { var scheduleBussines = new ScheduleBussines(); var result = await scheduleBussines.GetCities(); var fromid = SettingConfiguration.GetIntValue("CityId"); if (result != null) { foreach (var item in result.Where(O => O.Id != fromid).ToList()) { Cities.Add(item); } } if (Cities.Where(O => O.Id != fromid).Count() == 1) { var city = Cities.FirstOrDefault(); this.ToId = city.Id; } }
private async void SetNew() { Shiper = new customer(); Reciever = new customer(); this.Id = await CodeGenerate.GetNewPTINumber(); this.ActiveStatus = ActivedStatus.OK; this.CreatedDate = DateTime.Now; this.Etc = 0; this.Note = string.Empty; this.PayType = PayType.Chash; this.RecieverId = 0; this.ShiperID = 0; Shiper = new customer(); Reciever = new customer(); this.FromId = SettingConfiguration.GetIntValue("CityId"); Collies.Clear(); SourceView.Refresh(); SumBerat = 0; SumBiaya = 0; SumColly = 0; }
public static void GenerateRepositioningSet3() { Dictionary <bool, StationActivationConfiguration> stationControllers = new Dictionary <bool, StationActivationConfiguration>() { { false, new ActivateAllStationActivationConfiguration() }, { true, new WorkShiftStationActivationConfiguration(new DefaultConstructorIdentificationClass()) }, }; List <Tuple <double, double> > speedUtilityWeights = new List <Tuple <double, double> >() { new Tuple <double, double>(0, 1), new Tuple <double, double>(1, 0), new Tuple <double, double>(1, 1), }; List <Tuple <PodStorageConfiguration, RepositioningConfiguration> > positioningControllers = new List <Tuple <PodStorageConfiguration, RepositioningConfiguration> >() { new Tuple <PodStorageConfiguration, RepositioningConfiguration>( new NearestPodStorageConfiguration(), new UtilityRepositioningConfiguration()), new Tuple <PodStorageConfiguration, RepositioningConfiguration>( new NearestPodStorageConfiguration(), new CacheDropoffRepositioningConfiguration()), new Tuple <PodStorageConfiguration, RepositioningConfiguration>( new UtilityPodStorageConfiguration(), new UtilityRepositioningConfiguration()), new Tuple <PodStorageConfiguration, RepositioningConfiguration>( new CachePodStorageConfiguration(), new CacheDropoffRepositioningConfiguration()), }; List <OrderBatchingConfiguration> orderBatchers = new List <OrderBatchingConfiguration>() { new DefaultOrderBatchingConfiguration() { OrderSelectionRule = Core.Control.Defaults.OrderBatching.DefaultOrderSelection.FCFS, StationSelectionRule = Core.Control.Defaults.OrderBatching.DefaultOutputStationSelection.Random, }, }; List <RepositioningSubExperiment> subExperiments = new List <RepositioningSubExperiment>() { new RepositioningSubExperiment() { NightDown = false, BotsPerOStation = 4, BotAllocation = new Tuple <bool, double, double, double>(false, 1, 3, 0) }, new RepositioningSubExperiment() { NightDown = false, BotsPerOStation = 4, BotAllocation = new Tuple <bool, double, double, double>(true, 1, 2, 1) }, new RepositioningSubExperiment() { NightDown = false, BotsPerOStation = 5, BotAllocation = new Tuple <bool, double, double, double>(true, 1, 3, 1) }, new RepositioningSubExperiment() { NightDown = true, BotsPerOStation = 4, BotAllocation = new Tuple <bool, double, double, double>(true, 1, 3, 0) }, new RepositioningSubExperiment() { NightDown = true, BotsPerOStation = 4, BotAllocation = new Tuple <bool, double, double, double>(false, 1, 3, 0) }, }; int counter = 0; foreach (var subExperiment in subExperiments) { string dir = "SubExp" + (++counter); while (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } foreach (var speedUtilityWeight in speedUtilityWeights) { foreach (var positioningController in positioningControllers) { foreach (var orderBatcher in orderBatchers) { // Prepare setting SettingConfiguration setting = GetRepositioningBaseSetting(); setting.OverrideConfig = new OverrideConfiguration() { OverrideBotCountPerOStation = true, OverrideBotCountPerOStationValue = subExperiment.BotsPerOStation, }; if (subExperiment.NightDown) { setting.InventoryConfiguration.DemandInventoryConfiguration.BundleCount = 0; setting.InventoryConfiguration.SubmitBatches = true; setting.InventoryConfiguration.BatchInventoryConfiguration = new BatchInventoryConfiguration() { MaxTimeForBundleSubmissions = TimeSpan.FromDays(1).TotalSeconds, MaxTimeForOrderSubmissions = TimeSpan.FromDays(1).TotalSeconds, BundleBatches = new List <Skvp <double, double> >() { new Skvp <double, double>() { Key = TimeSpan.FromHours(16).TotalSeconds, Value = 0.75 } }, OrderBatches = new List <Skvp <double, int> >() { new Skvp <double, int>() { Key = TimeSpan.FromHours(22).TotalSeconds, Value = 1500 } }, }; } // Prepare config ControlConfiguration config = new ControlConfiguration() { StationActivationConfig = stationControllers[subExperiment.NightDown], TaskAllocationConfig = new BalancedTaskAllocationConfiguration() { RepositionBeforeRest = subExperiment.BotAllocation.Item1, WeightInputStations = subExperiment.BotAllocation.Item2, WeightOutputStations = subExperiment.BotAllocation.Item3, WeightRepositioning = subExperiment.BotAllocation.Item4, }, OrderBatchingConfig = orderBatcher, PodStorageConfig = positioningController.Item1, RepositioningConfig = positioningController.Item2, }; // Set weights if (config.PodStorageConfig is CachePodStorageConfiguration) { (config.PodStorageConfig as CachePodStorageConfiguration).WeightSpeed = speedUtilityWeight.Item1; (config.PodStorageConfig as CachePodStorageConfiguration).WeightUtility = speedUtilityWeight.Item2; } if (config.PodStorageConfig is UtilityPodStorageConfiguration) { (config.PodStorageConfig as UtilityPodStorageConfiguration).UtilityConfig.WeightSpeed = speedUtilityWeight.Item1; (config.PodStorageConfig as UtilityPodStorageConfiguration).UtilityConfig.WeightUtility = speedUtilityWeight.Item2; } if (config.RepositioningConfig is CacheDropoffRepositioningConfiguration) { (config.RepositioningConfig as CacheDropoffRepositioningConfiguration).WeightSpeed = speedUtilityWeight.Item1; (config.RepositioningConfig as CacheDropoffRepositioningConfiguration).WeightUtility = speedUtilityWeight.Item2; } if (config.RepositioningConfig is UtilityRepositioningConfiguration) { (config.RepositioningConfig as UtilityRepositioningConfiguration).UtilityConfig.WeightSpeed = speedUtilityWeight.Item1; (config.RepositioningConfig as UtilityRepositioningConfiguration).UtilityConfig.WeightUtility = speedUtilityWeight.Item2; } // Name setting setting.Name = "ScenRep-" + (subExperiment.NightDown ? "NightDown" : "NoDown") + "-BPOS" + subExperiment.BotsPerOStation; // Name controller string saTag; if (config.StationActivationConfig is ActivateAllStationActivationConfiguration) { saTag = "A"; } else if (config.StationActivationConfig is WorkShiftStationActivationConfiguration) { saTag = "W"; } else { throw new ArgumentException("Unknown!"); } string psTag; if (config.PodStorageConfig is RandomPodStorageConfiguration) { psTag = "R"; } else if (config.PodStorageConfig is NearestPodStorageConfiguration) { psTag = "N"; } else if (config.PodStorageConfig is CachePodStorageConfiguration) { psTag = "C"; } else if (config.PodStorageConfig is UtilityPodStorageConfiguration) { psTag = "U"; } else { throw new ArgumentException("Unknown!"); } string rpTag; if (config.RepositioningConfig is DummyRepositioningConfiguration) { rpTag = "D"; } else if (config.RepositioningConfig is CacheDropoffRepositioningConfiguration) { rpTag = "C"; } else if (config.RepositioningConfig is UtilityRepositioningConfiguration) { rpTag = "U"; } else { throw new ArgumentException("Unknown!"); } string obTag; if (config.OrderBatchingConfig is QueueOrderBatchingConfiguration) { obTag = "Q"; } else if (config.OrderBatchingConfig is PodMatchingOrderBatchingConfiguration) { obTag = "M"; } else if (config.OrderBatchingConfig is DefaultOrderBatchingConfiguration) { obTag = "D"; } else { throw new ArgumentException("Unknown!"); } config.Name = "PS" + psTag + "-" + "RP" + rpTag + "-" + "SA" + saTag + "-" + "OB" + obTag + "-" + "Bot" + (subExperiment.BotAllocation.Item1 ? "t" : "f") + "I" + subExperiment.BotAllocation.Item2 + "O" + subExperiment.BotAllocation.Item3 + "R" + subExperiment.BotAllocation.Item4 + "-" + "Wei" + speedUtilityWeight.Item1.ToString(IOConstants.EXPORT_FORMAT_SHORTER, IOConstants.FORMATTER) + speedUtilityWeight.Item2.ToString(IOConstants.EXPORT_FORMAT_SHORTER, IOConstants.FORMATTER); // Save it string fileNameController = Path.Combine(dir, config.Name + ".xconf"); Console.WriteLine("Saving " + fileNameController + " ..."); InstanceIO.WriteConfiguration(fileNameController, config); string fileNameSetting = Path.Combine(dir, setting.Name + ".xsett"); Console.WriteLine("Saving " + fileNameSetting + " ..."); InstanceIO.WriteSetting(fileNameSetting, setting); } } } } }
public static void GenerateRotterdamPhase2Settings() { // --> Begin Console.WriteLine("Initializing ..."); Dictionary <string, string> skuFiles = new Dictionary <string, string> { { "Mu-1000.xgenc", "1000" }, { "Mu-10000.xgenc", "10000" }, }; List <int> orderSizeScenarios = new List <int> { 1, 2, 3 }; List <double> returnOrderProbabilities = new List <double> { 0, 0.3 }; //List<int> pickStationCapacities = new List<int> { 6, 12, 18 }; List <double> pickStationCounts = new List <double> { 1.0 / 6.0, 2.0 / 6.0, 3.0 / 6.0, 4.0 / 6.0, 5.0 / 6.0, 6.0 / 6.0, }; //List<double> replStationCounts = new List<double> { 1.0 / 3.0, 2.0 / 3.0, 1.0 }; List <int> botsPerStations = new List <int> { 2, 3, 4, 5, 6 }; // Build all combinations foreach (var botsPerStation in botsPerStations) { foreach (var skuFile in skuFiles) { foreach (var pickStationCount in pickStationCounts) { foreach (var orderSizeScenario in orderSizeScenarios) { foreach (var returnOrderProbability in returnOrderProbabilities) { SettingConfiguration setting = GetRotterdamBaseSetting(); setting.OverrideConfig = new OverrideConfiguration() { OverrideBotCountPerOStation = true, OverrideBotCountPerOStationValue = botsPerStation, OverrideOutputStationCapacity = true, OverrideOutputStationCapacityValue = 8, OverrideInputStationCount = true, OverrideInputStationCountValue = 2.0 / 6.0, OverrideOutputStationCount = true, OverrideOutputStationCountValue = pickStationCount, }; setting.InventoryConfiguration.SimpleItemConfiguration.GeneratorConfigFile = skuFile.Key; switch (orderSizeScenario) { case 1: /* Do nothing - default scenario */ break; case 2: setting.InventoryConfiguration.OrderPositionCountMin = 1; setting.InventoryConfiguration.OrderPositionCountMax = 1; setting.InventoryConfiguration.PositionCountMin = 1; setting.InventoryConfiguration.PositionCountMax = 1; break; case 3: setting.InventoryConfiguration.OrderPositionCountMin = 2; setting.InventoryConfiguration.PositionCountMin = 2; break; default: throw new ArgumentException("Unknown order size scenario: " + orderSizeScenario); } setting.InventoryConfiguration.ReturnOrderProbability = returnOrderProbability; setting.CommentTag1 = "Scen" + "-SKU" + skuFile.Value + "-O" + (orderSizeScenario == 1 ? "M" : (orderSizeScenario == 2 ? "S" : "L")) + "-RO" + (returnOrderProbability > 0 ? "t" : "f"); string name = "MaTi" + "-SKU" + skuFile.Value + "-O" + (orderSizeScenario == 1 ? "M" : (orderSizeScenario == 2 ? "S" : "L")) + "-RO" + (returnOrderProbability > 0 ? "t" : "f") + "-BPOS" + botsPerStation.ToString(IOConstants.EXPORT_FORMAT_SHORTEST_BY_ROUNDING, IOConstants.FORMATTER) + //"-C" + pickStationCapacity.ToString(IOConstants.FORMATTER) + "-P" + pickStationCount.ToString(IOConstants.EXPORT_FORMAT_SHORTER, IOConstants.FORMATTER) + //"-R" + replStationCount.ToString(IOConstants.EXPORT_FORMAT_SHORTER, IOConstants.FORMATTER) + ""; setting.Name = name; string fileName = setting.Name + ".xsett"; Console.WriteLine("Saving " + fileName + " ..."); InstanceIO.WriteSetting(fileName, setting); } } } } } }
/// <summary> /// Writes the setting specification to a file. /// </summary> /// <param name="path">The file.</param> /// <param name="config">The setting specification.</param> public static void WriteSetting(string path, SettingConfiguration config) { // Serialize it using (TextWriter writer = new StreamWriter(path)) _settingConfigSerializer.Serialize(writer, config); }
/// <summary> /// Reads an instance from a file. /// </summary> /// <param name="instancePath">The path to either the instance or a layout configuration.</param> /// <param name="settingConfigPath">The path to the file specifying the setting.</param> /// <param name="controlConfigPath">The path to the file supplying the configuration for all controlling mechanisms.</param> /// <param name="overrideVisualizationAttached">Indicates whether a visualization shall be attached.</param> /// <param name="visualizationOnly">If this is enabled most of the initialization will be skipped.</param> /// <param name="logAction">A action that will be used for logging some lines.</param> /// <returns></returns> public static Instance ReadInstance( string instancePath, string settingConfigPath, string controlConfigPath, bool overrideVisualizationAttached = false, bool visualizationOnly = false, Action <string> logAction = null) { // Test for layout / instance file XmlDocument doc = new XmlDocument(); doc.Load(instancePath); string rootName = doc.SelectSingleNode("/*").Name; bool layoutConfigurationGiven = false; if (rootName == nameof(Instance)) { layoutConfigurationGiven = false; } else if (rootName == nameof(LayoutConfiguration)) { layoutConfigurationGiven = true; } else { throw new ArgumentException("No valid instance or layout file given!"); } logAction?.Invoke(rootName + " recognized!"); // --> Read configurations SettingConfiguration settingConfig = null; ControlConfiguration controlConfig = null; LayoutConfiguration layoutConfig = null; if (!visualizationOnly) { // Read the setting configuration logAction?.Invoke("Parsing setting config ..."); using (StreamReader sr = new StreamReader(settingConfigPath)) { // Deserialize the xml-file settingConfig = (SettingConfiguration)_settingConfigSerializer.Deserialize(sr); // If it contains a path to a word-file that is not leading to a wordlist file try the default wordlist locations if (settingConfig.InventoryConfiguration.ColoredWordConfiguration != null && !File.Exists(settingConfig.InventoryConfiguration.ColoredWordConfiguration.WordFile)) { settingConfig.InventoryConfiguration.ColoredWordConfiguration.WordFile = IOHelper.FindResourceFile(settingConfig.InventoryConfiguration.ColoredWordConfiguration.WordFile, instancePath); } // If it contains a path to an order-file that is not leading to a orderlist file try the default orderlist locations if (settingConfig.InventoryConfiguration.FixedInventoryConfiguration != null && !string.IsNullOrWhiteSpace(settingConfig.InventoryConfiguration.FixedInventoryConfiguration.OrderFile) && !File.Exists(settingConfig.InventoryConfiguration.FixedInventoryConfiguration.OrderFile)) { settingConfig.InventoryConfiguration.FixedInventoryConfiguration.OrderFile = IOHelper.FindResourceFile(settingConfig.InventoryConfiguration.FixedInventoryConfiguration.OrderFile, instancePath); } // If it contains a path to an simple-item-file that is not leading to a generator config file try the default locations if (settingConfig.InventoryConfiguration.SimpleItemConfiguration != null && !string.IsNullOrWhiteSpace(settingConfig.InventoryConfiguration.SimpleItemConfiguration.GeneratorConfigFile) && !File.Exists(settingConfig.InventoryConfiguration.SimpleItemConfiguration.GeneratorConfigFile)) { settingConfig.InventoryConfiguration.SimpleItemConfiguration.GeneratorConfigFile = IOHelper.FindResourceFile(settingConfig.InventoryConfiguration.SimpleItemConfiguration.GeneratorConfigFile, instancePath); } } // Read the control configuration logAction?.Invoke("Parsing control config ..."); using (StreamReader sr = new StreamReader(controlConfigPath)) // Deserialize the xml-file controlConfig = (ControlConfiguration)_controlConfigSerializer.Deserialize(sr); } // --> Init or generate instance Instance instance = null; if (layoutConfigurationGiven) { // Read the layout configuration logAction?.Invoke("Parsing layout config ..."); using (StreamReader sr = new StreamReader(instancePath)) // Deserialize the xml-file layoutConfig = (LayoutConfiguration)_layoutConfigSerializer.Deserialize(sr); // Apply override config, if available if (settingConfig != null && settingConfig.OverrideConfig != null) { layoutConfig.ApplyOverrideConfig(settingConfig.OverrideConfig); } // Generate instance logAction?.Invoke("Generating instance..."); instance = InstanceGenerator.GenerateLayout(layoutConfig, new RandomizerSimple(0), settingConfig, controlConfig, logAction); } else { // Init the instance object instance = new Instance(); } // Check whether the config is required if (!visualizationOnly) { // Submit config first to the instance object instance.SettingConfig = settingConfig; instance.ControllerConfig = controlConfig; } else { // Add default config (none required though) instance.SettingConfig = new SettingConfiguration(); instance.SettingConfig.VisualizationOnly = true; instance.ControllerConfig = new ControlConfiguration(); } // If a visualization is already present set it to true instance.SettingConfig.VisualizationAttached = overrideVisualizationAttached; // --> Parse the instance from a file, if no layout was given but a specific instance if (!layoutConfigurationGiven) { // Read the instance logAction?.Invoke("Parsing instance ..."); using (StreamReader sr = new StreamReader(instancePath)) { // Deserialize the xml-file DTOInstance dtoInstance = (DTOInstance)_instanceSerializer.Deserialize(sr); // Submit the data to an instance object dtoInstance.Submit(instance); } } // Return it return(instance); }
public static void TestInputTranslationTimeDependentPoisson() { SettingConfiguration config = new SettingConfiguration(); config.InventoryConfiguration.PoissonInventoryConfiguration = new PoissonInventoryConfiguration(new DefaultConstructorIdentificationClass()); IRandomizer randomizer = new RandomizerSimple(0); int oStationCount = 3; int iStationCount = 3; // --> Instantiate poisson generator for orders // Calculate instance-specific factor to adapt the rates List <KeyValuePair <double, double> > relativeOrderWeights = new List <KeyValuePair <double, double> >(); for (int i = 0; i < config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentOrderWeights.Count; i++) { relativeOrderWeights.Add(new KeyValuePair <double, double>( i > 0 ? config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentOrderWeights[i].Key - config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentOrderWeights[i - 1].Key : config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentOrderWeights[i].Key, config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentOrderWeights[i].Value )); } double unadjustedAverageOrderFrequency = relativeOrderWeights.Sum(w => w.Key * w.Value) / config.InventoryConfiguration.PoissonInventoryConfiguration.MaxTimeForTimeDependentOrderRates; double aimedAverageOrderFrequency = TimeSpan.FromSeconds(config.InventoryConfiguration.PoissonInventoryConfiguration.MaxTimeForTimeDependentOrderRates).TotalHours * config.InventoryConfiguration.PoissonInventoryConfiguration.AverageOrdersPerHourAndStation *oStationCount / config.InventoryConfiguration.PoissonInventoryConfiguration.MaxTimeForTimeDependentOrderRates; double orderSteerFactor = aimedAverageOrderFrequency / unadjustedAverageOrderFrequency; // Initiate order poisson generator PoissonGenerator TimeDependentOrderPoissonGenerator = new PoissonGenerator( randomizer, config.InventoryConfiguration.PoissonInventoryConfiguration.MaxTimeForTimeDependentOrderRates, config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentOrderWeights.Select(w => new KeyValuePair <double, double>(w.Key, orderSteerFactor * w.Value))); // --> Instantiate poisson generator for bundles // Calculate instance-specific factor to adapt the rates List <KeyValuePair <double, double> > relativeBundleWeights = new List <KeyValuePair <double, double> >(); for (int i = 0; i < config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentBundleWeights.Count; i++) { relativeBundleWeights.Add(new KeyValuePair <double, double>( i > 0 ? config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentBundleWeights[i].Key - config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentBundleWeights[i - 1].Key : config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentBundleWeights[i].Key, config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentBundleWeights[i].Value )); } double unadjustedAverageBundleFrequency = relativeBundleWeights.Sum(w => w.Key * w.Value) / config.InventoryConfiguration.PoissonInventoryConfiguration.MaxTimeForTimeDependentBundleRates; double aimedAverageBundleFrequency = TimeSpan.FromSeconds(config.InventoryConfiguration.PoissonInventoryConfiguration.MaxTimeForTimeDependentBundleRates).TotalHours * config.InventoryConfiguration.PoissonInventoryConfiguration.AverageBundlesPerHourAndStation *iStationCount / config.InventoryConfiguration.PoissonInventoryConfiguration.MaxTimeForTimeDependentBundleRates; double bundleSteerFactor = aimedAverageBundleFrequency / unadjustedAverageBundleFrequency; // Initiate bundle poisson generator PoissonGenerator TimeDependentBundlePoissonGenerator = new PoissonGenerator( randomizer, config.InventoryConfiguration.PoissonInventoryConfiguration.MaxTimeForTimeDependentBundleRates, config.InventoryConfiguration.PoissonInventoryConfiguration.TimeDependentBundleWeights.Select(w => new KeyValuePair <double, double>(w.Key, bundleSteerFactor * w.Value))); // Initiate time-independent order poisson generator double orderRate = PoissonGenerator.TranslateIntoRateParameter( TimeSpan.FromHours(1), config.InventoryConfiguration.PoissonInventoryConfiguration.AverageOrdersPerHourAndStation * oStationCount); PoissonGenerator TimeIndependentOrderPoissonGenerator = new PoissonGenerator(randomizer, orderRate); // Initiate time-independent bundle poisson generator double bundleRate = PoissonGenerator.TranslateIntoRateParameter( TimeSpan.FromHours(1), config.InventoryConfiguration.PoissonInventoryConfiguration.AverageBundlesPerHourAndStation * iStationCount); PoissonGenerator TimeIndependentBundlePoissonGenerator = new PoissonGenerator(randomizer, bundleRate); // --> Test int simulationHours = 2 * 24; double simulationTime = simulationHours * 60 * 60; double currentTime = 0; List <double> timeDependentBundleSteps = new List <double>(); while (currentTime < simulationTime) { currentTime += TimeDependentBundlePoissonGenerator.Next(currentTime); timeDependentBundleSteps.Add(currentTime); } currentTime = 0; List <double> timeDependentOrderSteps = new List <double>(); while (currentTime < simulationTime) { currentTime += TimeDependentOrderPoissonGenerator.Next(currentTime); timeDependentOrderSteps.Add(currentTime); } currentTime = 0; List <double> timeIndependentBundleSteps = new List <double>(); while (currentTime < simulationTime) { currentTime += TimeIndependentBundlePoissonGenerator.Next(currentTime); timeIndependentBundleSteps.Add(currentTime); } currentTime = 0; List <double> timeIndependentOrderSteps = new List <double>(); while (currentTime < simulationTime) { currentTime += TimeIndependentOrderPoissonGenerator.Next(currentTime); timeIndependentOrderSteps.Add(currentTime); } // Output graph WriteHourBasedGraph( new List <List <double> >() { timeDependentBundleSteps, timeDependentOrderSteps, timeIndependentBundleSteps, timeIndependentOrderSteps }, new List <string>() { "Bundles (time-dependent)", "Orders (time-dependent)", "Bundles (time-independent)", "Orders (time-independent)" }, simulationHours); }