Nonlinear inequality in GA optimization with integer constraints

조회 수: 1 (최근 30일)
Yro
Yro 2020년 10월 18일
편집: Matt J 2020년 10월 20일
Hi, I am using GA optimization tool. The problem I am solving contains integer constraints (IntCon), but I need to set a non-linear inequality to the objective function. I am calculating the value of the function (k-eff) for patterns obtained from the genetic algorithm, but I need an inequality for the power, which must be kept below a certain value (power <= 1.3). What I consulted is that the inequalities [c, ceq] are set in the following way c(x) <= 0, so c(x) -1.3 <= 0. On the other hand for the problem with IntCon the ceq = [ ].
Thanks in advance.
  댓글 수: 2
Alan Weiss
Alan Weiss 2020년 10월 20일
And what is the question? You stated some correct restrictions on c and ceq. But I don't understand what you want from us.
Alan Weiss
MATLAB mathematical toolbox documentation
Yro
Yro 2020년 10월 20일
Hi, thanks for your reply. My question is when defining the constraints because my constraint is:
0.8 <= POWER <= 1.3
Would it be okay to define c as follows?:
function [c, ceq] = POWER_CONSTRAINT(~)
ceq = [];
POWER = load('POWER_PEAK.txt') ;
MIN = 0.8 ;
MAX = 1.3 ;
c = [MIN - POWER ; POWER - MAX] ; % 0.8 <= P <= 1.3
Thanks in advance.

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

답변 (1개)

Matt J
Matt J 2020년 10월 20일
편집: Matt J 2020년 10월 20일
In the code you have shown for POWER_CONSTRAINT(~), it does not make sense that POWER does not depend on the input, but rather on some independent .txt file. The point of the nonlinear constraint function is that it lets ga() query the feasibility of an input x. If the text file is supposed to have some dependence on x, then there should be code within POWER_CONSTRAINT(x) that regenerates POWER_PEAK.txt for the input x.
If the issue is that POWER_PEAK.txt is a heavy computation and you are trying to avoid repeating a computation that may have been already done elsewhere in your code, then read here:
  댓글 수: 2
Yro
Yro 2020년 10월 20일
Briefly, the problem I am solving depends on x (patterns obtained using GA), with this value I run an external simualtion code for the objective function evaluation. I get as result the function and POWER values written to the text file separately in each iteration. The constraint I am giving is the POWER for each x pattern.
For:
x1 ==> function and POWER
x2 ==> function and POWER
x3 ==> function and POWER...
I am not clear how the algorithm handles the restrictions, the code runs well when introducing the POWER_CONSTRAINT function, the results are also logical. There is no way to check if you are using that function?. The code I am running is the following:
options = optimoptions(@ga,'Display', 'iter', ...
'OutputFcn',@GA_OUTPUT ,...
'PlotFcn', {@gaplotbestf, @PLOT_FUNCTION},...
'MaxGenerations', 30, ...
'PopulationSize', POPULATION_SIZE, ...
'FunctionTolerance',1e-6, ...
'CrossoverFraction', 0.95, ...
'EliteCount', 0.5*30) ;
start_time = tic ;
[x,fval,exitflag,output,population,scores] = ...
ga(@OBJECTIVE_FUNCTION,nvars,A,b,Aeq,beq,lb,ub,@POWER_CONSTRAINT,IntCon,options) ;
end_time = toc (start_time) ;
Matt J
Matt J 2020년 10월 20일
편집: Matt J 2020년 10월 20일
with this value I run an external simualtion code for the objective function evaluation.
You are assuming though that the x that is passed to your constraint function will be the same as the x that ga() most recently passed to the objective function. Because that assumption is not always valid, however, your constraint function will sometimes need to re-run the simulation for the x that it receives as input. The link I gave you discusses how to implement that efficiently.
There is no way to check if you are using that function?
We don't have to check because it can be seen in your code that you are not using it. The input to POWER_CONSTRAINT is completely ignored.

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

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by