MATLAB: bnb20 (Branch and Bound Method) Optimization -
i've got error when running following code in matlab. i'm trying use bnb20.
function [errmsg,z,x,t,c,fail] = optimize_bnb_test p = [34336 701 227 2860 32841 463 616 39769 331 1224 1515 472583 1021 969 9260 39380 4986 6567 3386 16926 4841 100635]; c = 31300; = [-c 0 0; 0 -c 0; 0 0 -c;]; b =[-p(1); -p(2); -p(3);]; function y = linear_objective(n) y = [1, 1, 1] * n; end lb = [1; 1; 1;]; ub = [16; 16; 16; ]; [errmsg,z,x,t,c,fail] = bnb20('linear_objective',lb,[],lb,ub,a,b, [],[],[],[],[],[]); end i got error message 'fun cause error.'
i don't know why.
i'm learning matlab.

update:
function [errmsg,z,x,t,c,fail] = optimize_bnb_test p = [34336 701 227 2860 32841 463 616 39769 331 1224 1515 472583 1021 969 9260 39380 4986 6567 3386 16926 4841 100635]; c = 31300; = [-c 0 0; 0 -c 0; 0 0 -c;]; b =[-p(1); -p(2); -p(3);]; lb = [1; 1; 1;]; ub = [16; 16; 16;]; fun = @(x)x(1)+x(2)+x(3); [errmsg,z,x,t,c,fail] = bnb20('fun',lb,[],lb,ub,a,b,[],[],[],[],[]); end error message changed:

i don't know now..
the error happens following call:
eval(['z=',fun,'(x0,varargin{:});'],'errmsg=''fun caused error.''; evalreturn=1;'); my guess varargin{:} giving error function. looks don't use it, empty. try either of:
1.- delete last ,[] call bnb20 13th input argument optional, instead of giving empty array ([]), don't give anything.
2.- when define function evaluate, define input arguments dump (or not use them).
function y = linear_objective(n,varargin) y = [1, 1, 1] * n; end
Comments
Post a Comment