I want to iterate rows one by one of an array of population (10,4) and parse each element of a column to given variables of function (x1, x2, x3, x4), respectively. How should I set loops so that one loop can iterate rows (one by one) and the second loop can assign values of columns to the function's variables? The variables also may need to define before function accordingly. Many thanks in advance! Here is my code:
import pandas as pd
import numpy as np
nv = 4
lb = [0, 0, 0, 0]
ub = [20, 17, 17, 15]
n = 10
def random_population(nv,n,lb,ub):
pop = np.zeros((n, nv))
for i in range(n):
pop[i,:] = np.random.uniform(lb,ub)
return pop
population = random_population(nv, n, lb, ub)
def test(x1, x2, x3, x4):
##Assignment statement
y = (10*x1 + 45.5*x2 - 6*x3) * x4
return y