示例#1
0
        private void UpdateRLMStatus(string statusMsg, bool isDone = false)
        {
            if (tokenSource.IsCancellationRequested)
            {
                return;
            }

            Dispatcher.Invoke(() =>
            {
                statusTxt.Text = statusMsg;
                isRLMDone      = isDone;

                if (headToHead)
                {
                    if (isRLMDone)
                    {
                        bool optimizeEncog = rdbEncog.IsChecked.HasValue && rdbEncog.IsChecked.Value;

                        Task.Run(() => {
                            //Item[] items;
                            //using (PlanogramContext ctx = new PlanogramContext())
                            //{
                            //    MockData mock = new MockData(ctx);
                            //    items = mock.GetItemsWithAttr();
                            //    simSettings.ItemMetricMin = mock.GetItemMinimumScore(simSettings);
                            //    simSettings.ItemMetricMax = mock.GetItemMaximumScore(simSettings);
                            //}

                            if (optimizeEncog)
                            {
                                var encogOpt = new PlanogramOptimizerEncog(itemsCache, simSettings, UpdateTensorflowResults, UpdateTensorflowStatus, Logger, true);
                                encogOpt.StartOptimization(tokenSource.Token);
                            }
                            else
                            {
                                // let's tensorflow (or other listeners) know that it should start training
                                OnSimulationStart?.Invoke(itemsCache, simSettings, tokenSource.Token);
                            }
                        });

                        if (isTensorflowDone)
                        {
                            EnableControlButtons(true);
                        }
                    }
                }
                else
                {
                    if (isRLMDone)
                    {
                        EnableControlButtons(true);
                    }
                }
            });
        }
        public void Start()
        {
            OnSimulationStart?.Invoke();
            GameMode?.EmitSimulationStart(this);

            _state = SimulationState.Running;

            Thread t = new Thread(Simulate)
            {
                Name         = "Simulation",
                IsBackground = true
            };

            t.Start();
        }
示例#3
0
        private static void StartSimulation()
        {
            //if (!SimulationRun)
            {
                //GameTimer = new Timer(GameTimerTick, null, new TimeSpan(0, 0, 0), GameCycleSpan);
                //coins = StartCoins;
                //Util.ConnectionToServer.SendDataToServer("Start simulation");
                Statistic = new SimulationInfo();
                Coins     = 0;
                Util.ConnectionToServer.SendSimulationStatus(SimulationRun);
                ChangeCoinsUp(Settings.StartCoins);
                PastTime = TimeHour = TimeDay = TimeMonth = 0;
                GameThread?.Abort();
                GameThread          = new Thread(GameThreadFunc);
                GameThread.Priority = ThreadPriority.Lowest;
                GameThread.Start();

                OnSimulationStart?.Invoke();
                Tools.Message(MessageStatus.Info, Localization.GetText("Text13"));
            }
        }
        private void UpdateRLMStatus(string statusMsg, bool isDone = false)
        {
            Dispatcher.Invoke(() =>
            {
                statusTxt.Text = statusMsg;
                isRLMDone      = isDone;

                if (headToHead)
                {
                    if (isRLMDone)
                    {
                        Task.Run(() => {
                            Item[] items;
                            using (PlanogramContext ctx = new PlanogramContext())
                            {
                                MockData mock             = new MockData(ctx);
                                items                     = 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);
                        });

                        if (isTensorflowDone)
                        {
                            EnableControlButtons(true);
                        }
                    }
                }
                else
                {
                    if (isRLMDone)
                    {
                        EnableControlButtons(true);
                    }
                }
            });
        }