public void TwoDim_EvaluatesCorrectValues(double[] values) { var evaluator = new Rastrigin(2); var ds = evaluator.GetGlobalOptimum().GetDecisionSpace(); var result = evaluator.Evaluate(DecisionVector.CreateFromArray(ds, new[] { values[0], values[1] })); Assert.True(Math.Abs(values[2] - result.ElementAt(0)) < 0.001); }
public void Evaluate() { Rastrigin function = new Rastrigin(); Vector v1 = new Vector(new double[] { Math.PI / 2, Math.PI / 2 }); Vector v2 = new Vector(new double[] { 0, 0 }); Assert.AreEqual(42.9885094392, function.Evaluate(v1), 0.0000000001); Assert.AreEqual(0, function.Evaluate(v2)); }
private void button1_Click(object sender, EventArgs e) { Global maple = new Global(); CCantileverBeam balka = new CCantileverBeam("balka1.mdl", 4.0, 120, 0.005); SUMSQR test = new SUMSQR(100); Rastrigin rst = new Rastrigin(3); SineRoot sr = new SineRoot(5); algopt = new CEndeavour(test); algopt.RandomScanAllowed = true; algopt.AllowReport = true; algopt.AllowASPPMode = true; algopt.StepChance = 0.025; algform = new EVF(algopt); // algform.CloseFormAfterFinish(); algform.Start(); }
public static void ObliczIndiwFitness(Particle ind) { switch (FunctionName.type) { case FunctionName.Type.Schwefel: Schwefel.setFitness(ind); break; case FunctionName.Type.DeJong1: DeJong1.setFitness(ind); break; case FunctionName.Type.Rastrigin: Rastrigin.setFitness(ind); break; case FunctionName.Type.Rosenbrock: Rosenbrock.setFitness(ind); break; } }
internal void ObliczPopulFitness(FunctionName.Type type) { for (int j = 0; j < population.Count; j++) { switch (type) { case FunctionName.Type.DeJong1: DeJong1.setFitness(population[j]); break; case FunctionName.Type.Schwefel: Schwefel.setFitness(population[j]); break; case FunctionName.Type.Rastrigin: Rastrigin.setFitness(population[j]); break; case FunctionName.Type.Rosenbrock: Rosenbrock.setFitness(population[j]); break; } } }
public static void Main(string[] args) { var param = new Parametrii(); param.W = 0.729; param.C1 = 1.49445; param.C2 = 1.49445; param.DimensiuneProblema = 3; // Rastrigin // param.Max = 5.12; // param.Min = -5.12; // Ackley // param.Min = -32.768; // param.Max = 32.768; // nGriewank param.Min = -600; param.Max = 600; param.NumarIteratii = 1000; param.NumarParticule = 50; param.VitezaMaxima = 1; ProblemaDeBaza p = new Rastrigin(); var rez = p.Rezolva(param); Console.WriteLine("Cost: " + rez.Cost); foreach (var weight in rez.Pozitie) { Console.Write(weight + " "); } Console.WriteLine("\nRosenbrock"); p = new Rosenbrock(); rez = p.Rezolva(param); Console.WriteLine("Cost: " + rez.Cost); foreach (var weight in rez.Pozitie) { Console.Write(weight + " "); } Console.WriteLine("\nAckley"); p = new Ackley(); rez = p.Rezolva(param); Console.WriteLine("Cost: " + rez.Cost); foreach (var weight in rez.Pozitie) { Console.Write(weight + " "); } Console.WriteLine("\nGriewank"); p = new Griewank(); rez = p.Rezolva(param); Console.WriteLine("Cost: " + rez.Cost); foreach (var weight in rez.Pozitie) { Console.Write(weight + " "); } }