problem with writing uncommon constraint function in genetic algorithm???

조회 수: 1 (최근 30일)
Hamid
Hamid 2015년 12월 13일
댓글: Alan Weiss 2015년 12월 28일
Hi everyone, How to write a constraint function in genetic algorithm that is not directly related to fitness function?
for example, suppose that fitness=x1+x2 ; y1<y2 while y1 and y2 is dependent on x1,x2 and other some parameters.
Any suggestion will be great help and I appreciate that.
thank you guys.

답변 (1개)

Alan Weiss
Alan Weiss 2015년 12월 16일
Take a look at the documentation of nonlinear constraints. Your nonlinear constraint function would be something like this:
function [c,ceq] = confun(x)
% calculate y1 here
% calculate y2 here
c = y1 - y2;
ceq = [];
If confun depends on other parameters besides x, see Passing Extra Parameters.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 4
Hamid
Hamid 2015년 12월 18일
Alan, I changed the code but I got this error:
??? Undefined function or variable 'GPR'.
Error in ==> myconstr at 3
c(1) = Etouch-GPR ;
thanks man.
Alan Weiss
Alan Weiss 2015년 12월 28일
I think that the error message is clear: GPR is undefined when the nonlinear constraint function runs. I suggest that you use the debugger to find out why.
Alan Weiss
MATLAB mathematical toolbox documentation

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

카테고리

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