Constraints in Genetic Algorithm - Not Just Input Constraints
Show older comments
Is it possible to specify constraints that are not just reliant on the input variable? I.e. a constrain that may be a function of the output or an intermediate variable.
NOTE: The output of this system is calculated from a "black box" (it's a PSS SINCAL simulation).
At this stage I've been using a workaround - making the result of the fitness function a very high value when the output is not within the constraints. Looking for a more elegant solution.
Thank you
Elvis
3 Comments
Anton Semechko
on 7 Jun 2013
First of all, what do you mean by the input variable? The GA parameters or the initial population of solutions?
Elvis
on 11 Jun 2013
Min Zhang
on 19 May 2019
Hello Elvis,
I think I am having the same problem as you.
I already have non-linear constraints in my problem.
Now I want to add one more constraint. To add this constraint, I need to read the outputs (which is calculated by a black box, an external .exe) and get the value "Output_h" and then the constraint is "Output_h<=LIMIT".
I think now I have two options:
- Modify the objective function value. Just as you did, in my objective function subroutine (which reads the input.txt, call and run the black box, read the outputs, calculate the objective function), I will check the value "Output_h" to see whether it is satisfying the above constraint. If not, I will add a much larger value to the initial objective function value.
- Add one more non-linear constraint. In my non-linear constraint subroutine, I will call and run the black box, read the outputs, and get the value "Output_h" and then add the constraint "Output_h - LIMIT <= 0".
What do you think? Which way you would recommend?
I have some concerns:
- For the first option, based on my understanding, GA will learn from the previous generation (probably learn from the objective function value) and generate the next generation. But here, I modify the initial objective function value. I am wondering how GA will learn from this and try to get a better solution gradually. Actually, physically, even I don't know how to generate a better solution since the value "Output_h" is an implicit function of the input variables (I am optimizing more than 10 variables).
- For the second option, it seems that in my non-linear constraint subroutine, I will have a lot of codes the same as my objective function subroutine, including reading the input.txt, calling and running the black box, reading the outputs. For me, it seems that for each GA population/case, the black box will be called twice (in both non-linear constraint and objective function subroutines)? Do you think it is wasting of time? Do I have a better way to do this? In addition, every run of the black box will take around 60s, which is the reason why I am trying to find a more efficient way to add this constraint.
Thanks!
Min
Accepted Answer
More Answers (1)
Pramod Bharadwaj
on 12 Feb 2018
0 votes
I have the following functions
L=sqrt((x(1)^2)+(x(2)^2)+(x(3)^2))+sqrt((x(4)^2)+(x(5)^2)+(x(6)^2));
H=x(7);
alpha=atand((x(1)-x(8))/x(2));
beta=atand(x(3)/x(2));
how to find the optimal values of x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8) such that output having constraints as 170<L<190,20<H<30,1<alpha<2,2<beta<4
Categories
Find more on Problem-Based Optimization Setup in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!