HELP in Genetic Algorithm for using integer constraints and linear constraints

2 vues (au cours des 30 derniers jours)
b
b le 12 Mai 2012
Commenté : Herdi Leuveano le 7 Déc 2015
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 commentaires
Sargondjani
Sargondjani le 13 Mai 2012
it would help if you explain why you couldnt do this:
-give error message
-(relevant) part of your code (your try)
b
b le 13 Mai 2012
When i added my integer constraints and linear constraints(equation) together, the error is ;
Optimization running. Objective function value: Could not find a feasible initial point.
Also, in the help part of Genetic Algorithm Toolbox, it explains that you can not use these two together. But is there a solution for that?

Connectez-vous pour commenter.

Réponses (3)

Alan Weiss
Alan Weiss le 14 Mai 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)
For more information, see Constraints and Mixed Integer Optimization.
Alan Weiss
MATLAB mathematical toolbox documentation
  3 commentaires
Alan Weiss
Alan Weiss le 16 Mai 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
owr le 16 Mai 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.

Connectez-vous pour commenter.


b
b le 16 Mai 2012
How can i save my options for use in MATLAB?
If i can do it, your code would be useful

Herdi Leuveano
Herdi Leuveano le 7 Déc 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 commentaires
Walter Roberson
Walter Roberson le 7 Déc 2015
Herdi, are you using rastrigins as well? What constraints are you passing? Which MATLAB version are you using?
Herdi Leuveano
Herdi Leuveano le 7 Déc 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

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by