フィルターのクリア

Particle Swarm Optimization code

4 ビュー (過去 30 日間)
Sana Mohamed
Sana Mohamed 2021 年 4 月 7 日
コメント済み: Alan Weiss 2021 年 4 月 8 日
I have this code for Particle Swarm Optimization (PSO) and the matlab shows this error :
First of all, I dont have equality constraints. Second there's an error shows: "Unrecognized function or variable 'PSO_non_linear_constraint'."
clc %clears the command window
clear all % clears the previous work space
close all % closes the privous graphical objects(figures)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% constrained function with equality and inequality contraints
fun=@(x)1.1*x(1) + 1.2*x(2) + 2*x(3) + 1.3*x(4) + 3*x(5);
%%
constraints=@(x)[-8*x(1) - 2*x(2) - 15*x(3) - 4*x(4) - 30*x(5) + 60;
-9*x(1) - 3*x(2) - 3*x(3) - 1*x(4) - 9*x(5) + 100;
-35*x(1) - 3*x(2) - 17*x(3) - 1*x(4) - 16*x(5) + 120;
-100*x(1) - 90*x(2) - 350*x(3) - 200*x(4) - 410*x(5) + 2100;
-10*x(1) - 20*x(2) - 40*x(3) - 25*x(4) - 40*x(5) + 400;];
constraints_eq=@(x)[];
nvars=5; % number of variables to be optimized
LB=[0;0;0;0;0];
UB=[Inf;Inf;Inf;Inf;Inf];
Npop=200;
max_iter=5000;
[Xmin,Fmin]=PSO_non_linear_constraint(fun,constraints,constraints_eq,LB,UB,nvars,Npop,max_iter);
  1 件のコメント
Alan Weiss
Alan Weiss 2021 年 4 月 8 日
That is not code that runs for the particleswarm function from Global Optimization Toolbox. You will have to ask the author of that toolbox any questions.
Alan Weiss
MATLAB mathematical toolbox documentation

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle Swarm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by