Particle Swarm Optimization code
조회 수: 3 (최근 30일)
이전 댓글 표시
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
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 Exchange에서 Particle Swarm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!