Problem with Linear inequality constraints

6 visualizaciones (últimos 30 días)
Azime Beyza Ari
Azime Beyza Ari el 30 de Mzo. de 2022
Editada: Torsten el 30 de Mzo. de 2022
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
Matt J
Matt J el 30 de Mzo. de 2022
Editada: Matt J 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
Azime Beyza Ari el 30 de Mzo. de 2022
Yes, Thank you!

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 30 de Mzo. de 2022
Editada: Matt J el 30 de Mzo. de 2022
sum(over j)(xij)<=1 for each i
This constraint can be written,
x=rand(36);
[m,n]=size(x);
A=kron(ones(1,n),speye(m)); b=ones(m,1);
You can check the equivalence as follows:
difference=sum(x,2) - A*x(:)
difference = 36×1
0 0 0 0 0 0 0 0 0 0
  17 comentarios
Matt J
Matt J el 30 de Mzo. de 2022
Editada: Matt J el 30 de Mzo. de 2022
It would not be easier with a different solver since in all MATLAB solvers for optimization, you would have to set up A and b.
No, if you were to use intlinprog, but through the problem-based workflow, there would be no need to explicitly create A and b. This would be done for you internally by optimproblem().
So it all ends with how i set up A, b, and (of course) objfunc Which all three i am currently failing to do properly.
So far, nothing has been found to be incorrect in your objective function.
Torsten
Torsten el 30 de Mzo. de 2022
Editada: Torsten el 30 de Mzo. de 2022
It would not be easier with a different solver since in all MATLAB solvers for optimization, you would have to set up A and b.
I should have added: if you use the solver-based approach.
The problem-based approach looks simple, but I have the feeling that one looses too much control over the problem. Checking how settings are internally translated (kind of debugging possibility) is impossible (at least as far as I can see). But as so many things: it's a matter of taste.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by