Having problems creating inequality constraints for genetic algorithm
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (2)
Alan Weiss
le 12 Juil 2017
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 commentaires
ASIF
le 8 Nov 2023
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;
0 commentaires
Voir également
Catégories
En savoir plus sur Genetic Algorithm dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!