HELP in Genetic Algorithm for using integer constraints and linear constraints

1 次查看(过去 30 天)
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 个评论
Sargondjani
Sargondjani 2012-5-13
it would help if you explain why you couldnt do this:
-give error message
-(relevant) part of your code (your try)
b
b 2012-5-13
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?

请先登录,再进行评论。

回答(3 个)

Alan Weiss
Alan Weiss 2012-5-14
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 个评论
Alan Weiss
Alan Weiss 2012-5-16
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 2012-5-16
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.

请先登录,再进行评论。


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

Herdi Leuveano
Herdi Leuveano 2015-12-7
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 个评论
Walter Roberson
Walter Roberson 2015-12-7
Herdi, are you using rastrigins as well? What constraints are you passing? Which MATLAB version are you using?
Herdi Leuveano
Herdi Leuveano 2015-12-7
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

请先登录,再进行评论。

类别

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