private void SetFitnessFunction(FitnessFunctionDelegate argDelegate) { //uncheck miXXplusYY.IsChecked = false; miTripod.IsChecked = false; miAlpine.IsChecked = false; miGriewank.IsChecked = false; miRosenbrock.IsChecked = false; //set ffd = argDelegate; //preview cvPage.Children.Clear(); if (Preview) { Optimizer = new PreviewDisplayer { LowerParamBounds = new ArrayList { -100, -100 }, UpperParamBounds = new ArrayList { 100, 100 }, FitnessFunction = ffd }; Optimizer.GenerationCreated += this.ShowAntibodies; Optimizer.Optimize(); } }
/// <summary> /// Constructor for class /// </summary> /// <param name="swingObject">Specific swing GameObject the class is attached to</param> /// <param name="entity">Specific instance of an IEntity which serves as the swinger's brain</param> /// <param name="fitnessFunction">Fitness Function to use when evaluating current state</param> public void Construct(GameObject swingObject, IEntity entity, FitnessFunctionDelegate fitnessFunction) { swing = swingObject; swingElements = swing.transform.Find("Swing").gameObject; robotElements = swing.transform.Find("Robot").gameObject; swingAI = entity; fitnessFunctionToUse = fitnessFunction; }
/// <summary> /// Initializes the fields of a particle and calculates the fitness of the position vector. /// </summary> /// <param name="ffd">Function used for the fitness calculation.</param> /// <param name="p">The new parameter tuple.</param> public Particle(FitnessFunctionDelegate ffd, ArrayList pos, EventHandlerDelegate fitnessEvaluated) : base(ffd, pos, fitnessEvaluated) { // Initial velocity is 0.0 in each dimension. Velocity = new ArrayList(); for (int i = 0; i < Position.Count; i++) { Velocity.Add(0.0); } BestFitness = Double.MaxValue; }
/// <summary> /// Initializes the fields of an element and calculates the fitness of the position vector. /// </summary> /// <param name="fitnessFunction">Function used for the affinity calculation.</param> /// <param name="parameters">The new parameter tuple.</param> public BaseElement(FitnessFunctionDelegate fitnessFunction, ArrayList parameters, EventHandlerDelegate fitnessEvaluated) { Position = new ArrayList(); foreach (var d in parameters) { Position.Add(d); } FitnessFunction = fitnessFunction; FitnessEvaluated += fitnessEvaluated; Update(); }
/// <summary> /// Method to retrieve the fitness function from it's string name /// </summary> /// <param name="fitnessFuncToUse">String name of the desired fitness function. Must be contained in fitnessFunctionNames.</param> /// <returns>FitnessFunction, the method chosen from the input string.</returns> public FitnessFunctionDelegate GetfitnessFunction(string fitnessFuncToUse) { //Easy method of allocating which function to use switch (fitnessFuncToUse) { case "Example": findFitness = ExampleFitnessFunction; break; case "StoredEnergy": findFitness = EnergyConservation; break; default: findFitness = EnergyConservation; break; } return(findFitness); }
/// <param name="fitnessFunction">Have to thread save since it will be used in several threads at the same time</param> public StartingInfo(FitnessFunctionDelegate <Creature> fitnessFunction, Creature foreFather) { FitnessFunctionFactory = new DefaultFitnessFunctionFactory <Creature>(fitnessFunction); this.foreFather = foreFather; }
public void SetFitnessFunction(FitnessFunctionDelegate <Creature> newFitnessFunction) => SetFitnessFunctinonFactory(new DefaultFitnessFunctionFactory <Creature>(newFitnessFunction));
public MainWindow() { InitializeComponent(); openParams = 0; // Lower and upper bounds for the parameters. lbp = new ArrayList { -100.0, -100.0 }; ubp = new ArrayList { 100.0, 100.0 }; // Initial values of the parameters to be optimized. InitialParameters = new ArrayList { 90.0, 90.0 }; // Define whether the seeked values should be restricted to integers (true) or not (false). Integer = new bool[] { false, false }; //Create optimizer object. // Number of antibodies. NA = 50; method = 0; Slow = false; Preview = false; uniqueTest = false; // Stopping stoppingType = StoppingType.EvaluationNumber; ng = 100; nev = 50000; Ftr = 0.00001; // Fitness function ffd = FitnessFunctionParabola; //clonal generation params beta = 0.5; ro = 0.5; d = NA / 5; cgn = NA / 3; cglssr = 0.005; cgln = 5; // Firework params m = 50; a = 0.04; b = 0.8; Amax = 40; mhat = NA; // Particle swarm params c0 = 0.8; cp = 0.2; cg = 0.2; // Genetic algorithm params P = NA / 2; pm = 0.6; crossoverCount = NA; // Bee algorithm params ExBeeCount = 10; MaxStep = 5; // Bacterial algorithm params Infections = 10; ClonesCount = 25; // Differential Evolution params weighf = 1.8; crossf = 0.9; // Haromony Search params consid_rate = 0.95; adjust_rate = 0.7; range = 0.05; }
/// <summary> /// Method responsible for the optimization. /// </summary> /// <returns>An object containing the optimized values of the parameters as well as other characteristics of the optimization process.</returns> /// <summary> /// Returns the particle created using the initial parameters and the fitness function. /// </summary> /// <param name="fitnessFunction"></param> /// <param name="parameters"></param> /// <returns></returns> protected override IElement GetNewElement(FitnessFunctionDelegate fitnessFunction, ArrayList parameters) { return(new Particle(fitnessFunction, parameters, FitnessEvaluated)); }
/// <summary> /// Returns the element created using the initial parameters and the fitness function. /// </summary> /// <param name="fitnessFunction"></param> /// <param name="parameters"></param> /// <returns></returns> protected virtual IElement GetNewElement(FitnessFunctionDelegate fitnessFunction, ArrayList parameters) { return(new BaseElement(fitnessFunction, parameters, FitnessEvaluated)); }
public DefaultFitnessFunctionFactory(FitnessFunctionDelegate <Creature> fitnessFunction) { provider = () => fitnessFunction; }