hi
I am trying to use fmincon to solve a nonlinear optimization question. But the objective function is so complex that I cannot easily use x(1) and x(2) to describe. So i used a function file to link the fun. But there is always some error:Not enough input arguments.
i thought the error is because the obj function is too complex (maybe?). Please help me, thx!!
function [ y ] = expectedprofit(k,s)potential_arrival_rate=50;lambda=potential_arrival_rate*s;mu=4;c=200;K=100;rho=lambda/mu;syms t;h=symsum(power(rho,t)/factorial(t), t,0,k-1);denominator = h+k*power(rho,k)/[(k-rho)*factorial(k)];numerator = k*power(rho,k)/[(k-rho)*factorial(k)];C = numerator/denominator;waitingtime = C/[mu*(k-rho)];y=-lambda*[1-s-c*waitingtime-power(k,2)/(K*lambda)];end
and my fmincon code is:
fun = @(k,s)expectedprofit;lb = [0,0];ub = [100,1];A = [-1,100];b = 0;Aeq = [];beq = [];x0 = [5,0.2];[k,s] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub);
the error message:
Not enough input arguments.Error in expectedprofit (line 5)lambda=potential_arrival_rate*s;Error in @(k,s)expectedprofitError in fmincon (line 535) initVals.f = feval(funfcn{3},X,varargin{:});Caused by: Failure in initial objective function evaluation. FMINCON cannot continue.
Best Answer