Exemplo n.º 1
0
        private ICandidateFactory <MpiSysConfig> CreatePopulationInitialiser(
            IClonableObjectiveEvaluator <MpiSysConfig> objectiveEvaluator,
            MpiSysConfig templateParameterSet,
            MpiSysConfig[] seedsPopulation,
            string initialisationOption = "")
        {
            Log.Debug("Root: creating population initialiser");
            var options = initialisationOption.Split(':');
            var seeds   = new List <MpiSysConfig> {
                templateParameterSet
            };

            if (seedsPopulation != null)
            {
                seeds.AddRange(seedsPopulation);
            }
            var rng = new BasicRngFactory(SceParameterDefinition.RandomizationSeed);

            ICandidateFactory <MpiSysConfig> result = CreatePopulationInitialiser(
                templateParameterSet,
                rng,
                objectiveEvaluator,
                options);

            if (result is BestOfSampling <MpiSysConfig> )
            {
                return(result);
            }
            else
            {
                return(new SeededSamplingFactory <MpiSysConfig>(result, seeds));
            }
        }
Exemplo n.º 2
0
        private ShuffledComplexEvolution <MpiSysConfig> CreateShuffledComplexEvolution(
            IClonableObjectiveEvaluator <MpiSysConfig> objectiveEvaluator,
            IDictionary <string, string> dict,
            ICandidateFactory <MpiSysConfig> populationInitializer,
            ILoggerMh logger)
        {
            Log.Debug("Root: creating SCE optimiser");
            ShuffledComplexEvolution <MpiSysConfig> optimEngine = new ShuffledComplexEvolution <MpiSysConfig>(
                objectiveEvaluator,
                populationInitializer,
                CreateTerminationCriterion(),
                SceParameterDefinition.Parameters.P,
                SceParameterDefinition.Parameters.M,
                SceParameterDefinition.Parameters.Q,
                SceParameterDefinition.Parameters.Alpha,
                SceParameterDefinition.Parameters.Beta,
                SceParameterDefinition.Parameters.NumShuffle,
                new BasicRngFactory(SceParameterDefinition.RandomizationSeed + 1000),
                new DefaultFitnessAssignment(),
                dict,
                trapezoidalPdfParam: SceParameterDefinition.Parameters.TrapezoidalDensityParameter,
                options: sceOptions,
                pmin: SceParameterDefinition.Parameters.Pmin)
            {
                Logger = logger
            };

            return(optimEngine);
        }
Exemplo n.º 3
0
        public BestOfSampling(ICandidateFactory <TSysConfig> innerSamplingFactory, int poolSize, int bestPoints,
                              IObjectiveEvaluator <TSysConfig> evaluator, IFitnessAssignment <double> fitAssignment = null)
        {
            if (fitAssignment == null)
            {
                fitAssignment = new DefaultFitnessAssignment();
            }
            if (poolSize < bestPoints)
            {
                throw new ArgumentOutOfRangeException("poolSize", poolSize, String.Format("poolSize must be >= bestPoints({0})", bestPoints));
            }
            this.HcFactory            = (IHyperCubeOperationsFactory)innerSamplingFactory;
            this.innerSamplingFactory = innerSamplingFactory;
            var tmp = new IObjectiveScores[poolSize];

            for (int i = 0; i < poolSize; i++)
            {
                tmp[i] = evaluator.EvaluateScore(innerSamplingFactory.CreateRandomCandidate());
            }
            var points = fitAssignment.AssignFitness(tmp);

            Array.Sort(points);
            candidates = new FitnessAssignedScores <double> [bestPoints];
            for (int i = 0; i < bestPoints; i++)
            {
                candidates[i] = points[i];
            }
        }
Exemplo n.º 4
0
 public UniformRandomSampling(IClonableObjectiveEvaluator <T> evaluator,
                              ICandidateFactory <T> populationInializer,
                              int numShuffle, IDictionary <string, string> tags = null)
 {
     this.evaluator             = evaluator;
     this.populationInitializer = populationInializer;
     this.numShuffle            = numShuffle;
     this.logTags = tags;
 }
