/// <summary> /// Constructor /// </summary> /// <param name="CR"></param> /// <param name="F"></param> public DifferentialEvolutionOffspring(double CR, double F) { Dictionary <string, object> parameters = null; this.CR = CR; this.F = F; try { // Crossover operator parameters = new Dictionary <string, object>(); parameters.Add("CR", CR); parameters.Add("F", F); crossover = new DifferentialEvolutionCrossover(parameters); // Selecion operator parameters = null; selection = SelectionFactory.GetSelectionOperator("DifferentialEvolutionSelection", parameters); } catch (Exception ex) { Logger.Log.Error("Exception in " + this.GetType().FullName + ".Execute()", ex); Console.Error.WriteLine("Error in: " + this.GetType().FullName + "\r\n" + ex.StackTrace); } Id = "DE"; }
public PolynomialMutationOffspring(double mutationProbability, double distributionIndexForMutation) { Dictionary <string, object> parameters; // Operator parameters parameters = new Dictionary <string, object>(); parameters.Add("probability", this.mutationProbability = mutationProbability); parameters.Add("distributionIndex", this.distributionIndex = distributionIndexForMutation); mutation = MutationFactory.GetMutationOperator("PolynomialMutation", parameters); selection = SelectionFactory.GetSelectionOperator("BinaryTournament", null); Id = "PolynomialMutation"; }
public Operator GetSelection() { Dictionary <string, object> parameters = new Dictionary <string, object>(); switch (s) { case "BinaryTournament2": parameters = null; selection = SelectionFactory.GetSelectionOperator("BinaryTournament2", parameters); break; default: break; } return(selection); }
public SBXCrossoverOffspring(double crossoverProbability, double distributionIndexForCrossover) { Dictionary <string, object> parameters; this.crossoverProbability = crossoverProbability; this.distributionIndexForCrossover = distributionIndexForCrossover; // Crossover operator parameters = new Dictionary <string, object>(); parameters.Add("probability", crossoverProbability); parameters.Add("distributionIndex", distributionIndexForCrossover); crossover = CrossoverFactory.GetCrossoverOperator("SBXCrossover", parameters); selection = SelectionFactory.GetSelectionOperator("BinaryTournament", null); Id = "SBXCrossover"; }
/// <summary> /// Usage: /// - NSGAIImTSP /// </summary> /// <param name="args">Command line arguments.</param> public static void Main(string[] args) { Problem problem; // The problem to solve Algorithm algorithm; // The algorithm to use Operator crossover; // Crossover operator Operator mutation; // Mutation operator Operator selection; // Selection operator Dictionary <string, object> parameters; // Operator parameters QualityIndicator indicators; // Object to get quality indicators // Logger object and file to store log messages var logger = Logger.Log; var appenders = logger.Logger.Repository.GetAppenders(); var fileAppender = appenders[0] as log4net.Appender.FileAppender; fileAppender.File = "NSGAIImTSP.log"; fileAppender.ActivateOptions(); indicators = null; problem = new MTSP("Permutation", "kroA150.tsp", "kroB150.tsp"); algorithm = new JMetalCSharp.Metaheuristics.NSGAII.NSGAII(problem); //algorithm = new ssNSGAII(problem); // Algorithm parameters algorithm.SetInputParameter("populationSize", 100); algorithm.SetInputParameter("maxEvaluations", 10000000); /* Crossver operator */ parameters = new Dictionary <string, object>(); parameters.Add("probability", 0.95); //crossover = CrossoverFactory.getCrossoverOperator("TwoPointsCrossover", parameters); crossover = CrossoverFactory.GetCrossoverOperator("PMXCrossover", parameters); /* Mutation operator */ parameters = new Dictionary <string, object>(); parameters.Add("probability", 0.2); mutation = MutationFactory.GetMutationOperator("SwapMutation", parameters); /* Selection Operator */ parameters = null; selection = SelectionFactory.GetSelectionOperator("BinaryTournament", parameters); // Add the operators to the algorithm algorithm.AddOperator("crossover", crossover); algorithm.AddOperator("mutation", mutation); algorithm.AddOperator("selection", selection); // Add the indicator object to the algorithm algorithm.SetInputParameter("indicators", indicators); // Execute the Algorithm long initTime = Environment.TickCount; SolutionSet population = algorithm.Execute(); long estimatedTime = Environment.TickCount - initTime; // Result messages logger.Info("Total execution time: " + estimatedTime + "ms"); logger.Info("Variables values have been writen to file VAR"); population.PrintVariablesToFile("VAR"); logger.Info("Objectives values have been writen to file FUN"); population.PrintObjectivesToFile("FUN"); if (indicators != null) { logger.Info("Quality indicators"); logger.Info("Hypervolume: " + indicators.GetHypervolume(population)); logger.Info("GD : " + indicators.GetGD(population)); logger.Info("IGD : " + indicators.GetIGD(population)); logger.Info("Spread : " + indicators.GetSpread(population)); logger.Info("Epsilon : " + indicators.GetEpsilon(population)); int evaluations = (int)algorithm.GetOutputParameter("evaluations"); logger.Info("Speed : " + evaluations + " evaluations"); } }
/// <summary> /// Usage: three options /// - NSGAII /// - NSGAII problemName /// - NSGAII problemName paretoFrontFile /// </summary> /// <param name="args"></param> public NSGAIIRunner(string[] args, Problem p, string Path, MOO comp) { Problem problem = p; // The problem to solve Algorithm algorithm; // The algorithm to use Operator crossover; // Crossover operator Operator mutation; // Mutation operator Operator selection; // Selection operator this.comp = comp; Dictionary <string, object> parameters; // Operator parameters QualityIndicator indicators; // Object to get quality indicators // Logger object and file to store log messages //var logger = Logger.Log; //var appenders = logger.Logger.Repository.GetAppenders(); //var fileAppender = appenders[0] as log4net.Appender.FileAppender; //fileAppender.File = "NSGAII.log"; //fileAppender.ActivateOptions(); indicators = null; //if (args.Length == 1) //{ // object[] param = { "Real" }; // problem = ProblemFactory.GetProblem(args[0], param); //} //else if (args.Length == 2) //{ // object[] param = { "Real" }; // problem = ProblemFactory.GetProblem(args[0], param); // indicators = new QualityIndicator(problem, args[1]); //} //else //{ // Default problem // //problem = ; // //problem = new Kursawe("BinaryReal", 3); // //problem = new Water("Real"); // //problem = new ZDT3("ArrayReal", 30); // //problem = new ConstrEx("Real"); // //problem = new DTLZ1("Real"); // //problem = new OKA2("Real") ; //} algorithm = new NSGAII(problem, comp); //algorithm = new ssNSGAII(problem); // Algorithm parameters algorithm.SetInputParameter("populationSize", comp.popSize); algorithm.SetInputParameter("maxEvaluations", comp.maxEvals); comp.LogAddMessage("Population Size = " + comp.popSize); comp.LogAddMessage("Max Evaluations = " + comp.maxEvals); // Mutation and Crossover for Real codification parameters = new Dictionary <string, object>(); parameters.Add("probability", 0.9); parameters.Add("distributionIndex", 20.0); crossover = CrossoverFactory.GetCrossoverOperator("SBXCrossover", parameters); comp.LogAddMessage("Crossover Type = " + "SBXCrossover"); comp.LogAddMessage("Crossover Probability = " + 0.9); comp.LogAddMessage("Crossover Distribution Index = " + 20); parameters = new Dictionary <string, object>(); parameters.Add("probability", 1.0 / problem.NumberOfVariables); parameters.Add("distributionIndex", 20.0); mutation = MutationFactory.GetMutationOperator("PolynomialMutation", parameters); comp.LogAddMessage("Mutation Type = " + "Polynomial Mutation"); comp.LogAddMessage("Mutation Probability = " + (1 / problem.NumberOfVariables)); comp.LogAddMessage("Mutation Distribution Index = " + 20); // Selection Operator parameters = null; selection = SelectionFactory.GetSelectionOperator("BinaryTournament2", parameters); comp.LogAddMessage("Selection Type = " + "Binary Tournament 2"); // Add the operators to the algorithm algorithm.AddOperator("crossover", crossover); algorithm.AddOperator("mutation", mutation); algorithm.AddOperator("selection", selection); // Add the indicator object to the algorithm algorithm.SetInputParameter("indicators", indicators); // Execute the Algorithm long initTime = Environment.TickCount; SolutionSet population = algorithm.Execute(); long estimatedTime = Environment.TickCount - initTime; comp.LogAddMessage("Total Execution Time = " + estimatedTime + "ms"); // Result messages //logger.Info("Total execution time: " + estimatedTime + "ms"); //logger.Info("Variables values have been writen to file VAR"); //population.PrintVariablesToFile(@"C:\Users\Jonathas\Desktop\text.txt"); population.PrintVariablesToFile(@"" + comp.fileName + "VAR-" + comp.fileName); //logger.Info("Objectives values have been writen to file FUN"); population.PrintObjectivesToFile(@"" + comp.fileName + "OBJ-" + comp.fileName); // Saving all solutions to file //Console.WriteLine("Time: " + estimatedTime); //Console.ReadLine(); if (indicators != null) { //logger.Info("Quality indicators"); //logger.Info("Hypervolume: " + indicators.GetHypervolume(population)); //logger.Info("GD : " + indicators.GetGD(population)); //logger.Info("IGD : " + indicators.GetIGD(population)); //logger.Info("Spread : " + indicators.GetSpread(population)); //logger.Info("Epsilon : " + indicators.GetEpsilon(population)); int evaluations = (int)algorithm.GetOutputParameter("evaluations"); //logger.Info("Speed : " + evaluations + " evaluations"); } }
/// <summary> /// Usage: three options /// - SPEA2 /// - SPEA2 problemName /// - SPEA2 problemName ParetoFrontFile /// </summary> /// <param name="args">Command line arguments. The first (optional) argument specifies the problem to solve.</param> public static void Main(string[] args) { Problem problem; // The problem to solve Algorithm algorithm; // The algorithm to use Operator crossover; // Crossover operator Operator mutation; // Mutation operator Operator selection; // Selection operator QualityIndicator indicators; // Object to get quality indicators Dictionary <string, object> parameters; // Operator parameters // Logger object and file to store log messages var logger = Logger.Log; var appenders = logger.Logger.Repository.GetAppenders(); var fileAppender = appenders[0] as log4net.Appender.FileAppender; fileAppender.File = "SPEA2.log"; fileAppender.ActivateOptions(); indicators = null; if (args.Length == 1) { object[] param = { "Real" }; problem = ProblemFactory.GetProblem(args[0], param); } else if (args.Length == 2) { object[] param = { "Real" }; problem = ProblemFactory.GetProblem(args[0], param); indicators = new QualityIndicator(problem, args[1]); } else { // Default problem problem = new Kursawe("Real", 3); //problem = new Water("Real"); //problem = new ZDT1("ArrayReal", 1000); //problem = new ZDT4("BinaryReal"); //problem = new WFG1("Real"); //problem = new DTLZ1("Real"); //problem = new OKA2("Real") ; } algorithm = new JMetalCSharp.Metaheuristics.SPEA2.SPEA2(problem); // Algorithm parameters algorithm.SetInputParameter("populationSize", 100); algorithm.SetInputParameter("archiveSize", 100); algorithm.SetInputParameter("maxEvaluations", 25000); // Mutation and Crossover for Real codification parameters = new Dictionary <string, object>(); parameters.Add("probability", 0.9); parameters.Add("distributionIndex", 20.0); crossover = CrossoverFactory.GetCrossoverOperator("SBXCrossover", parameters); parameters = new Dictionary <string, object>(); parameters.Add("probability", 1.0 / problem.NumberOfVariables); parameters.Add("distributionIndex", 20.0); mutation = MutationFactory.GetMutationOperator("PolynomialMutation", parameters); // Selection operator parameters = null; selection = SelectionFactory.GetSelectionOperator("BinaryTournament", parameters); // Add the operators to the algorithm algorithm.AddOperator("crossover", crossover); algorithm.AddOperator("mutation", mutation); algorithm.AddOperator("selection", selection); // Execute the algorithm long initTime = Environment.TickCount; SolutionSet population = algorithm.Execute(); long estimatedTime = Environment.TickCount - initTime; // Result messages logger.Info("Total execution time: " + estimatedTime + "ms"); logger.Info("Objectives values have been writen to file FUN"); population.PrintObjectivesToFile("FUN"); logger.Info("Variables values have been writen to file VAR"); population.PrintVariablesToFile("VAR"); if (indicators != null) { logger.Info("Quality indicators"); logger.Info("Hypervolume: " + indicators.GetHypervolume(population)); logger.Info("GD : " + indicators.GetGD(population)); logger.Info("IGD : " + indicators.GetIGD(population)); logger.Info("Spread : " + indicators.GetSpread(population)); logger.Info("Epsilon : " + indicators.GetEpsilon(population)); } Console.WriteLine("Total execution time: " + estimatedTime + "ms"); Console.ReadLine(); }
/// <summary> /// Usage: three options /// - NSGAIIAdaptive /// - NSGAIIAdaptive problemName /// - NSGAIIAdaptive problemName paretoFrontFile /// </summary> /// <param name="args">Command line arguments.</param> public static void Main(string[] args) { Problem problem; // The problem to solve Algorithm algorithm; // The algorithm to use Operator selection; // Selection operator Dictionary <string, object> parameters; // Operator parameters QualityIndicator indicators; // Object to get quality indicators // Logger object and file to store log messages var logger = Logger.Log; var appenders = logger.Logger.Repository.GetAppenders(); var fileAppender = appenders[0] as log4net.Appender.FileAppender; fileAppender.File = "NSGAIIAdaptive.log"; fileAppender.ActivateOptions(); indicators = null; if (args.Length == 1) { object[] param = { "Real" }; problem = ProblemFactory.GetProblem(args[0], param); } else if (args.Length == 2) { object[] param = { "Real" }; problem = ProblemFactory.GetProblem(args[0], param); indicators = new QualityIndicator(problem, args[1]); } else { // Default problem problem = new Kursawe("Real", 3); //problem = new Kursawe("BinaryReal", 3); //problem = new Water("Real"); //problem = new ZDT1("ArrayReal", 100); //problem = new ConstrEx("Real"); //problem = new DTLZ1("Real"); //problem = new OKA2("Real") ; } problem = new LZ09_F3("Real"); algorithm = new JMetalCSharp.Metaheuristics.NSGAII.NSGAIIAdaptive(problem); //algorithm = new ssNSGAIIAdaptive(problem); // Algorithm parameters algorithm.SetInputParameter("populationSize", 100); algorithm.SetInputParameter("maxEvaluations", 150000); // Selection Operator parameters = null; selection = SelectionFactory.GetSelectionOperator("BinaryTournament2", parameters); // Add the operators to the algorithm algorithm.AddOperator("selection", selection); // Add the indicator object to the algorithm algorithm.SetInputParameter("indicators", indicators); Offspring[] getOffspring = new Offspring[3]; double CR, F; CR = 1.0; F = 0.5; getOffspring[0] = new DifferentialEvolutionOffspring(CR, F); getOffspring[1] = new SBXCrossoverOffspring(1.0, 20); //getOffspring[1] = new BLXAlphaCrossoverOffspring(1.0, 0.5); getOffspring[2] = new PolynomialMutationOffspring(1.0 / problem.NumberOfVariables, 20); //getOffspring[2] = new NonUniformMutationOffspring(1.0/problem.getNumberOfVariables(), 0.5, 150000); algorithm.SetInputParameter("offspringsCreators", getOffspring); // Execute the Algorithm long initTime = Environment.TickCount; SolutionSet population = algorithm.Execute(); long estimatedTime = Environment.TickCount - initTime; // Result messages logger.Info("Total execution time: " + estimatedTime + "ms"); logger.Info("Variables values have been writen to file VAR"); population.PrintVariablesToFile("VAR"); logger.Info("Objectives values have been writen to file FUN"); population.PrintObjectivesToFile("FUN"); Console.WriteLine("Time: " + estimatedTime); Console.ReadLine(); if (indicators != null) { logger.Info("Quality indicators"); logger.Info("Hypervolume: " + indicators.GetHypervolume(population)); logger.Info("GD : " + indicators.GetGD(population)); logger.Info("IGD : " + indicators.GetIGD(population)); logger.Info("Spread : " + indicators.GetSpread(population)); logger.Info("Epsilon : " + indicators.GetEpsilon(population)); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new LoadConfig()); // VariabilityModel model = new VariabilityModel("Model1"); // InfluenceModel infModel = new InfluenceModel(model, new NFProperty("Test")); // BettyFileParser bfp = new BettyFileParser(model, infModel); String[] file = System.IO.File.ReadAllLines(@"C:\Users\Tom\Desktop\Masterarbeit\SPLConqueror\SPLConqueror\BettyConqueror\FeatureModel0.afm"); // bfp.readConfiguration(file); //ILArray<float> A = ILMath.tosingle() //ILArray<float> A = ILMath.tosingle(ILMath.rand(3, 100)); // RDotNet.NativeLibrary.UnmanagedDll.SetDllDirectory(@"C:\Program Files\R\R-3.2.0\bin\i386\R.dll"); engine = REngine.GetInstance(); NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 }); engine.SetSymbol("group1", group1); // e.Evaluate("hist(group1)"); // e.Evaluate("hist(group1)"); Problem problem; Operator crossover; // Crossover operator Operator mutation; // Mutation operator Operator selection; // Selection operator var logger = Logger.Log; // var appenders = logger.Logger.Repository.GetAppenders(); // var fileAppender = appenders[0] as log4net.Appender.FileAppender; // fileAppender.File = "NSGAII.log"; //.ActivateOptions(); Dictionary <string, object> parameters; // Operator parameters QualityIndicator indicators; // Object to get quality indicators problem = new GeneratorProblem("Real", 30); NSGAII algorithm = new NSGAII(problem); indicators = null; algorithm.SetInputParameter("populationSize", 200); algorithm.SetInputParameter("maxEvaluations", 25000); // Mutation and Crossover for Real codification parameters = new Dictionary <string, object>(); parameters.Add("probability", 0.9); parameters.Add("distributionIndex", 20.0); crossover = CrossoverFactory.GetCrossoverOperator("SBXCrossover", parameters); parameters = new Dictionary <string, object>(); parameters.Add("probability", 1.0 / problem.NumberOfVariables); parameters.Add("distributionIndex", 20.0); mutation = MutationFactory.GetMutationOperator("PolynomialMutation", parameters); // Selection Operator parameters = null; selection = SelectionFactory.GetSelectionOperator("BinaryTournament2", parameters); // Add the operators to the algorithm algorithm.AddOperator("crossover", crossover); algorithm.AddOperator("mutation", mutation); algorithm.AddOperator("selection", selection); // Add the indicator object to the algorithm algorithm.SetInputParameter("indicators", indicators); // Execute the Algorithm long initTime = Environment.TickCount; //SolutionSet population = algorithm.Execute(); long estimatedTime = Environment.TickCount - initTime; logger.Info("Variables values have been writen to file VAR"); //population.PrintVariablesToFile("VAR"); logger.Info("Objectives values have been writen to file FUN"); // population.PrintObjectivesToFile("FUN"); Console.WriteLine("Time: " + estimatedTime); Console.ReadLine(); //Application.Run(new Form1(e, group1, new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99, 1.3, 1.7, 9.4, 11.1 })); }
/// <summary> ///Usage: three choices /// - GDE3 /// - GDE3 problemName /// - GDE3 problemName paretoFrontFile /// </summary> /// <param name="args">Command line arguments.</param> public static void Main(string[] args) { Problem problem; // The problem to solve Algorithm algorithm; // The algorithm to use Operator selection; Operator crossover; Dictionary <string, object> parameters; // Operator parameters QualityIndicator indicators; // Object to get quality indicators // Logger object and file to store log messages var logger = Logger.Log; var appenders = logger.Logger.Repository.GetAppenders(); var fileAppender = appenders[0] as log4net.Appender.FileAppender; fileAppender.File = "GDE3.log"; fileAppender.ActivateOptions(); indicators = null; if (args.Length == 1) { object[] param = { "Real" }; problem = ProblemFactory.GetProblem(args[0], param); } else if (args.Length == 2) { object[] param = { "Real" }; problem = ProblemFactory.GetProblem(args[0], param); indicators = new QualityIndicator(problem, args[1]); } else { // Default problem problem = new Kursawe("Real", 3); //problem = new Water("Real"); //problem = new ZDT1("ArrayReal", 100); //problem = new ConstrEx("Real"); //problem = new DTLZ1("Real"); //problem = new OKA2("Real") ; } algorithm = new JMetalCSharp.Metaheuristics.GDE3.GDE3(problem); // Algorithm parameters algorithm.SetInputParameter("populationSize", 100); algorithm.SetInputParameter("maxIterations", 250); // Crossover operator parameters = new Dictionary <string, object>(); parameters.Add("CR", 0.5); parameters.Add("F", 0.5); crossover = CrossoverFactory.GetCrossoverOperator("DifferentialEvolutionCrossover", parameters); // Add the operators to the algorithm parameters = null; selection = SelectionFactory.GetSelectionOperator("DifferentialEvolutionSelection", parameters); algorithm.AddOperator("crossover", crossover); algorithm.AddOperator("selection", selection); // Execute the Algorithm long initTime = Environment.TickCount; SolutionSet population = algorithm.Execute(); long estimatedTime = Environment.TickCount - initTime; // Result messages logger.Info("Total execution time: " + estimatedTime + "ms"); logger.Info("Objectives values have been writen to file FUN"); population.PrintObjectivesToFile("FUN"); logger.Info("Variables values have been writen to file VAR"); population.PrintVariablesToFile("VAR"); if (indicators != null) { logger.Info("Quality indicators"); logger.Info("Hypervolume: " + indicators.GetHypervolume(population)); logger.Info("GD : " + indicators.GetGD(population)); logger.Info("IGD : " + indicators.GetIGD(population)); logger.Info("Spread : " + indicators.GetSpread(population)); logger.Info("Epsilon : " + indicators.GetEpsilon(population)); } Console.WriteLine("Total execution time gde: moead" + estimatedTime + "ms"); Console.ReadLine(); }