Azzera filtri
Azzera filtri

How to write matlab code for optimization of this equation ?

2 visualizzazioni (ultimi 30 giorni)
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).

Risposta accettata

Johan Löfberg
Johan Löfberg il 11 Ago 2014
Modificato: Johan Löfberg il 11 Ago 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 Commento
Seshadri Behera
Seshadri Behera il 11 Ago 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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by