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

1 visualizzazione (ultimi 30 giorni)
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 Commenti

Accedi per commentare.

Risposta accettata

jgg
jgg il 28 Apr 2016
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.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by