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?

 Réponse acceptée

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 commentaires

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:
Screen Shot 2019-01-19 at 6.17.24 PM.png
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 imagesScreenshot_20190120-134819.png
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 20190121_154807.jpginformation
Dear Walter Roberson,
Is there is compact code after the description in the last two images?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by