Help please with MATLAB ga toolbox (Not enough input arguments)

Could someone please help me with this,
I am trying to minimize a 3 variable problem, and, keep getting this error in return,
"Not enough input arguments"
Number of variables = 3
Upper bounds = [80 6 2]
Lower bounds = [10 1 1]
Function used,
function y = pallab(x)
y = -0.59567+0.008793*x(1)+0.1025*x(2)+0.40967*x(3)-0.000266667*(x(1)*x(2))+0.0000*(x(1)*x(3))-0.013333*(x(2)*x(3))-0.0000504*(x(1)^2)-0.00683333*(x(2)^2)-0.106*(x(3)^2);
end
Thanks in advance

댓글 수: 2

Please show us your ga call, including any options that you passed.
Alan Weiss
MATLAB mathematical toolbox documentation
I hope this screenshot answers your queries. All options are at default at this point.

댓글을 달려면 로그인하십시오.

답변 (2개)

Alan Weiss
Alan Weiss 2017년 7월 6일
Try this command:
which -all pallab
Also try
type pallab
The reason I ask is that using exactly your stated function and using the Optimization app as you seem to be doing, I got no error.
Alan Weiss
MATLAB mathematical toolbox documentation

댓글 수: 1

I know, it works well for others. I posted the same on researchgate, and seemed to work for others. NOT JUST FOR ME.
I looked at the autogenerated codes,
THIS DOES NOT RUN,
function [x,fval,exitflag,output,population,score] = pallabga(nvars,lb,ub)
%%This is an auto generated MATLAB file from Optimization Tool.
%%Start with the default options
options = gaoptimset; %%Modify options setting
options = gaoptimset(options,'Display', 'off');
[x,fval,exitflag,output,population,score] = ...
ga(@pallab,nvars,[],[],[],[],lb,ub,[],[],options);
HOWEVER, THIS RUNS WELL,
function [x,fval,exitflag,output,population,score] = pallabgamultiobj(nvars,lb,ub)
%%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');
[x,fval,exitflag,output,population,score] = ...
gamultiobj(@pallab,nvars,[],[],[],[],lb,ub,options);
So, the multiobj is working, not just the standalone ga. What do you think?

댓글을 달려면 로그인하십시오.

Pallab
Pallab 2017년 7월 7일

0 개 추천

It compiled finally.
I don't know, what was wrong with it. I cleared up the entire MATLAB directory, deleted everything in it. And started with a fresh script. And it suddenly started working.
I just don't know, why and how. M glad though.

댓글 수: 2

If at one point you had a pallab that required more than one variable, it is possible it was still invoking that routine. If you change the function without using the Editor to change it, then you should use "clear pallab" to get rid of any old handles that might be around.
Thanks a lot. Cheers.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

질문:

2017년 7월 5일

댓글:

2017년 7월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by