Example #1
0
        public static void Main(string[] args)
        {
            /*
             * The context of this tutorial is that you have an existing time stepping simulation
             * model.
             */
            IClonableObjectiveEvaluator <IHyperCube <double> > evaluator;
            IEvolutionEngine <IHyperCube <double> >            uniformRandomSampling;


            var simulation = SimulationFactory.CreateAwbmSimulation();
            var data       = DataHandling.GetSampleClimate();

            SimulationFactory.SetSampleSimulation(simulation, data);
            int from = simulation.GetStart();
            int to   = simulation.GetEnd();

            evaluator = BuildUrsEvaluator(simulation, data.Runoff, from, to);

            var paramSpace = CreateFeasibleAwbmParameterSpace(simulation);

            uniformRandomSampling = new UniformRandomSampling <IHyperCube <double> >(evaluator, new BasicRngFactory(0), paramSpace, 3000);
            var ursResults = uniformRandomSampling.Evolve();

            Console.WriteLine(MetaheuristicsHelper.GetHumanReadable(ursResults));
        }
Example #2
0
        static void Main(string[] args)
        {
            /*
             * This program primarily demonstrates how to wrap and calibrate a model written
             * in a native language. While technological aspects of what it demonstrates
             * are not inherently limited nor specific to optimisation, this is
             * a use case often encountered (e.g. to calibrate existing models written in
             * C++ , C, or Fortran)
             */
            IClonableObjectiveEvaluator <IHyperCube <double> > evaluator;
            IEvolutionEngine <IHyperCube <double> >            uniformRandomSampling;

            NativeModelWrapper.AwbmWrapper.PermitMultiThreading = true;

            using (var simulation = new AwbmWrapper())
            {
                var data = DataHandling.GetSampleClimate();
                SimulationFactory.SetSampleSimulation(simulation, data);
                int from = simulation.GetStart();
                int to   = simulation.GetEnd();

                evaluator = AWBM_URS.MainClass.BuildUrsEvaluator(simulation, data.Runoff, from, to);

                var paramSpace = AWBM_URS.MainClass.CreateFeasibleAwbmParameterSpace(simulation);
                uniformRandomSampling = new UniformRandomSampling <IHyperCube <double> >(evaluator, new BasicRngFactory(0), paramSpace, 3000);
                var ursResults = uniformRandomSampling.Evolve();
                Console.WriteLine(MetaheuristicsHelper.GetHumanReadable(ursResults));
            }
        }
Example #3
0
        public static void Main(string[] args)
        {
            // If you have to remember *one* thing from this tutorial, it is the three essential players
            // 1- the tunable parameters of the optimisation problem:
            //    ISystemConfiguration, here implemented by StringSpecification for this 'Hello World' problem
            // 2- the object evaluating the score(s) for a given "system configuration" (IObjectiveEvaluator<T>)
            // 3- the optimisation algorithm, implementing IEvolutionEngine<T>
            // It is recommended that you declare variables typed as interfaces, not concrete classes,
            // whenever possible including in an 'Hello World'...
            IObjectiveEvaluator <StringSpecification> evaluator;
            IEvolutionEngine <StringSpecification>    finder;

            string strToFind = args.Length == 0 ? "Hello, World!" : args[0];

            evaluator = buildEvaluator(strToFind);
            finder    = new StringFinder(evaluator, strToFind.Length, new BasicRngFactory(0));
            var result = finder.Evolve();

            Console.WriteLine(MetaheuristicsHelper.GetHumanReadable(result));
        }