HELP in Genetic Algorithm for using integer constraints and linear constraints
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am using Genetic Algorithm Toolbox(GUI) for double vector population..
I have a problem with that.
I want to use linear constraints and integer boundaries together for double vector population. But i could not do this.
Is there a solution for that issue??
Thanks for help.
[Merged information from clarifying Question]
I have a function like that;
function y = rastrigins(x)
n = 4;
s = 0;
for j = 1:n
s = s+(x(j)^2-10*cos(2*pi*x(j)));
end
y = 10*n+s;
I want to add integer constraints for that function to each variable, such as;
0<x(1)<15
0<x(2)<20
0<x(3)<5
0<x(4)<5
Do i have a chance for that?
Thanks..
2 comentarios
Sargondjani
el 13 de Mayo de 2012
it would help if you explain why you couldnt do this:
-give error message
-(relevant) part of your code (your try)
Respuestas (3)
Alan Weiss
el 14 de Mayo de 2012
rastriginsfcn.m ships with Global Optimization Toolbox (you don't have to write a separate function). See http://www.mathworks.com/help/toolbox/gads/bsa_e27.html.
Integer constraints were added to the toolbox in R2011b. If you have that version or later, you can use mixed integer programming.
To add the constraints you mention, use the following:
lb = [1,1,1,1];
ub = [14,19,4,4];
IntCon = [1:4];
x = ga(@rastriginsfcn,4,[],[],[],[],lb,ub,[],IntCon)
Alan Weiss
MATLAB mathematical toolbox documentation
3 comentarios
Alan Weiss
el 16 de Mayo de 2012
I do not understand you. There is no problem using integer constraints with any type of inequality onstraint. What "help menu of constraints" are you referring to?
If you want to use the optimization tool, feel free to export your options to the workspace, save them, and import them again when you like. See <http://www.mathworks.com/help/toolbox/optim/ug/bquu7oa-1.html this link>. You don't have to use my code, feel free to set up the constraints in the optimization tool.
Alan Weiss
MATLAB mathematical toolbox documentation
owr
el 16 de Mayo de 2012
Perhaps he is getting cofused with the "bitstring" value in the "PopulationType" setting? On the doc page for gaoptimset it still says the following for 2012A:
"Note that linear and nonlinear constraints are not satisfied when PopulationType is set to 'bitString' or 'custom'."
I know this isnt the same as the integer constraints that were introduced in ga more recently, just pointing this out as a potential source of confusion.
Herdi Leuveano
el 7 de Dic. de 2015
I also have the same problem with you. When I run the GA using the toolbox, the GA cannot run work with constrained given. How can I fix this problem? Is there any specific tutorial from MathWorks or other sources to fix this problem. Thank you
2 comentarios
Walter Roberson
el 7 de Dic. de 2015
Herdi, are you using rastrigins as well? What constraints are you passing? Which MATLAB version are you using?
Herdi Leuveano
el 7 de Dic. de 2015
No. I have my own function but little bit same with rastigins. Im using matlab R2011b. The problem is same, when I set the integer variable indices, the GA will not satisfy the solution. I need my solution is in integer values. But when I set the workspace (Integer variable indices) as [1:37] in Ga toolbox, the objective function value becomes 0. How can I fix this problem? Thank u
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!