Beispiel #1
0
        //Grafica una lista de vectores de segunda o tercera dimensión, desde cuarta dimensión hacia arriba sólo se pueden graficar las primeras 3 componentes (x,y,z).
        //Tuplas que identifican rotación horizontal/vertical para Custom_Scatter3D (Gráfica 3D personalizada).
        //Cantidad de tuplas permitidas: Máximo 4 tuplas.
        //var degrees_tuple_rotation = new List<(float horizontal_degrees, float vertical_degrees)> {
        //(45,45),
        //(0,0),
        //(90,0),
        //(0,90)
        //};
        //var degrees_rotation = $"[{string.Join(",", degrees_tuple_rotation.Select(tuple => $"('{tuple.horizontal_degrees}','{tuple.vertical_degrees}')"))}]";
        //arguments.Add("degrees_rotation", degrees_rotation);
        public static void PlotVectors(List <Vector> hyper_points, Dictionary <string, object> arguments = null)
        {
            if (hyper_points == null || !hyper_points.Any())
            {
                throw new ArgumentException("La lista <hyper_points> no puede ser nula o estar vacía.");
            }
            hyper_points = hyper_points.Distinct().ToList();
            var dimensional_size = hyper_points.All(hyper_point => hyper_point.DimensionalSize > 1) ? hyper_points.First().DimensionalSize : 1;

            if (dimensional_size < 2)
            {
                throw new ArgumentException("Solo se pueden graficar vectores con al menos dos dimensiones.");
            }
            string path_to_script = @"C:\Users\Trifenix\Desktop\Tesis_Learnheuristics\Python\PlotPoints.py";

            if (arguments == null)
            {
                arguments = new Dictionary <string, object>();
            }
            arguments["x"] = $"[{string.Join(',', hyper_points.Select(hyper_point => hyper_point.coordinates[0]).ToList())}]";
            arguments["y"] = $"[{string.Join(',', hyper_points.Select(hyper_point => hyper_point.coordinates[1]).ToList())}]";
            if (dimensional_size >= 3)
            {
                arguments["z"] = $"[{string.Join(',', hyper_points.Select(hyper_point => hyper_point.coordinates[2]).ToList())}]";
            }
            PythonScripter.Run(path_to_script, arguments).ForEach(output_line => Console.WriteLine(output_line));
        }
Beispiel #2
0
        //Evalúa la configuración: Este método debe ejecutar PythonScripter.Run para iniciar el script de python que utiliza la metaheurística de bajo nivel.
        //En este caso, ejecuta NSGA-III.py
        public float Evaluate(int max_iterations = 1, int seed = 1)
        {
            string path_to_script = @"C:\Users\Trifenix\Desktop\Tesis_Learnheuristics\Python\Main.py";
            var    arguments      = new Dictionary <string, object> {
                ["problem"]               = ProblemName,
                ["algorithm"]             = "NSGAIII",
                ["pop_size"]              = Parameter("pop_size"),
                ["crossover_probability"] = Parameter("crossover_probability") / 100,
                ["n_gen"] = max_iterations,
                ["seed"]  = seed
            };
            var output = PythonScripter.Run(path_to_script, arguments);
            var IGD    = output.FirstOrDefault().Substring(5);

            Performance = Convert.ToSingle(IGD);
            return(Performance);
        }