Exemplo n.º 5
0
        /// <summary>
        ///   Executes the shuffled complex evolution for nesting within the rosenbrock optimiser.
        /// </summary>
        /// <param name="objectiveEvaluator"> The compound obj calculator. </param>
        /// <param name="dict"> The dict. </param>
        /// <param name="populationInitializer"> The population initializer. </param>
        /// <param name="logger"> The logger. </param>
        /// <returns> </returns>
        private MpiSysConfig ExecuteShuffledComplexForRosen(
            IClonableObjectiveEvaluator <MpiSysConfig> objectiveEvaluator,
            IDictionary <string, string> dict,
            ICandidateFactory <MpiSysConfig> populationInitializer,
            ILoggerMh logger)
        {
            Log.Debug("Root: Executing SCE optimiser");
            var optimEngine = CreateShuffledComplexEvolution(objectiveEvaluator, dict, populationInitializer, logger);

            return(BestParameterSet(optimEngine.Evolve(), new DefaultFitnessAssignment()));
        }
Exemplo n.º 6
0
        private IEvolutionEngine <MpiSysConfig> CreateSceRosenEngine(
            IClonableObjectiveEvaluator <MpiSysConfig> objectiveEvaluator,
            IDictionary <string, string> dict,
            ICandidateFactory <MpiSysConfig> populationInitializer,
            ILoggerMh logger)
        {
            Log.Debug("Root: Creating Rosenbrock + SCE optimiser");
            Func <IOptimizationResults <MpiSysConfig> > rosenFunc = () => ExecuteRosenbrock(objectiveEvaluator, dict, populationInitializer, logger);

            return(new ChainOptimizations <MpiSysConfig>("Sce+Rosen", rosenFunc));
        }
Exemplo n.º 7
0
        private IEvolutionEngine <MpiSysConfig> CreateEngine(
            IClonableObjectiveEvaluator <MpiSysConfig> objectiveEvaluator,
            IDictionary <string, string> dict,
            ICandidateFactory <MpiSysConfig> populationInitializer,
            ILoggerMh logger)
        {
            switch (OptimisationMethod)
            {
            default:
            case OptimisationMethods.Sce:
                return(CreateShuffledComplexEvolution(objectiveEvaluator, dict, populationInitializer, logger));

            case OptimisationMethods.RosenSce:
                return(CreateSceRosenEngine(objectiveEvaluator, dict, populationInitializer, logger));
            }
        }
Exemplo n.º 8
0
        private IOptimizationResults <MpiSysConfig> ExecuteRosenbrock(
            IClonableObjectiveEvaluator <MpiSysConfig> objectiveEvaluator,
            IDictionary <string, string> dict,
            ICandidateFactory <MpiSysConfig> populationInitializer,
            ILoggerMh logger)
        {
            Log.Debug("Root: Executing Rosenbrock optimiser");
            var engine = new RosenbrockOptimizer <MpiSysConfig, double>(
                objectiveEvaluator,
                ExecuteShuffledComplexForRosen(objectiveEvaluator, dict, populationInitializer, logger),
                new RosenbrockOptimizer <MpiSysConfig, double> .RosenbrockOptimizerIterationTermination(RosenbrockIterations),
                logTags: dict)
            {
                Logger = logger, AlgebraProvider = new TimeAlgebraProvider()
            };

            return(engine.Evolve());
        }
 public SeededSamplingFactory(ICandidateFactory <TSysConfig> uniformRandomSamplingFactory, IEnumerable <TSysConfig> seeds)
 {
     this.HcFactory = (IHyperCubeOperationsFactory)uniformRandomSamplingFactory;
     this.uniformRandomSamplingFactory = uniformRandomSamplingFactory;
     this.seeds = seeds == null ? null : seeds.ToArray();
 }