/// <summary> /// Initializes a new instance of the BacktestFitness class. /// </summary> /// <param name="indicatorLibraryAdapter">The indicator library adapter to run the backtest with.</param> public BacktestFitness(TestData indicatorLibraryAdapter, Dictionary <DateTime, Dictionary <string, double> > ILA, List <DateTime> error, FitnessTest fitTest) { this.indicatorLibraryAdapter = indicatorLibraryAdapter; this.ILA = ILA; this.error = error; this.fit = fitTest; }
public virtual FitnessTest CreateTest(ITestParameters parameters) { var singleTest = new FitnessTest(this.Scenario, parameters); singleTest.Reset(); return(singleTest); }
public SimulationDisplayForm(FitnessTest test, bool limitedUser) : base(test) { //allow for keys detection when not recording this.KeyPreview = true; this.limitedUser = limitedUser; this.InitializeComponent(); }
public virtual TestMeasure CreateTestMeasure(FitnessTest test) { return(new TestMeasure { ID = test.TestName, Parameters = test.TestParameters, Quantity = test.SimulationScoreAvg?.Clone(), Value = test.FinalScores.Mean, StdDev = test.FinalScores.StdDev }); }
protected override void RunConsoleApplication(FitnessTest test) { //also shows progress form using (new ProgressFormUpdater(test) { Visible = this.TestsConfig.GraphicsEnabled, Text = test.TestName }) { base.RunConsoleApplication(test); } }
protected virtual void RunFormApplication(int cellSize, bool limitedUser, FitnessTest test) { //creates form application var simulationForm = this.CreateSimulationForm(test, limitedUser); simulationForm.Text = test.TestName; simulationForm.CellSize = cellSize; //runs player form application simulationForm.Init(); simulationForm.PauseResumeSimulation(); Application.Run((Form)simulationForm); }
private void PrepareTest(FitnessTest test) { test.LogStatistics = this.TestsConfig.GraphicsEnabled; if (!this.TestsConfig.GraphicsEnabled) { return; } //initiates log and writes all properties to file PathUtil.CreateOrClearDirectory(test.FilePath); test.LogWriter = new LogWriter($"{test.FilePath}{Path.DirectorySeparatorChar}test.log"); test.WriteProperties(); }
private void PrintTestMeasure(FitnessTest test) { //creates and prints test measure var testMeasure = this.DefaultTestFactory.CreateTestMeasure(test); var testMeasuresFilePath = Path.GetFullPath( string.Format("{0}{1}..{1}{2}.csv", test.FilePath, Path.DirectorySeparatorChar, this.TestsConfig.TestMeasuresName)); if (!File.Exists(testMeasuresFilePath)) { ExclusiveFileWriter.AppendLine(testMeasuresFilePath, ArrayUtil.ToString(testMeasure.Header)); } ExclusiveFileWriter.AppendLine(testMeasuresFilePath, ArrayUtil.ToString(testMeasure.ToValue())); }
protected virtual void FinishSingleTest(FitnessTest test) { lock (this.locker) { //test.PrintResults(); //removes test from current list this.currentTests.Remove(test); //gets test measure and replaces on the measures list var testMeasure = this.OptimizationTestFactory.CreateTestMeasure(test); this.TestMeasures.Remove(test.TestParameters); this.TestMeasures.Add(test.TestParameters, testMeasure); this.WriteLine($"{test.TestName}: {testMeasure.Value:0.00}±{testMeasure.StdDev:0.00}"); } }
protected virtual void RunConsoleApplication(FitnessTest test) { //runs test Console.WriteLine(@"----------------------------------------------"); Console.WriteLine(@"Starting test {0}...", test.TestName); test.Run(); if (this.TestsConfig.GraphicsEnabled) { //prints results Console.WriteLine(@"----------------------------------------------"); Console.WriteLine(@"Printng test results..."); test.PrintResults(); } Console.WriteLine(@"----------------------------------------------"); Console.WriteLine(@"Test has finished!"); }
protected override void RunSimulation(FitnessTest test) { //tests execution only on console if (this.ForceConsole || !this.TestsConfig.GraphicsEnabled) { this.RunConsoleApplication(test); return; } //shows menu InitApplication(); using (var chooseForm = new ChooseOptionForm(new List <string> { OPTION_CONSOLE, OPTION_FORM }) { Text = OPTIONS_FORM_TITLE + test.TestName }) { chooseForm.Show(); while (!chooseForm.IsDisposed) { Application.DoEvents(); } switch (chooseForm.ChosenOption) { case OPTION_FORM: this.RunFormApplication(this.TestsConfig.CellSize, false, test); break; case OPTION_CONSOLE: this.RunConsoleApplication(test); break; default: this.RunFormApplication(this.TestsConfig.CellSize, true, test); break; } } }
public override TestMeasure CreateTestMeasure(FitnessTest test) { if (test == null) { return(new GPTestMeasure()); } var chromosome = (IECChromosome)test.TestParameters; //creates new chromosome test measure return(new GPTestMeasure { ID = test.TestName, Parameters = chromosome, Quantity = test.SimulationScoreAvg, Value = test.FinalScores.Mean, StdDev = test.FinalScores.StdDev, TranslatedExpression = this.GetTranslatedExpression(test), TimesGenerated = 1, GenerationNumber = chromosome.Population == null ? -1 : chromosome.Population.GenerationNumber }); }
private void RunGAButton_Click(object sender, EventArgs e) { this.progressBar2.Value = 0; this.bestResults.Clear(); this.generationalBest.Clear(); if (TDD != null) { this.Cursor = Cursors.WaitCursor; this.StopGA.Enabled = true; //BackgroundWorker BGWkr = new BackgroundWorker(); //DoWorkEventArgs eve = new DoWorkEventArgs(sender); //this.testData.Restart(); TradeCondition newBCond = new TradeCondition(); IndicatorHelper list = new IndicatorHelper(this.testData.IndicatorLocations.Keys.ToArray <string>()); IGeneticMutating mutant = new TradeConditionMutation((double)this.MutationRate.Value, list); TradeSystem newSys = new TradeSystem(newBCond); TradeSystemChromosome newchromosome = new TradeSystemChromosome(newSys, list, (int)this.ChromosomeSize.Value); IGeneticBreeding newBreed = new RandomMultipleSplitBreeding(); FitnessTest fitTest = new FitnessTest((int)ThresholdValue.Value, (string)timeRange.SelectedValue); IGeneticFitness newFitness = new BacktestFitness(this.testData, TDD, errorData, fitTest); this.geneticAlgorithm = new GeneticAlgorithm((int)this.Chromosomes.Value, (int)this.NoGenerations.Value, (int)this.ChromosomeSize.Value, newSys, list, newBreed, mutant, newFitness); this.backgroundWorkerRunGA.RunWorkerAsync(this.geneticAlgorithm); } }
protected SimulationForm(FitnessTest test) { this.test = test; this.simControlForm = new SimulationControlForm(this); this.InitTimer(); }
protected override void PrepareSingleTest(FitnessTest test) { base.PrepareSingleTest(test); lock (this.locker) test.LogStatistics = this.TestsConfig.GraphicsEnabled; }
protected override ISimulationForm CreateSimulationForm(FitnessTest test, bool limitedUser) { return(test.Scenario is PacmanScenario ? new PacmanLightSimForm(test) : base.CreateSimulationForm(test, limitedUser)); }
protected virtual void RunSimulation(FitnessTest test) { //just run test on console this.RunConsoleApplication(test); }
public SimulationDisplayForm(FitnessTest test) : this(test, false) { }
protected virtual void PrepareSingleTest(FitnessTest test) { //this.WriteLine(string.Format(@"Initiating: {0}", test.TestName)); lock (this.locker) this.currentTests.Add(test); }
public async Task DeleteAsync(FitnessTest fitness) { await _repository.DeleteAsync(fitness); }
public async Task UpdateAsync(FitnessTest fitness) { await _repository.UpdateAsync(fitness); }
public async Task <int> InsertAsync(FitnessTest fitnessTest) { await _repository.AddAsync(fitnessTest); return(fitnessTest.FitnessTestID); }
public PacmanLightSimForm(FitnessTest test) : base(test, false) { this.InitializeComponent(); }
protected virtual ISimulationForm CreateSimulationForm(FitnessTest test, bool limitedUser) { return(new SimulationDisplayForm(test, limitedUser)); }