Particle Swarm Optimization code

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개)

카테고리

질문:

2021년 4월 7일

댓글:

2021년 4월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by