pso example : f(x)= -x^2 + 2*x +11

in univeristy

2 Comments

What is your question?
See this link and then ask a question and improve your post, like by attaching data, diagrams, or anything else to allow us to help you.

Sign in to comment.

Answers (1)

f = @(x) -x^2 + 2*x + 11;
nvars = 1;
lb = []; ub = [];
options = optimoptions('particleswarm', 'MaxIterations', 10000);
[x, fval] = particleswarm(f, nvars, lb, ub, options);
fprintf('pso stopped at x = %g at which time the function value was %g\n', x, fval);

Tags

Asked:

on 9 Jun 2018

Answered:

on 9 Jun 2018

Community Treasure Hunt

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

Start Hunting!