protected override string FormatOptimizerParameters(AOptimizer <double> optimizer)
        {
            String parametry = "";

            if (optimizer.GetType() == typeof(CMAES))
            {
                parametry += "None";
            }
            else if (optimizer.GetType() == typeof(RealES11Scouting))
            {
                parametry += "Scouting" + ", " +
                             ((RealES11Scouting)optimizer).nScouts.ToString() + ", " +
                             ((RealES11Scouting)optimizer).scoutingMultiplier.ToString();
            }
            else if (optimizer.GetType() == typeof(RealEvolutionStrategy11))
            {
                if (((RealEvolutionStrategy11)optimizer).mutationAdaptation.GetType() == typeof(RealOneFifthRuleMutationES11Adaptation))
                {
                    parametry += "OneFifthRule" + ", " +
                                 ((RealOneFifthRuleMutationES11Adaptation)((RealEvolutionStrategy11)optimizer).mutationAdaptation).archiveSize.ToString() + ", " +
                                 ((RealOneFifthRuleMutationES11Adaptation)((RealEvolutionStrategy11)optimizer).mutationAdaptation).modifier.ToString();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            else
            {
                throw new NotImplementedException();
            }
            return(parametry);
        }
        protected String FormatSave(AOptimizer <E> optimizer)
        {
            if (!optimizer.divergenceException)
            {
                String optimizerName       = optimizer.GetType().Name;
                String optimizerParameters = FormatOptimizerParameters(optimizer);
                String optimizerResult     = FormatOptimizationResult(optimizer.Result);
                String problemParameters   = FormatProblemParameters(optimizer.Evaluation);

                return(optimizerName + ", " +
                       optimizerParameters + ", " +
                       problemParameters + ", " +
                       optimizerResult);
            }
            else
            {
                String optimizerName       = optimizer.GetType().Name;
                String optimizerParameters = FormatOptimizerParameters(optimizer);
                String problemParameters   = FormatProblemParameters(optimizer.Evaluation);

                return(optimizerName + ", " +
                       optimizerParameters + ", " +
                       problemParameters + ", " +
                       "diverged");
            }
        }
Пример #3
0
        protected override string FormatOptimizerParameters(AOptimizer <double> optimizer)
        {
            if (optimizer.GetType() == typeof(RealEvolutionStrategy11))
            {
                var    ma        = ((RealEvolutionStrategy11)optimizer).mutationAdaptation;
                String MaName    = ma.GetType().Name;
                String parametry = "";

                // C# 7 switch z sprawdzeniem klas
                switch (ma)
                {
                case RealIgnitingSimAnnMutationAdaptation irsa:
                    parametry += irsa.ignitingCoefficient.ToString() + ", ";
                    parametry += irsa.temperatureDropCoef.ToString() + ", ";
                    parametry += irsa.startingTemperature.ToString();
                    break;

                case RealSimulatedAnnealingMutationAdaptation rsa:
                    parametry += rsa.temperatureDropCoef.ToString() + ", ";
                    parametry += rsa.startingTemperature.ToString();
                    break;

                case RealNullRealMutationES11Adaptation rn:
                    parametry += "None";
                    break;

                default:
                    throw new NotImplementedException();
                }
                return(MaName + ", " + parametry);
            }
            else
            {
                throw new NotImplementedException();
            }
        }