How to calculate velocity in PSO CVRP

1 vue (au cours des 30 derniers jours)
Ayobami Meadows
Ayobami Meadows le 11 Jan 2021
Commenté : Ayobami Meadows le 13 Jan 2021
I intend using the standard PSO to solve a vehicle routing problem that has been developed in a continuous form. My problem arrives when the velocity adds up to update the position, some exceeds the variable max/min which result in having repeated numbers in the updated position.
For instance VarMax=4 VarMin=1 initialposition(x) = [1 2 3 4]
When velocity adds up for Position update, it becomes Updatedposition =[1 4 4 2]
4 appeared twice because of the VarMax constraint, which will eventually result to an indexing error. Please I need a way to make those Updatedposition not to have repeated numbers after the velocity add up.
Exploring some research papers I found this method (quoted below) but don't know how to apply. Any other method is welcomed please.
"we turn each element of the solution into a floating point between [0, 1]. After calculating the velocity of all particles, the elements of the velocity vector are transformed back into the integer domain using relative position indexing. In this way, the smallest floating value is assigned to the smallest integer, the next highest floating value to the next integer and so on".

Réponse acceptée

Alan Weiss
Alan Weiss le 11 Jan 2021
If you simply want to sort the variables, I suggest that you apply the sort function.
nums = [1 4 4 2];
[~,snums] = sort(nums)
snums =
1 4 2 3
This might not be exactly what you want, because I am not sure what it is that you want.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 commentaire
Ayobami Meadows
Ayobami Meadows le 13 Jan 2021
It worked. Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by