Too many input arguments error. Matrix variable as input to objective function. Using ga algorithm.

1 次查看(过去 30 天)
I have objective function as below, where x(input) is 3 by 9 matrix input, I get single value output from objective function. I am trying to minimize the function using genetic algorithm like below, but i am getting error as "Error using ObjectiveFun Too many input arguments.". Please help me in resolving this issue. And what if I have to use non-linear constraints in this case having matrix variable as input. Thank you for your help in advance.
ObjectiveFunction = @ObjectiveFun X0 = zeros(3,9); options.InitialPopulationMatrix = X0; lb = zeros(3,9); ub = zeros(3,9)+Inf; [x,fval] = ga(ObjectiveFunction,3*9,[],[],[],[],lb(:),ub(:),[],options);
Objective function: function y=ObjectiveFun() global 9 for t=1:1:9 y(t)=integral_function(t, x); end y=-sum(y') end function fun=integral_function(t, x) global alpha a b M c1 c2 beta % these values I have define globally fun=x(1,t)*(x(2,t)-c1)+(x(3,t)-c2)*(M- x(1,t))*(a + b * x(1,t))*(exp(-alpha*x(2,t)-beta*x(3,t))); end
  3 个评论

请先登录,再进行评论。

采纳的回答

jgg
jgg 2016-4-28
As you've written it, your objective function does not take in any inputs. It needs to take in the point to be evaluated and return the value of the point.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by