How does make function of this equation?
이전 댓글 표시
Can anyone help me,how to implement this equation in MATLAB?
This is basically the fitness function of genetic algorithm.
댓글 수: 5
darova
2019년 12월 22일
Where is the data?
Misbah Habib
2019년 12월 22일
darova
2019년 12월 22일
ja nie ponimaju
dpb
2019년 12월 22일
Attach expression we can read w/o downloading a file, please...
Misbah Habib
2019년 12월 23일
답변 (3개)
Misbah Habib
2019년 12월 23일
0 개 추천
댓글 수: 1
Walter Roberson
2019년 12월 23일
What is the variable of summation? Is the i in gi(j) the same as the i in li-1 ?
The variables potentially used in the summation are i and j, but both of those appear to be used in the bounds of summation.
Walter Roberson
2019년 12월 23일
1 / (N * sum(C(sub2ind(size(C), gi(1:end-1), gi(2:end)))))
... under various assumptions about what the equation is intended to mean.
댓글 수: 5
Misbah Habib
2019년 12월 23일
Walter Roberson
2019년 12월 23일
In that case it would generally be more robust to use the negative of the reciprocal, and without the N factor.
Walter Roberson
2019년 12월 23일
That is, for optimization you would use
- sum(C(sub2ind(size(C), gi(1:end-1), gi(2:end))))
Again, this depends upon what some of the terms mean. I have interpreted
as indicating that gi is a vector of node numbers, and that
is the "cost" associated with traveling from the node designated by
to the node
and that Cis a matrix not a function. This would, for example, be used in a Travelling Salesman Problem, except that in a Traveling Salesman problem you would be wanting to minimize the sum, not maximize it (maximal sum leads to minimal
)
as indicating that gi is a vector of node numbers, and that
is the "cost" associated with traveling from the node designated by
and that Cis a matrix not a function. This would, for example, be used in a Travelling Salesman Problem, except that in a Traveling Salesman problem you would be wanting to minimize the sum, not maximize it (maximal sum leads to minimal
Misbah Habib
2019년 12월 24일
Walter Roberson
2019년 12월 24일
When you are doing the optimization, what would the input be?
If the input is a list of nodes forming a path, and you are trying to find an optimal path, then be aware that your current expression will find the path with highest C entries, which is presumably the same thing as the path with the highest cost. The higher the cost of the path, the lower the value of 1/N * 1/cost .
If your C represents distance or represents energy use to transmit from one node to another, then minimizing your
would involving maximizing your cost, which would in turn involve shooting messages as far away as possible and then back closer as the least efficient path would lead to highest sum() and that leads to lowest reciprocal-of-sum.
Misbah Habib
2019년 12월 24일
0 개 추천
댓글 수: 3
Walter Roberson
2019년 12월 25일
numvar = min(size(C,1), size(C,2));
obj = @(gi) -sum(C(sub2ind(size(C), gi(1:end-1), gi(2:end))));
A = []; b = [];
Aeq = []; beq = [];
lb = 1 * ones(1, numvar);
ub = numvar * ones(1, numvar);
nonlcon = @(gi) numvar - length(unique(gi)); %positive if there are duplicates
intcon = 1 : numvar;
[best_gi, cost] = ga(obj, numvar, A, b, Aeq, beq, lb, ub, nonlcon, intcon);
Warning: this is a very inefficient way of expressing that the values must be a permutation of integers !!!
Misbah Habib
2019년 12월 25일
Walter Roberson
2019년 12월 25일
You would do a lot more efficient with ga() if you did not use intcon and instead used a custom creation and custom mutation and custom crossover functions that "just happened" to impose permutations.
카테고리
도움말 센터 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
