Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Error GA with Nonlinear constraints function.

1 Ansicht (letzte 30 Tage)
Matlab Noob
Matlab Noob am 22 Jul. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hello,
I make code which is Vectorized Nonlinear constraints.
function [c1,c2, ceq] = fitFC(x)
B = [3000 2000 5000];
W = [500 250 1000];
b = [10 10 10;
8.5 8.5 8.5];
w = [1 1 1; 2 2 2];
q = reshape(x(1:6),2,3);
k = reshape(x(7:12),2,3);
m = reshape(x(13:18),2,3);
ceq=[];
c1 = b.*q - B;
c2 = w*(q.*(1 - 2*k)./m) - W;
When i run GA using optool box, I got this message "Matrix dimensions must agree.".
Is there any way to add multi vectorized constraints in Nonlinear Constraints function?

Antworten (1)

Lee Long
Lee Long am 16 Mai 2019
you should define constraint function like this:
function [c,ceq]=fitFC(x)
...
...
c(1)=b.*q - B;
c(2)= w*(q.*(1 - 2*k)./m) - W;
ceq=[];
end

Diese Frage ist geschlossen.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by