Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How to solve the system of constraints?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a program that need to check for each set of values- bound limits and coupled constraints. But every time i try to run it it may go beyond the limits or the constraints are not satisfied. What modification i can do. The code goes like this:-
function [ gout ] = c(gac,cy)
gout=gac;
%% Uncoupled Constraints
lbac=[220 260 50 25];
ubac=[260 1000 400 600];
U=(gac>ubac);
gout(U)=ubac(U);
gout(~U)=gac(~U);
L=(gac<lbac);
gout(L)=lbac(L);
%% Coupled constraints
if gout(2)-gout(3)-gout(4)-20<0
[~,I]=max(abs([ gout(3) gout(4) gout(2)]-[ lbac(3) lbac(4) ubac(2)]));
switch I
case 1
gout(3)=gout(2)-gout(4)-20;
if (gout(3)>ubac(3) || gout(3)<lbac(3))
gout(3)=min((gout(2)-gout(4)-20),lbac(3));
end
case 2
gout(4)=gout(2)-gout(3)-20; %modification related to hc
if (gout(4)>ubac(4) || gout(3)<lbac(3))
gout(4)=min((gout(2)-gout(3)-20),lbac(4));
end
case 3
gout(2)= gout(2)+(gout(3)+gout(4)-gout(2));
if gout(2)-gout(3)-gout(4)-20<0
gout(2)=min((gout(3)+gout(4)),ubac(2));
end
end
end
gout = ceil(gout);
end
I am getting a gac vector and want to fit in with all the constraints and pass the modified value to other function.
1 Kommentar
Antworten (0)
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!