How to solve this problem using PSO?

2 ビュー (過去 30 日間)
Jeong_evolution
Jeong_evolution 2017 年 9 月 13 日
コメント済み: Alan Weiss 2017 年 9 月 14 日
Hi all,
I have some problem using pso algoithm.
fcn = @(x) x(1) + x(2) + x(3)
lb = [-40 -40 -40];
ub = [40 40 40];
nvars = 3;
x = particleswarm(fun,nvars,lb,ub);
In this code, I want to 8.8 <= x(1)+x(2)+x(3) <= 79.2 (constraint)
But I don't know use this expression.
Plz help ..

採用された回答

Alan Weiss
Alan Weiss 2017 年 9 月 13 日
Unfortunately, particleswarm does not currently support linear constraints. You really should use linprog for this kind of problem.
You can also try a penalty function, say fcn = 1e6 when sum(x) < 8.8 or sum(x) > 79.2.
But linprog is the best solver for linear problems with linear constraints.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 件のコメント
Jeong_evolution
Jeong_evolution 2017 年 9 月 14 日
Excuse sir, Should I know Why can not pso do it?
Alan Weiss
Alan Weiss 2017 年 9 月 14 日
There are two solvers in Global Optimization Toolbox that support only bound constraints: particleswarm and simulannealbnd. Similarly, there are solvers in Optimization Toolbox that do not support constraints or support only bound constraints: fminunc, lsqcurvefit, fsolve, and others. Choose a solver that works for you.
And even more, for smooth problems, use an Optimization Toolbox solver, not a Global Optimization Toolbox solver.
Alan Weiss
MATLAB mathematical toolbox documentation

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange비선형 최적화 についてさらに検索

Community Treasure Hunt

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

Start Hunting!