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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!