How to use PSO (Particle swarm optimization) to optimize objective function containing two terms one of them kmeans clustering?
显示 更早的评论
Hi
I used PSO before to optimize an objective function.Now I have an objective(fitness) function containing two terms; one of them described by k-means clustering ..Euclidean distance?
采纳的回答
You have to pass a function handle as the objective function, but it does not have to be an anonymous function. You can pass the handle to a function that does extensive computation based on the inputs. The only requirement is that the output has to be a scalar.
If you are trying to minimize two distinct things simultaneously then you either need to decide their relative weighting to combine them into a scalar, or else you need to use gamultiobj() to find pareto fronts.
14 个评论
I do not understand that image?
You saw what is written in??
If you read it
You will see the objective function phi
the first term I made and I want to know how to implement the second term??
If any information you need I will give
This is what your image looks like at my end:

No phi, no first or second term.
that looks like weighted Euclidean not plain Euclidean .
Yes
Now ,how to make as code in MATLAB?
I have the Wi matrix so how to implement this weighted Euclidean distance?
To get results like these in the images

Use a nested for loop if you need to.
total = 0;
for j = 1 : K
for i = 1 : N2
total = total + sum(sum((W(i) * bsxfun(@minus, V(mu(j)).^i, mu(j)))).^2));
end
end
Here I assume that V_(mu_j) must indicate a function named V that is being passed a scalar mu(j) and is returning a vector or array -- if V_mu_j is a scalar then it makes less sense to talk about a Euclidean distance. If mu(j) represents a vector or array, or Wi is a vector or array, the code might need to be revised. If we had information about the relative dimensions we might potentially be able to write much more compact code.
Wi : is vector
See the attached for more
information
informationDear Walter Roberson,
Is there is compact code after the description in the last two images?
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Particle Swarm 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)




