how to apply pso to formula
6 views (last 30 days)
Show older comments
kyungdoo lee
on 26 Oct 2021
Commented: Star Strider
on 26 Oct 2021
i want to apply pso to function y = -0.0429x4 + 1.1527x3 - 11.178x2 + 43.153x + 19.63
0 Comments
Accepted Answer
Star Strider
on 26 Oct 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 Comments
Star Strider
on 26 Oct 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
fprintf('%23.15E\n',xe1)
[xe2,fval] = fminsearch(@(x)norm(y(x)), x0) % Mean Square Minimum
fprintf('%23.15E\n',xe2)
Experiment to get the desired result.
.
More Answers (0)
See Also
Categories
Find more on Particle Swarm in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!