How do I input linear constraints for the genetic algorithm function using discrete variables?

4 views (last 30 days)
Hello,
I am using the matlab's ga algorithm to solve an optimization problem using discrete variables. My decision variable is set to take only integer values, then using a simple mapping function, my decision variable are transformed to the n'th indexed value in a list of specific values which i provide, where n is the integer value initially assigned to the decision variable. I followed the exact steps of the following link:
Within this link, they inputed non-linear constraints using a function. In my case, I am interested in inserting linear constraints of inequality, using the matrices A and b. The algorithm seems to not respect these constraints. This is possible because the algorithm is applying the constraints to the decision variables in the form of integers rather than their transformed form.
How should I inser the A and b matrices in such a scenario?
Thank you.
  19 Comments
Samer Alsamadi
Samer Alsamadi on 17 Jul 2023
I wanted to try that method but read the writing linear constraints in the non-linear constraints part of the algorithm could lead to problems as the algo will mess things up. Do you have an idea if that is true or not? Thanks anyways for providing a code example!
Torsten
Torsten on 17 Jul 2023
Edited: Torsten on 17 Jul 2023
Your constraints are linear in the transformed variables, but not in the solution variables.
Or are you able to use A (which is multiplied by x, not x_trans) and b to set the constraints you want on x_trans ?
What you did in your code is setting x(1:10) >= t_ar(1:10), not x_trans(1:10) >= t_ar(1:10). And from what you wrote this is what you actually want, isn't it ?

Sign in to comment.

Answers (0)

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!