Problem with Linear inequality constraints
Mostrar comentarios más antiguos
Hello everyone,
I am trying to do an optimization using genetic algorithm solver. I have linear inequality constraints and i am having trouble properly defining them.
First of all, although my objective function gives not enough input argument error, it works(colud not solve this error i have tried everything). Next step is defining the constraints. I have several constraints, to be more exact including the domain constraints(2) i have 6.
My problem has variables and paremeters with (mostly) dimensions 36x36. I have choosed one constraint to test before proceeding with the rest of the constraints. i have choosed this one ;
sum(over j)(xij)<=1 for each i
what i did was;
i have created A matrix and b vector since this is an inequality constraint. In the A matrix i wrote 1's and 0's. in the b matrix i wrote 1 since that is what i desire.
But it does not assign any values to my variables (xij), and best solution returns as 0.
I will attch the file, if you can have a look i would be appreacited.
Thank you in advance.
Beyza.
10 comentarios
Torsten
el 30 de Mzo. de 2022
What was your objective function ?
What were possibly other constraints on the x_ij (e.g. only 0 or 1, positive or something else)
Azime Beyza Ari
el 30 de Mzo. de 2022
Editada: Azime Beyza Ari
el 30 de Mzo. de 2022
First of all, although my objective function gives not enough input argument error, it works(colud not solve this error i have tried everything)
Do you mean this?

If so, what is unclear? The error message is complaining that you are not providing input arguments and indeed, you are providing none. What are you trying to do in that line?
Azime Beyza Ari
el 30 de Mzo. de 2022
Editada: Azime Beyza Ari
el 30 de Mzo. de 2022
Matt J
el 30 de Mzo. de 2022
The line that is causing the error is the one I highlighted in blue. I did not tell you to put it there. You are invoking your objective function without passing in any xij. Did you mean to have,
objfun2(solution2)
Azime Beyza Ari
el 30 de Mzo. de 2022
Matt J
el 30 de Mzo. de 2022
Get rid of this line
% Clear variables
clearvars objfun2 options2
Azime Beyza Ari
el 30 de Mzo. de 2022
What are you trying to do? Are you just trying to see the objective function value? If so, just write,
objectiveValue
I did not write that line. And can not delete it, it does not allow me.
Just for reference, you can convert the Live Task to editable code using the drop down menu in the upper right corner of the task

Azime Beyza Ari
el 30 de Mzo. de 2022
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Genetic Algorithm en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

