필터 지우기
필터 지우기

How can I optimize the following conditions using Genetic Algorithms.

조회 수: 1 (최근 30일)
I have a objective function
y=obj(x,N,phaseNoise)
Where
  • x -> decision variable of length N.
  • PhaseNoise -> a random variable.
And I have a constraint function
[C Ceq]=constraint (x,N)
Where x & N same as above.
I need to call GA using those two function.
But GA only assumes both Objective function and Constraints function should be depend on x of same length.
How can I achieve Generic Programming?

채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 31일
N = ...
phaseNoise = ...
A = []; b = [];
Aeq = []; beq = [];
lb = []; ub = [];
nonlcon = @(x) constraint(x, N);
intcon = ...
options = ....
fun = @(x) obj(x, N, phaseNoise);
ga(fun, N, A, b, Aeq, beq, lb, ub, nonlcon, intcon, options)
  댓글 수: 9
Walter Roberson
Walter Roberson 2018년 2월 1일
creatAnonymousFcn is not part of any of the more-than 50 toolboxes that I have installed, not as a major function and not as any internal method called by a function.
Walter Roberson
Walter Roberson 2018년 2월 1일
You have
for n=0:N-1
m(n)=m(n)+x(n)*(-1)^(N-n-1)*x(N-n-1)*phase(n);
end
which starts n at 0 and then uses m(n), which is an attempt to index m at location 0, which is not permitted in MATLAB.

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

추가 답변 (1개)

Dhanu Naik
Dhanu Naik 2018년 2월 1일
But I am getting that error about Anonymous function. Can u please go through the attached codes. A3.m is main function.

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by