I have a filter expression as follows:
feasible_agents = filter(lambda agent: agent >= cost[task, agent], agents)
where agents is a python list.
Now, to get speedup, I am trying to implement this using numpy.
What would be the equivalent using numpy?
I know that this works:
threshold = 5.0
feasible_agents = np_agents[np_agents > threshold]
where np_agents is the numpy equivalent of agents.
However, I want threshold to be a function of each element in the numpy array.
costvalue that is obtained by lookup in the cost table using each element of theagentslist as key.taskis a constant here. i.e. the threshold is not fixed, but will vary for every elementagentin the numpy arraynp_agents.