Having problems creating inequality constraints for genetic algorithm

1 次查看(过去 30 天)
Hi! I am having some problems with my GA, I use a fitness function that gives me the min cost of operation and creates values of power generated in each generator, in my case 6, to which i called Pg. My Pg will be a vector of 1x6 and for every value of Pg, i.e. Pg1,...,Pg6, I will have some prohibited operation zones: Pg1-> [210 240] [350 380]; Pg2-> [90 110] [140 160]; Pg3-> [150 170] [210 240]; Pg4-> [80 90] [110 120]; Pg5-> [90 110] [140 150]; Pg6-> [75 85] [100 105]; My problem is that every time I see people doing something with intervals it is usualy as boundaries, but I cant do it because I already have them as Pgmax for UB and Pgmin for LB. How can I create the constraints function in order to make these as prohibited zones for my Pg values? Thanks and Im sorry if I didnt explain something properly, I am still new to GA. EDIT: Im going to put some code in case I didnt explain myself properly.
%%My main
...
Pmin=[100 50 80 50 50 50 ];
Pmax=[500 200 300 150 200 120];
LB=Pmin;
UB=Pmax;
nvars=6;
[Pg,Fval] = ga(ObjFcn,nvars,[],[],[],[],LB,UB,ConsFcn,Options);
--------------
%%My fitness function
...
z=0;
for i=1:1:6
z=a(i)*(Pg(i)^2)+b(i)*Pg(i)+c(i)+abs(e(i)*sin(f(i)*(Pmin(i)-Pg(i))))+pen*
(Pdemand-Ploss-sum(Pg))^2+z;
end

回答(2 个)

Alan Weiss
Alan Weiss 2017-7-12
You need to represent these nonconvex constraints either as nonlinear constraints OR reformulate your problem to have 2^6 different possibilities, and investigate all 2^6 = 64 possibilities.
1. For the nonlinear constraint approach, I will give you just one example, you generalize to the other constraints. For a 2-element real vector t with t(1) < t(2) define
function f = nomiddle(x,t)
f = (x-t(1))*(t(2)-x);
This f is positive when t(1) < x < t(2) and is negative otherwise. So it represents the constraint that x <= t(1) OR x >= t(2). So one of your constraints, that x is not in the region [240,350], could be
function [c,ceq] = cons1(x)
ceq = [];
c = nomiddle(x,[240,350]);
2. Set your bounds to allow only the regions that are OK, such as x(1) is in [210 240], x(2) is in [140 160], etc. Do that for each of the 2^6 possibilities.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  4 个评论
Luis Manito
Luis Manito 2017-7-12
编辑:Luis Manito 2017-7-12
Ups sry I actually didnt implement it that way in my program, I did "c(1)=...; to c(6)=...;". Now in this new one you showed me I implemented it like this:
c(1) = nomiddle(Pg(1),[210,240,350,380]);
c(2) = nomiddle(Pg(2),[90,110,140,160]);
c(3) = nomiddle(Pg(3),[150,170,210,240]);
c(4) = nomiddle(Pg(4),[80,90,110,120]);
c(5) = nomiddle(Pg(5),[90,110,140,150]);
c(6) = nomiddle(Pg(6),[75,85,100,105]);
This way I should have no Pg values inside [t(1),t(2)] and inside [t(3),t(4)], however sometimes that doesnt happen and some intervals are violated. Perhaps it has something to do with my fitness function... Thanks for helping!
EDIT:
%One of my results for Pg values
(unfortunatly the values dont stay consistent for each run I do...)
Pg = [408.450 185.710 241.536 112.851 199.396 102.224]
you can see Pg(4) and Pg(6) violate the intervals [110,120] and [100,105] respectively.

请先登录,再进行评论。


ASIF
ASIF 2023-11-8
I am also facing the same problem to implement these Prohibited operation zone values as; Pg1-> [210 240] [350 380]; Pg2-> [90 110] [140 160]; Pg3-> [150 170] [210 240]; Pg4-> [80 90] [110 120]; Pg5-> [90 110] [140 150]; Pg6-> [75 85] [100 105]; for 6 generators using LSA. My problem is that i want to try this vector values with ramp limit coefficnets. kindly help me in this to implement POZ values in LSA Code;

类别

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