this a part of a code from COA:
this code is an original one from the author in Matlab:
function[lowerbund, upperbound, dimension, fitness] = fun_info(F) switch F case 'F1' fitness = @F1; lowerbound = -100; upperbound = 100; dimension = 30; . . . end end %F1 function R = F1(x) R = sum(x.^2); end . . . and this code is what I wrote in Python:
def fun_info(fun_name): if fun_name == 'F1': fitness = function() lowerbound = -100 upperbound = 100 dimension = 30 . . . else: raise ValueError("Function not defined.") return lowerbound, upperbound, dimension, fitness def funtion1(x): r = np.sum(np.square(x)) return r . . . in Matlab code, the function is referenced by '@' and the input for the function is 'x', but I don't know where the x comes from, so in the Python version, there is an error because of that. what is the mistake? what should I do?
Источник: https://stackoverflow.com/questions/780 ... comes-from
Откуда взялся «х»? ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
Мобильная версия