필터 지우기
필터 지우기

help how can I use the PSO algorithme for the case of a matrix ?!

조회 수: 3 (최근 30일)
Imane hammou ouali
Imane hammou ouali 2019년 4월 9일
편집: Stephan 2019년 4월 10일
Hello community,
I want to apply the PSO algirithme for a matrix, if someone have the matlab code or any idea or recommendation please
Thanks

답변 (1개)

Stephan
Stephan 2019년 4월 9일
Hi,
you can use the reshape function and take advantage of the linear indexing in Matlab. This will allow to work with matrices too.
Best regards
Stephan
  댓글 수: 4
Imane hammou ouali
Imane hammou ouali 2019년 4월 10일
well , my objective function is a matrix , and i'm searching how can i return a maximum of this matrix with a constraint predefined.
Stephan
Stephan 2019년 4월 10일
편집: Stephan 2019년 4월 10일
Perhaps this helps:
>> A = [1 2 3; 4 5 6; 7 8 9]
A =
1 2 3
4 5 6
7 8 9
>> A(3)
ans =
7
%-------------------------------------------------------------
>> B = reshape(A,1,[])
B =
1 4 7 2 5 8 3 6 9
>> B(3)
ans =
7
%-------------------------------------------------------------
>> C = reshape(B,3,3)
C =
1 2 3
4 5 6
7 8 9
>> C(3)
ans =
7
--> You can give an array of size 1xn to the objective function (this is what PSO will do) and then reshape it to size ixj to perform matrix calculations inside your objective function. This works because the linear indexing and is done easily using reshape. As long as your objective function returns a scalar value as result, this will work properly.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Particle Swarm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by