I am using the Genetic Algorithm to solve a particular problem. I am optimizing scheduled over the day vs a price. The schedule is wether On or Off. So the parameters from the genetic algorithm are the index of starting of each range. Ex :
Range 1 : 0h --> x(1) = 0
Range 2 : 07h --> x(2) = 7....
To do this I need to put a constraint that will tell the algorithm that x(4)>x(3)>x(2)>x(1)... Unfortunately, I am not able to do so with the existing constraints :
A*x = b
lb & ub
Does anyone have an idea to do this ?

 채택된 답변

John D'Errico
John D'Errico 2018년 11월 7일
편집: John D'Errico 2018년 11월 7일

0 개 추천

Um, the constraints allow you to supply inequality constraints. In fact, the A and b arguments are INEQUALITY constraints, NOT EQUALITY constraints as you indicted. (READ THE HELP.) So you can indeed specify what you want, with one caveat.
So, if you want to enforce that
x(4)>x(3)>x(2)>x(1)
then set A, such that A*x<=b. That means here, we would have
A = [1 -1 0 0;0 1 -1 0;0 0 1 -1];
b = [0;0;0];
That will constrain the variables such that
x(4) >= x(3) >= x(2) >= x(1)
However, there is NO provision for strict inequality constraints. In fact, pretty much no optimizer allows that, although there are tricks you can use.
The simplest thing to do is to specify an offset, thus a minimum distance between elements. Don't go too small, but this should suffice:
delta = 1e-6;
b = -delta*ones(3,1)
You need to watch out for the constraint tolerance.
There are other ways to solve this, using a transformation of the variables, but the simple solution is usually the best.

댓글 수: 1

Thib Lab
Thib Lab 2018년 11월 8일
편집: Thib Lab 2018년 11월 8일
Thanks for your answer ! It should work but actually the parameters don't reply to the constraints. I defined A and b as you said and I still get this kind of matrix :
[0 18 8 47 16 1]

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

추가 답변 (0개)

카테고리

질문:

2018년 11월 7일

편집:

2018년 11월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by