All problems
DE Mutant Vector
Problem
Build a differential evolution mutant vector for individual i.
After random.seed(seed), sample three distinct indices a, b, c from all indices except i using random.sample, then return population[a] + f * (population[b] - population[c]) elementwise.
Hint
Indices a, b, and c must be distinct and different from i.
Test cases
case 1
in: [[[1,2],[3,4],[5,6],[7,8]],0,0.5,0]
expected: [7,8]
case 2
in: [[[0],[1],[2],[3]],2,0.8,42]
expected: [2.2]
case 3
in: [[[1,0],[0,1],[2,2],[-1,-1]],3,0.3,7]
expected: [-0.3,0.4]
Starter codePython
def de_mutant_vector(population, i, f, seed):
# Your code here
pass3 test cases · run your code against them in the editor