Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to solve the system of constraints?

1 次查看(过去 30 天)
kumar vivek
kumar vivek 2015-12-3
关闭: Walter Roberson 2015-12-4

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.

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by