fmincon error, please help me!
1 view (last 30 days)
Show older comments
fzstage2 = @(fkj, h2k, h2l) zstage2([fkj, h2k, h2l], demandrateSubregionBothDCs(1,j),...
distances(DCindexk, j), distances(DCindexl, j), spatialpointdensity(j),...
k, numberofstops(j), s2, ts, vmax2, cd, cr, dcs, ci, cif, cs);
fzstage2con = @(fkj, h2k, h2l) zstage2con([fkj, h2k, h2l], demandrateSubregionBothDCs(1,j),...
distances(DCindexk, j), distances(DCindexl, j), spatialpointdensity(j),...
k, numberofstops(j), s2, ts, vmax2);
decVar0=[0.5 1 1];
lb=[0,0,0];
ub=[1, 1000, 1000];
options=optimset('largescale','off','display','iter');
[decVaropt,fval,exitflag,output] = fmincon(fzstage2,decVar0,[],[],[],[],lb,ub,fzstage2con,options);
Err Msg:
Error using
@(fkj,h2k,h2l)zstage2([fkj,h2k,h2l],demandrateSubregionBothDCs(1,j),distances(DCindexk,j),distances(DCindexl,j),spatialpointdensity(j),k,numberofstops(j),s2,ts,vmax2,cd,cr,dcs,ci,cif,cs)
Not enough input arguments.
Error in fmincon (line 601)
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation.
FMINCON cannot continue.
function [ zstage2con ceq ] = zstage2con( DECVAR, DtotStage2j, rkj, rlj, SPDj, k, nsj, s2, ts, vmax2)
fkj = DECVAR(1);
h2k = DECVAR(2);
h2l = DECVAR(3);
...
function zstage2 = zstage2( DECVAR, DtotStage2j, rkj, rlj, SPDj, k, nsj, s2, ts, vmax2, cd, cr, dcs, ci2, cif, cs)
fkj = DECVAR(1);
h2k = DECVAR(2);
h2l = DECVAR(3);
...
help! T_T
0 Comments
Answers (1)
Alan Weiss
on 17 Jul 2014
If I understand you, then this is a syntax error. fmincon expects that the objective function is a function of one variable. This variable can be a matrix or vector. So if you have variables fkj, h2k, and h21, you should write your objective function as
function y = zstage(x)
fkj = x(1:21); % assumes fkj is a 21-element vector
h2k = x(22:40); % h2k is a 19-element vector
h21 = x(41); % h21 is a scalar
...
If I misunderstood what you were asking, feel free to ask again.
Alan Weiss
MATLAB mathematical toolbox documentation
0 Comments
See Also
Categories
Find more on Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!