Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to solve the system of constraints?

3 visualizzazioni (ultimi 30 giorni)
kumar vivek
kumar vivek il 3 Dic 2015
Chiuso: Walter Roberson il 4 Dic 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.

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by