jDE(Adaptive Differential Evolution)

145 Views Asked by At

In jDE, each individual has its own F and CR values. How to assign these values to each individuals programmatically. How to update these values.

A pseudo-code will help.

1

There are 1 best solutions below

2
On

If you want each individual to have its own F and CR values, you can simply save it in a list. (Pseudo-code: Python)

ID_POS = 0
ID_FIT = 1
ID_F = 2
ID_CR = 3

def create_solution(problem_size):
    pos = np.random.uniform(lower_bound, upper_bound, problem_size)
    fit = fitness_function(pos)
    F = your_values
    CR = your values 
    return [pos, fit, F, CR]
    
def training(problem_size, pop_size, max_iteration):
    # Initialization
    pop = [create_solution(problem_size) for _ in range(0, pop_size)]
    
    # Evolution process
    for iteration in range(0, max_iteration):
        for i in range(0, pop_size):
            # Do your stuff here
            pos_new = ....
            fit_new = ....
            F_new = ...
            CR_new = ...
            
            if pop[i][ID_FIT] < fit_new:    # meaning the new solution has better fitness than the old one.
                pop[i][ID_F] = F_new 
                pop[i][ID_CR] = CR_new      # This is how you update F and CR for every individual.
            ...

You can check out my repo's contains most of the state-of-the-art meta-heuristics here. https://github.com/thieunguyen5991/metaheuristics