public MainWindow()
        {
            InitializeComponent();
            headToHead = false;
            Width      = 580;
            //toggleColorBtn.Margin = new Thickness(422, 14, 0, 0); //new Thickness(62, 10, 0, 0);
            //dataGenerationBtn.Margin = new Thickness(24, 14, 0, 0); //new Thickness(182, 10, 0, 0);
            //metricsBtn.Margin = new Thickness(146, 14, 0, 0); //new Thickness(302, 10, 0, 0);
            //runSlmBtn.Margin = new Thickness(266, 14, 0, 0); //new Thickness(422, 10, 0, 0);

            rectHeadToHeadDivider.Visibility = Visibility.Hidden;

            planogramTensorflow.Visibility = Visibility.Hidden;


            tensorFlowPlanogramScore.Visibility = Visibility.Hidden;
            GrdTensorFlowsetting.Visibility     = Visibility.Hidden;
            grpBox_Tensorflow.Visibility        = Visibility.Hidden;

            FillGrid(planogram, Colors.LightGray);
            //For testing only
            string dbIdentifier = "RLV_small";

            // instantiate visualizer with this window as its parent reference
            visualizer = new RLVOutputVisualizer(this);
            core       = new RLVCore(dbIdentifier);

            //core.SetupVisualizer(new List<IRLVPanel>
            //{
            //    detailsPanel,
            //    chartPanel
            //}, visualizer);

            //this.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml") });
            //this.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml") });
            //this.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml") });
            //this.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml") });
            //this.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml") });
        }
Ejemplo n.º 2
0
        private void runSlmBtn_Click(object sender, RoutedEventArgs e)
        {
            selectedSlotIndex = -1;
            _row    = -1;
            _col    = -1;
            itemRow = -1;
            itemCol = -1;

            SimulationPanel simPanel = new SimulationPanel();

            simPanel.SetSimSettings(simSettings);
            bool?result = simPanel.ShowDialog();

            if (result.HasValue && result.Value == true)
            {
                // resets grid to default
                usePerfColor = false;
                FillGrid(planogram, Colors.LightGray);
                if (headToHead)
                {
                    FillGrid(planogramTensorflow, Colors.LightGray);
                }

                // disable control buttons
                //statusTxt.Text = statusTxtTensor.Text = "";
                statusTxtTensor.Text = "Waiting for RLM to finish running...";
                EnableControlButtons(false);

                // set simulation settings
                simSettings.SimType                = simPanel.SimType;
                simSettings.Sessions               = simPanel.Sessions;
                simSettings.Hours                  = simPanel.Hours;
                simSettings.Score                  = simPanel.Score;
                simSettings.EnableSimDisplay       = simPanel.EnableSimDisplay;
                simSettings.DefaultScorePercentage = simPanel.simScoreSlider.Value;
                simSettings.HiddenLayers           = simPanel.HiddenLayers;
                simSettings.HiddenLayerNeurons     = simPanel.HiddenLayerNeurons;

                targetScoreTxt.Text = "";
                if (simSettings.SimType == SimulationType.Score)
                {
                    targetScoreLbl.Visibility  = Visibility.Visible;
                    targetScoreTxt.Visibility  = Visibility.Visible;
                    targetScoreTxt.Text        = simSettings.Score.Value.ToString("n");
                    targetScoreTxt2.Visibility = Visibility.Visible;
                    targetScoreTxt2.Text       = simSettings.Score.Value.ToString("n");
                }
                else
                {
                    targetScoreLbl.Visibility  = Visibility.Hidden;
                    targetScoreTxt.Visibility  = Visibility.Hidden;
                    targetScoreTxt2.Visibility = Visibility.Hidden;
                }

                if (simSettings.SimType == SimulationType.Sessions)
                {
                    sessionPerBatchLbl.Visibility = Visibility.Hidden;
                    sessionPerBatchTxt.Visibility = Visibility.Hidden;
                }
                else
                {
                    sessionPerBatchLbl.Visibility = Visibility.Visible;
                    sessionPerBatchTxt.Visibility = Visibility.Visible;
                }

                Logger.Clear();


                string dbIdentifier = "RLM_planogram_" + Guid.NewGuid().ToString("N");
                // instantiate visualizer with this window as its parent reference
                visualizer = new RLVOutputVisualizer(this);
                core       = new RLVCore(dbIdentifier);

                // subscribe mainwindow to the comparison event
                //visualizer.LearningComparisonDisplayResultsEvent += DisplayLearningComparisonResults;

                // open temporary RLV container panel
                // todo this must be embeded in this Window instead of the temporary container
                if (rlvPanel != null)
                {
                    rlvPanel.Close();
                }

                rlvPanel = new TempRLVContainerPanel(core, visualizer);

                //this.Top = 20;
                //tmpPanel.Top = this.Top;
                //this.Height = tmpPanel.Height;
                //tmpPanel.Left = 10;
                //this.Left = tmpPanel.Width + tmpPanel.Left;
                //tmpPanel.Visibility = Visibility.Hidden;

                Task.Run(() =>
                {
                    // get items from db as well as the min and max metric scores as we need that for the calculation later on
                    Item[] items;
                    using (PlanogramContext ctx = new PlanogramContext())
                    {
                        MockData mock             = new MockData(ctx);
                        items                     = itemsCache = mock.GetItemsWithAttr();
                        simSettings.ItemMetricMin = mock.GetItemMinimumScore(simSettings);
                        simSettings.ItemMetricMax = mock.GetItemMaximumScore(simSettings);
                    }

                    // let's tensorflow (or other listeners) know that it should start training
                    //OnSimulationStart?.Invoke(items, simSettings); //return;

                    // initialize and start RLM training
                    optimizer = new PlanogramOptimizer(items, simSettings, this.UpdateRLMResults, this.UpdateRLMStatus, Logger, dbIdentifier);
                    //optimizer.OnSessionDone += Optimizer_OnSessionDone;
                    optimizer.StartOptimization(tokenSource.Token);
                });
            }
        }