Effacer les filtres
Effacer les filtres

How to write matlab code for optimization of this equation ?

2 vues (au cours des 30 derniers jours)
Seshadri Behera
Seshadri Behera le 11 Août 2014
Commenté : Seshadri Behera le 11 Août 2014
Hello, I want to optimize the following equation with particle swarm optimization algorithm. f(x)=(1/(n*xmax))* (summation(xi)) ; where i is the index varying from 1 to n, xmax is the maximum value of x & range of x is (0.003, 316.2).

Réponse acceptée

Johan Löfberg
Johan Löfberg le 11 Août 2014
Modifié(e) : Johan Löfberg le 11 Août 2014
Do you absolutely have to use particle swarm optimization?
I would conjecture that the optimal solution is to let all but one element take the value 0.003, and the last element the value 316.2
The following test shows that this is the case for your setup. It uses the MATLAB Toolbox YALMIP to formulate the problem, and assumes you have a mixed-integer solver installed
n = 20;
m = 0.003;
M = 316.2;
x = sdpvar(n,1);
% Conjecture
xbest = [repmat(m,n-1,1);M];
costbest = sum(xbest)/(length(xbest)*max(xbest));
% Recover the conjectured solution by stating problem as mixed-integer problem
solvesdp([m <= x <= M, sum(x) <= length(x)*max(x)*costbest])
% Try to obtain a slightly better solution will fail and lead to
% infeasibility
solvesdp([m <= x <= M, sum(x) <= length(x)*max(x)*costbest*0.9999])
Shouldn't be too hard to prove that the conjecture holds.
  1 commentaire
Seshadri Behera
Seshadri Behera le 11 Août 2014
Thank you for the answer. But it's an assignment to use PSO to optimize this equation. So I must write the code using PSO.

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