Constrained Variable Genetic Algorithm
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
Need help on solving a problem with the GA toolbox (have a variant soln that works but am not sure of the soln). I have a function say 'piqe' that I am looking for the global minimum. The inputs to this function are (x1 ... xn). These inputs variables can only take values 1:5 (upper and lower bound).
However the variables serve as indexes (1 say leftmost, 5 rightmost) to a matrix function say
P = [30 20 10 5 0; 27 17 7 2 0; 20 14 4 0 0; 14 12 7 4 0; ..................];
I need to constrain the inputs to 'piqe' so that P(1,x1) + P(2,x2) + ...... + P(n,xn)<Constant.
I am having some problem on implementing the last part (relational constraint) into the toolbox. thanks
댓글 수: 2
Walter Roberson
2013년 3월 25일
When you say 1:5 do you mean the list 1, 2, 3, 4, 5? Or do you mean the range 1 to 5 ?
채택된 답변
Alan Weiss
2013년 3월 25일
It seems from your description that you want all the variables x1,...,xn to have integer values. If this is the case, and if you have MATLAB R2011b or later, then you can use integer programming. See the documentation of integer programming and also see this extensive example.
Setting nonlinear inequality constraints means programming a function in the proper syntax. For your case, of you have P defined in your workspace, then you can use something like
function [c,ceq] = pconstraint(x,P)
ceq = [];
c = -Constant; % put in the value of Constant here
for ii = 1:numel(x)
c = c + P(ii,x(ii));
end
Pass @(x)pconstraint(x,P) as your nonlinear constraint function. Also, I would advise you to give both an initial range of 1 to 5 on all componenets, and set a large population size.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
댓글 수: 0
추가 답변 (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!