Failure in initial user-supplied objective function evaluation.
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
I introduce the necesary data for the function rcpspdc.m
c=[0 -200 -450 120 170 -200 130 -40 0];
I make my function rcpspdc.m in another script and then i save it
function [npv] = rcpspdc (c,f)
m=(c(2)*exp(-0.01*(f(2))))+(c(3)*exp(-0.01*(f(3))))+(c(4)*exp(-0.01*(f(4))))+(c(5)*exp(-0.01*(f(5))))+(c(6)*exp(-0.01*(f(6))))+(c(7)*exp(-0.01*(f(7))))+(c(8)*exp(-0.01*(f(8))));
npv=-m;
now I make another script to call function and use fmincon function to find out minimum
f0=[0 10 7 8 12 9 12 12 0];
Aeq=[1 0 0 0 0 0 0 0 0];
beq=0;
A=[1 -1 0 0 0 0 0 0 0;1 0 -1 0 0 0 0 0 0;0 0 1 -1 0 0 0 0 0;0 1 0 0 -1 0 0 0 0;0 0 1 0 0 -1 0 0 0;0 0 0 0 0 1 -1 0 0;1 0 0 0 0 0 0 -1 0;0 0 0 0 0 0 0 1 -1;0 0 0 0 0 0 0 0 1];
b=[-3 -3 -1 -2 -2 -3 -3 0 12];
[f,fval] = fmincon(@rcpspdc,f0,A,b,Aeq,beq);
I am getting error messages as follow:
Warning: The default trust-region-reflective algorithm does not solve
problems with the constraints you have specified. FMINCON will use
the active-set algorithm instead. For information on applicable
algorithms, see Choosing the Algorithm in the documentation.
> In fmincon at 504
Warning: Your current settings will run a different algorithm
(interior-point) in a future release.
> In fmincon at 509
Error using rcpspdc (line 4)
Not enough input arguments.
Error in fmincon (line 635)
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation.
FMINCON cannot continue.
What should I must change? why does it say to me 'not enough input arguments'? what does 'initVals.f = feval(funfcn{3},X,varargin{:})' mean?
0 件のコメント
回答 (2 件)
Jingbo
2014 年 12 月 14 日
0 投票
I have the same problem. Did you solve this problem? Care to share with me?
0 件のコメント
Alex Zhu
2017 年 7 月 5 日
0 投票
You should use only one parameter for the function. E.G. function [npv] = rcpspdc (x) x(1)=c; x(2)=f;
1 件のコメント
Walter Roberson
2017 年 7 月 5 日
Correct. fmincon and related functions only pass a single parameter to the objective function. All values that are to be optimized should be merged into a single vector. Any auxiliary value needed for the calculation should be included by http://www.mathworks.com/help/matlab/math/parameterizing-functions.html
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!