Not enough input arguments Error

2 views (last 30 days)
Hello,
I am not that experienced with Matlab errors and was wondering if anyone could help me with why I keep getting this error:
Error using MaxFunctionProblem (line 73)
Not enough input arguments.
Error in fmincon (line 601)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in MaxFunExe (line 25)
[P,W,U,Wprime,Uprime,fval] =
fmincon(@MaxFunctionProblem,x0,[],[],[],[],[],[],@confun,options);
Caused by:
Failure in initial user-supplied objective function evaluation. FMINCON
cannot continue.
Below is my complete program including the functions:
function E = MaxFunctionProblem(P,W,U,Wprime,Uprime)
% Function Formulations
% Multiobjective function
D1 = 0.2;
a = 2;
b = 0.2;
d = 0.1;
e = 2;
k = 1;
P1 = 1;
P2 = 6;
W1 = 1;
W2 = 5;
U1 = 1;
U2 = 6;
W3 = 10;
L = 10;
a2 = 0.01;
b2 = 0.005;
i = 1;
g = 0.1;
t = 0;
r = mvnrnd (0,6);
Theta0 = .005;
Theta1 = .01;
Theta2 = .01;
Theta3 = .02;
Inf = 50;
% Expected Unit Profit
% Unknown variables: P,W,U, Uprime, Unit Price
Pprime = 0.2;
v = (0.1*Pprime);
% Expected Unit Production Costs
Ltr = Theta0+(Theta1*r)+(Theta2+(Theta3*r))*t;
FuncEct = @(t,L)(a2 + (b2/(Ltr^i)))*(1-(g*(t)));
ECTf = integral(FuncEct,t,L);
% ECTf = @ExpUnitProdCost;
%%%%%%Expected Unit Profit %%%%%%
% q = integral(fun,xmin,xmax) example
% q = integral(fun,xmin,xmax,Name,Value)
%FuncEct = @(t,L)(a2 + (b1/(Ltr^i)))*(1-(g*t));
%ExpUnitProdCostX = integral(ECTf,t,L);
Lfun = @(t,r)Theta0+(Theta1*r)+((Theta2+(Theta3*r)).*t);
L1 = integral2(Lfun,t,W,r,(U/W));
L2 = integral2(Lfun,t,(U/r),(U/W),Inf);
Cs = 0.05*P;
ExpUnitWarCost = Cs*(L1 + L2);
ExpUnitProfit = (P + v) - ECTf - ExpUnitWarCost;
%%%%%%Expected increase in market share %%%%%%
Pprime = .2;
D = D1/((P1^(-a))*((W2 + k)^b)*U2^d);
Q = (D*(P^(-a))*((W + k)^b)*(U^d));
Qprime = (D*(P^(-a))*((Wprime + k)^b)*(((Uprime)^d)*((1 + v)^(-e))));
ExpIncMarketShare = (Pprime*Qprime) + ((1 - Pprime))*Q - Q;
%%%%%%Unit Price %%%%%
UnitPrice = P;
%%%%%%Market share without extension of warranty %%%%%%
MarShareWOExtWar = Q;
E = -(ExpUnitProfit*ExpIncMarketShare)/(UnitPrice*MarShareWOExtWar);
function [c, ceq] = confun(P,W,U,Wprime,Uprime)
P1 = 1;
P2 = 6;
W1 = 1;
W2 = 5;
U1 = 1;
U2 = 6;
W3 = 10;
U3 = 12;
c = [-P + P1;
P - P2;
-W + W1;
W - W2;
-U + U1;
U - U2;
-Wprime + W
Wprime - W3
-Uprime + U
Uprime - U3];
ceq = [];
x0 = [3,4,4,2,2];
options = optimset('Algorithm','active-set');
[P,W,U,Wprime,Uprime,fval] = fmincon(@MaxFunctionProblem,x0,[],[],[],[],[],[],@confun,options);
I am trying to find the minimization for 5 unknown variables using 5 constraints. Since this is kind of a complicated problem, i am sort of lost now. Any help would be greatly appreciated. Thanks :)

Accepted Answer

Alan Weiss
Alan Weiss on 24 Sep 2012
I wonder if you understand what type of arguments fmincon is expecting. The quantities you want to optimize should be in a single vector, usually called x. So if you want to find values of P, W, U, Wprime, and Uprime, you should write your objective and constraint functions to take a vector x, and then say things like
function E = MaxFunctionProblem(x)
P = x(1);
W = x(2);
U = x(3);
...
function [c, ceq] = confun(x)
P = x(1);
W = x(2);
U = x(3);
...
etc.
Also, I wonder about your statement Inf = 50. I believe you should not override MATLAB's value.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Comment
Kam Selley
Kam Selley on 25 Sep 2012
Thanks a lot for the clarification! That definitely helped. I did change the inf bound.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!