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