Why does ga not take into account boundaries and nonlcon and just gives random values to my variables?

3 views (last 30 days)
Hi. I'm optimizing a multivariable single objective problem using ga. I have multiple constrains that depend on aditional parameters appart from the optimization variables. That's why I made a "problem" function in which I nested functions for the fitness function and nonlcon. I nested these two so that I could pass the aditional parameters (wich are structs with many fields) to the problem function that contains them and that way I can make the two nested ones only depend on x, but also able to work with the aditional parameters. The idea here is that the boundaries of x change with each iteration because they depend on the values of x. The problem is that if those boundaries or constraints are not respected, nothing works, the problem only works for a specific range of values of the variables. GA is just turning a blind eye to my lower and upper bounds and to my nonlcon, and it just gives random values (a lot higher that the limit, or negative) to the variables, usually on the second iteration, as on the first x = guess values, and so the nonlcon of the following iteration after the random values are given gives tons of errors as it cannot work with such strange values. Any ideas on why ga just ignores my constraints? If you need more details I can try and elaborate more on the explanation. Thanks in advance!

Answers (0)

Community Treasure Hunt

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

Start Hunting!