function cny=petl_cons(X)
%input file for nominal optimalisation of genpelt.m
global hessflag coldata d cs_glob unc_glob R_glob
%splitting X into x and u 
%criterion function
%constraints
D_ut=X(106)-X(105);%D


    Nt=ones(6,1)*coldata.Nt;
    ceq(1:104)=genpet(0,X(1:104),X(105:113),1,coldata.Nt,coldata.alfa,coldata.M0);	%steady state
    ceq(105)=X(110)-d(1)+(D_ut*(0.97-d(5))/(d(2)-0.97));					%Feed flow
    ceq(106:107)=X(111:112)-d(2:3);     %Feed composition
    ceq(108)=(X(113)-d(4));                       %liquid feed fraction
    ceq(109:111)=(genpet(0,X(1:104),X(105:113),3,coldata.Nt,coldata.alfa,coldata.M0)-X(114:116));			
    ceq(112:114)=(X(114:116)-d(5:7));					
    c=0;
if hessflag==1 % Beskrankninger på utgangskonsentrasjon + DTS + Rv
    % Add constraints on the u's
    % Measurements
    Ymeas=genpet(0,X(1:104),X(105:113),3,coldata.Nt,coldata.alfa,1,1,[]); % Y=[xA xB xC Temp u]=[1 1 1 48 9]
    ceq(115:116)=[(R_glob(1,:)*Ymeas-cs_glob(1))+unc_glob(1);(R_glob(2,:)*Ymeas-cs_glob(2))+unc_glob(2)];
    
elseif hessflag==2 % Beskrankninger på utgangskonsentrasjonene + Rv + Rl
    Ymeas=genpet(0,X(1:104),X(105:113),3,coldata.Nt,coldata.alfa,1,1,[]); % Y=[xA xB xC Temp u]=[1 1 1 48 9]
        
    % Fixed streams
    ceq(115)=R_glob(2,:)*Ymeas-cs_glob(2);   % Gassplit, Rv
    ceq(116)=R_glob(4,:)*Ymeas-cs_glob(4);   % Liq.split, Rl
    
elseif hessflag==3 % Beskrankninger på utgangskonsentrasjonene + Rv + DTS2
    Ymeas=genpet(0,X(1:104),X(105:113),3,coldata.Nt,coldata.alfa,1,1,[]); % Y=[xA xB xC Temp u]=[1 1 1 48 9]
        
    % Fixed streams
    ceq(115)=R_glob(2,:)*Ymeas-cs_glob(2);   % Gassplit, Rv
    ceq(116)=R_glob(5,:)*Ymeas-cs_glob(5);   % DTS2

end
cny=[ceq'];