"too many output arguments". gamultiobj Optimization Toolbox
显示 更早的评论
Hi, I want to use the gamultiobj algorithm to solve a multiobjective optimization problem (optimize cutting parameters of tooling machines). I already wrote the fitness function and want now to solve it with the gamultiobj algorithm. But, when I try to run it, I get the error "Optimization running. Error running optimization. Too many output arguments.". Can you say me why there are too many output arguments?!?
function y = fit(x)
y = zeros(size(x,1),3);
y(:,1) = t_r*ones(length(x(:,1)),1) + t_n*ones(length(x(:,1)),1) + V./((10^3)*(x(:,1).*(x(:,2).*x(:,3)))) + (V./((10^3)*(x(:,1).*(x(:,2).*x(:,3))))).*(t_w./(A3*(x(:,1).^A6).*((x(:,2).^A4).*(x(:,3).^A2))));
y(:,2) = K_ML*t_r*ones(length(x(:,1)),1) + K_ML*t_n*ones(length(x(:,1)),1) + K_ML*(V./((10^3)*x(:,1).*(x(:,2).*x(:,3)))) + (V./((10^3)*(x(:,1).*(x(:,2).*x(:,3))))).*((t_w*K_ML)./(A3*(x(:,1).^A6).*((x(:,2).^A4).*(x(:,3).^A2)))) + (V./((10^3)*x(:,1).*(x(:,2).*x(:,3)))).*((K_WT)./(A3*(x(:,1).^A6).*((x(:,2).^A4).*(x(:,3).^A2))));
y(:,3) = ((x(:,2).^2)/(8*r_e)); %.*(a.^0).*(v.^0)
end
The parameters (K_ML, ...) are already implemented.
Thank you!
回答(1 个)
Alan Weiss
2015-7-16
Your objective function looks vectorized. Did you set options to have vectorized function evaluations?
options = gaoptimset('Vectorized','on');
Also, as a first debugging step, can you take a row vector (not matrix) input vector x and compute y = fit(x) and check that it is a 3-element row vector? If so, then take x as a matrix with two rows and check that y = fit(x) is also a matrix with 2 rows.
Alan Weiss
MATLAB mathematical toolbox documentation
5 个评论
Sebastian Sickmann
2015-7-17
Alan Weiss
2015-7-17
Then I will need more information. Can you please give your exact call to gamultiobj, including all options and any other relevant input arguments?
Alan Weiss
MATLAB mathematical toolbox documentation
Sebastian Sickmann
2015-7-20
Alan Weiss
2015-7-20
Thank you for the information. I was able to get the optimization to run in part, but it halted due to complex values in the objective function. You probably need to introduce some bounds in your optimization in order to prevent complex values from appearing.
How did I get the optimization to run while you could not? I suspect that your objective function is poorly named. fit.m is a function in Curve Fitting Toolbox, and if you have that toolbox then MATLAB might be confused over which function file to use. I suggest that you change the name from fit.m to something unique.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Sebastian Sickmann
2015-7-21
类别
在 帮助中心 和 File Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!