- 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
2 ビュー (過去 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!