Esempio n. 1
0
        public void Initialise(OptimiserParameters parameters, IList<BaseChromosomeType> chromosomeTypes)
        {
            _validatorFactory = new GeneValidatorFactory(chromosomeTypes);

            generationsSpin.Value = parameters.MaximumGenerations;
            populationSizeSpin.Value = parameters.PopulationSize;
            reproductionPercentSpin.Value = (decimal) (parameters.ReproductionRate * 100);
            mutationRateSpin.Value = (decimal) (parameters.MutationRate * 100);

            screenThresholdSpin.Value = (decimal) parameters.ScreeningThreshold;
            saveLogCheckbox.Checked = parameters.ExportGenes;

            var wrappers = GetOptimisationTypeWrappers();

            fitnessFunctionComboBox.DisplayMember = "Name";
            fitnessFunctionComboBox.ValueMember = "Type";
            fitnessFunctionComboBox.DataSource = wrappers;

            try
            {
                foreach (var wrapper in wrappers)
                {
                    if (wrapper.Type.AssemblyQualifiedName == parameters.FitnessFunctionType)
                    {
                        fitnessFunctionComboBox.SelectedItem = wrapper;
                        break;
                    }
                }
            }
            catch
            {
            }

            minimumTradesSpin.Value = parameters.MinimumTrades;

            strategyParameterConditionsGrid.Rows.Clear();

            foreach (var condition in parameters.ParameterConditions)
            {
                if (IsConditionValid(condition))
                {
                    var row = strategyParameterConditionsGrid.Rows[strategyParameterConditionsGrid.Rows.Add()];
                    row.SetValues(condition);
                }
            }
        }
Esempio n. 2
0
        private IGeneValidator GetGeneValidator(IList<BaseChromosomeType> chromosomeTypes,
                                                IEnumerable<string> parameterConditions)
        {
            var validatorFactory = new GeneValidatorFactory(chromosomeTypes);
            var validators = new List<IGeneValidator>();

            foreach (var condition in parameterConditions)
            {
                validators.Add(validatorFactory.GetGeneValidator(condition));
            }

            return new CompositeGeneValidator(validators.ToArray());
        }