Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to solve the system of constraints?

1 visualización (últimos 30 días)
kumar vivek
kumar vivek el 3 de Dic. de 2015
Cerrada: Walter Roberson el 4 de Dic. de 2015

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.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by