필터 지우기
필터 지우기

How to implement theses constraints in the cost function ?

조회 수: 1 (최근 30일)
Anwar
Anwar 2022년 11월 16일
댓글: Anwar 2022년 11월 17일
I am working on a constrained PSO program (S decision variable) where the constraints are arrays that there elements should be lower or egual to 0.4 :
1) dx = [S(1) - 0.3, diff(S)];
2) ds = [0.3 - S(1),S(1:end-1)-S(2:end)];
abs(dx)<=0.4
abs(ds)<=0.4
in a simpler way,dx and ds should be arrays with elements that are less or egual to 0.4
i tried this : le(abs(dx),0.4)
le(abs(ds),0.4)
but when runing the main pso i dont see constrained results
  댓글 수: 2
Matt J
Matt J 2022년 11월 16일
i tried this
Where? How? pso() doesn't have an input for such constraints. Maybe use ga() or patternsearch(). Also, the constraints are linear, so you should put them in the form A*S<=b.
Matt J
Matt J 2022년 11월 16일
Also, from your expressions we can see that dx=-ds. Therefore, the constraints, abs(dx)<=0.4 and abs(ds)<=0.4 are the same thing.

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

답변 (1개)

Matt J
Matt J 2022년 11월 16일
편집: Matt J 2022년 11월 16일
pso() doesn't have an input for such constraints. Maybe use ga() or patternsearch().
Here's how it would look when solved with ga():
lb=-inf(nvars,1);
ub=-lb;
e=0.4*ones(nvars-1,1);
D=diff(eye(nvars));
%constraint matrices
lb(1)=-0.1;
ub(1)=0.7;
A=[D;-D];
b=[e;e];
%run optimization
S = ga(fun,nvars,A,b,[],[],lb,ub)
  댓글 수: 12
Matt J
Matt J 2022년 11월 17일
The objective function came out of your brain. If it's returning the wrong value, I have no way of knowing what it should be returning instead.
Anwar
Anwar 2022년 11월 17일
Here is the original syntax of my function :
I don't know if there's a way out to this last step but this was really helpful,i mean getting steps forward with thoses constraints seting.Thanks a lot Matt J ,I appreciate .

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

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by