- First make sure that the constraints in the 'constraint' function are all inequalities because equality constraints are not allowed while using the integer 'ga' solver.
- You need to check the 'exitflag' and make sure that the solver is able to find a feasible solution. One possibility as to why you are getting non-integer values is that the solver is not able to find a feasible solution. You can check the list of exit flags in the following link: http://www.mathworks.com/help/gads/ga.html#zmw57dd0e32305
- Regarding imposing binary constraints, you can simply add them as lower and upper bounds. 'ga' solves integer problems best when you provide lower and upper bounds for every 'x' component. You can also refer to the following link for more information on Integer optimization. http://www.mathworks.com/help/gads/mixed-integer-optimization.html
Binary/Integer variables in genetic algorithm
조회 수: 10 (최근 30일)
이전 댓글 표시
I want to define some variables as integer and constraint them to be binary. Even though I set the IntCon matrix the variables that I want to be integer, the ga doesn't recognize them as integers.
function [x,fval,exitflag,output,population,score] = model()
nvars=64;
IntCon=[33:64];
TolFun_Data=10^-2;
TolCon_Data=10^-2;
options = gaoptimset;
options = gaoptimset(options,'TolFun', TolFun_Data);
options = gaoptimset(options,'TolCon', TolCon_Data);
[x,fval,exitflag,output,population,score] = ga(@objective,nvars,[],[],[],[],[],[],@constraint,IntCon,options);
The solution for the integer variables is always a non-integer value. (such as 0.0221, -0.0153).
Also, should I constraint the integer variables to binary [0,1] using linear constraint lb,ub?
댓글 수: 0
답변 (1개)
Ghada Saleh
2015년 7월 15일
편집: Ghada Saleh
2015년 7월 15일
Hi Stefanos,
I understand that the output of the generic optimization is not integer for the variables specified in 'IntCon' as integers. I would check the following:
I hope the above information helps.
Ghada
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!