Dependent Variable operations?
Afficher commentaires plus anciens
Hello Everyone,
I am working on an optimization problem using genetic algorithm solver. I have 2 decision variables (x with 36x36 dimensions and y with 36x1 dimensions ). y is dependent to x. Like;
column sum of x is equal to row of y.
I introduced x and y like;
x = optimvar('x', [36,36], 'Type', 'integer', 'LowerBound',0,'UpperBound',1);
y = optimvar('y', [36,1]);
But i have a hard time doing the operation i want to do. How can i implement this (column sum of x is equal to row of y. ) into my code?
Any suggestions and opinions are welcome.
Thank you in advance!
Best,
Beyza.
7 commentaires
Did you look at the examples provided here:
?
You can even display the constraints after you defined them to see if you made something worng.
Azime Beyza Ari
le 3 Avr 2022
Modifié(e) : Azime Beyza Ari
le 3 Avr 2022
Torsten
le 3 Avr 2022
Could you write out the code as Matt showed you and attach the .m file ?
Azime Beyza Ari
le 3 Avr 2022
Torsten
le 3 Avr 2022
Sorry, but I'm not familiar with the problem-based approach.
If you tell me the vector of unknowns, how it is ordered and what constraints you want to impose, I can help you setting up the A, Aeq, b and beq.
If you want to use the problem-based approach, maybe someone else will help.
Azime Beyza Ari
le 3 Avr 2022
Aeq = zeros(36,36*36+36);
for i = 1:36
Aeq(i,(i-1)*36+1:i*36) = ones(1,36);
Aeq(i,36*36+i) = -1;
end
This gives the contribution of the constraint sum_i (xij) - y(j) = 0 for j=1,...,36 to Aeq if the vector of unknowns Z is ordered as
Z = [x11,x21,x31,...,x(36,1),x12,x22,x32,...,x(36,2),...,x(1,36),x(2,36),...,x(36,36),y1,y2,...,y36]
The corresponding part of the vector beq is
beq(1:36,1) = zeros(36,1)
Réponses (0)
Catégories
En savoir plus sur Genetic Algorithm dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!