Hi guys, I have 4 functions where each one is derived from previous one. When I call the last one (revenue.m) I got an error using fmincon. Any clue? I want to optimize in respect to x0 that is present in each function. Many Thanks! Here is my code:
%% Total out flow equation T = zeros([N,M]); S=zeros([N,M]); for i = 1:M
R(:,i)=revenue(price(:,1),HH(:,i),ro,g,eff,x0(:,i),N,k1); options = optimset('MaxFunEvals',Inf,'MaxIter',50,... 'Algorithm','interior-point','Display','iter'); tic [x(:,i),fval(:,i)] = fmincon(@revenue,x0(1:2*N,i),A,b(:,i),Aeq,beq(:,i),LB(:,i),UB(:,i),[],options); %good
tocend
with revenue fun being:
function R=revenue(price,HH,ro,g,eff,x0,N,k1) R= -sum(price.*((HH*ro*g*eff).*x0(1:N))/k1); end % saved as revenue.m
Error msg:
Not enough input arguments.Error in revenue (line 5) R= -sum(price.*((HH*ro*g*eff).*x0(1:N))/k1);Error in fmincon (line 535) initVals.f = feval(funfcn{3},X,varargin{:});Caused by: Failure in initial objective function evaluation. FMINCON cannot continue. end
Best Answer