how to apply pso to formula

2 visualizaciones (últimos 30 días)
kyungdoo lee
kyungdoo lee el 26 de Oct. de 2021
Comentada: Star Strider el 26 de Oct. de 2021
i want to apply pso to function y = -0.0429x4 + 1.1527x3 - 11.178x2 + 43.153x + 19.63

Respuesta aceptada

Star Strider
Star Strider el 26 de Oct. de 2021
The parameters have to be elements of a vector (and the appropriate operators must be provided, in this instance multiplication) —
y = @(x) -0.0429*x(4) + 1.1527*x(3) - 11.178*x(2) + 43.153*x(1) + 19.63
If the posted equation is actually something different, (such that ‘x4’ is actually ) those details — and a clear explanation of the actual problem — need to be provided. See the documentation on Anonymous Functions for details on them.
.
  2 comentarios
kyungdoo lee
kyungdoo lee el 26 de Oct. de 2021
Are you saying the question has errors like vector parameters?
Star Strider
Star Strider el 26 de Oct. de 2021
If the parameters to be optimised are ‘x’, they must be elements of a vector.
That is how the optimisation functions work.
Also, it is necessary to be clear about the objective of the optimisation.
For example —
y = @(x) -0.0429*x(4) + 1.1527*x(3) - 11.178*x(2) + 43.153*x(1) + 19.63;
x0 = rand(4,1);
[xe1,fval] = fminsearch(y, x0) % Absolute Minimum
Exiting: Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. Current function value: -4553455067893434311976313508498416664992637329080320.000000
xe1 = 4×1
1.0e+49 * -8.3765 8.4337 0.3630 0.4905
fval = -4.5535e+51
fprintf('%23.15E\n',xe1)
-8.376509228679389E+49 8.433651206800148E+49 3.629666932350592E+48 4.905026065674677E+48
[xe2,fval] = fminsearch(@(x)norm(y(x)), x0) % Mean Square Minimum
xe2 = 4×1
-0.1648 1.1516 0.3351 0.7555
fval = 8.3061e-05
fprintf('%23.15E\n',xe2)
-1.647817685875986E-01 1.151648047524384E+00 3.351060012819946E-01 7.554828255085815E-01
Experiment to get the desired result.
.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Particle Swarm en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by