필터 지우기
필터 지우기

i'm getting Error using ga (line 305) help me

조회 수: 1 (최근 30일)
Arunachalam  D
Arunachalam D 2015년 4월 4일
댓글: Arunachalam D 2015년 4월 5일
Objective function
function z=my_fun(x)
z=x(1)+2*x(2)+56*x(3)+100;
constrain function
function [c]=const(x)
x=[6,3,4];
c1=(6<=x(1)<=100);
c2=(2<=x(2)<=4);
c3=(2<=x(3)<=4);
c=[c1;c2;c3];
main script
clear all
clc
nvars=3;
LB=[6 2 2];
UB=[100 4 4];
[x, fval]=ga(my_fun,nvars,[],[],[],[],[],[],LB,UB,@const)
when excecuted getting error
Error using ga (line 305)
Tenth input argument must be a valid structure created with GAOPTIMSET.
Error in start (line 6)
[x, fval]=ga(@my_fun,nvars,[],[],[],[],[],[],LB,UB,@const)
please help me by necessary changes to coding..

채택된 답변

Geoff Hayes
Geoff Hayes 2015년 4월 4일
Arunachalam - the error message is telling you that the tenth parameter/argument to the ga function is not the options object that should be created with the gaoptimset function. Instead, the tenth argument corresponds to UB, the array of upper bounds. If you look at the documentation for ga you will not that you are passing too many input parameters/arguments for what you have in mind. Your call to ga should be reduced to (according to the 2015a documentation)
x = ga(@my_fun,nvars,[],[],[],[],LB,UB,@const);
Note that you may also want to review the nonlcon documentation as it would appear that this function (your const) should return two outputs).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by