"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!

Answers (1)

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 Comments

I already set the options to have vectorized function evaluations! I also tried, as you explained, to compute the function with a row vector as input. The result was a 3-element row vector as well. The same with the 2x3 matrix. So I cannot explain why I again get the error "too many output arguments"...?!?
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
In the zip-file you can find my fitness function "fit.m" as well as the parameters "parameter_HSS.m" and the input variables "Schnittwerte Schruppen HSS". When I tried to run the optimization, these were my arguments:
function [x,fval,exitflag,output,population,score] = untitled(nvars)
%%This is an auto generated MATLAB file from Optimization Tool.
%%Start with the default options
options = gaoptimset;
%%Modify options setting
options = gaoptimset(options,'CrossoverFcn', { @crossoverintermediate [] });
options = gaoptimset(options,'Display', 'off');
options = gaoptimset(options,'PlotFcns', { @gaplotpareto });
options = gaoptimset(options,'Vectorized', 'on');
[x,fval,exitflag,output,population,score] = ...
gamultiobj(@fit,nvars,[],[],[],[],[],[],[],options);
end
It is vectorized. May there be any error regarding population, mutation etc...?!
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
Now I know the reason why the optimization did not run.
I did not fill in the fields for the constraints. There has to be a [] when there are not any constraints at all.
Thank you for your help!

Sign in to comment.

Categories

Asked:

on 16 Jul 2015

Edited:

on 4 Nov 2015

Community Treasure Hunt

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

Start Hunting!