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
Arnab Sen
Arnab Sen 2016년 4월 28일
@ jgg, please post your comment as answer as it seems to be resolved

댓글을 달려면 로그인하십시오.

채택된 답변

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