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

% if hessflag==0
    Nt=ones(6,1)*coldata.Nt;
    ceq(1:104)=genpet(0,X(1:104),X(105:113),1,Nt,coldata.alfa,coldata.M0);	%steady state
    ceq(105)=X(110)-d(1);					%Feed flow
    ceq(106:107)=X(111:112)-d(2:3);     %Feed composition
    ceq(108)=(X(113)-d(4));                       %liquid feed fraction
    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(109)=R_glob(1,:)*Ymeas-cs_glob(1);      % T i seksjon 3
    ceq(110)=R_glob(2,:)*Ymeas-cs_glob(2);      % T i seksjon 4/5
    ceq(111)=R_glob(3,:)*Ymeas-cs_glob(3);      % T i seksjon 6
    ceq(112:114)=(genpet(0,X(1:104),X(105:113),3,Nt,coldata.alfa,coldata.M0)-X(114:116));		%top composition	
    ceq(115:117)=(X(114:116)-d(5:7));					%side product composition
c=0;
    
if hessflag==1 % Beskrankninger på 3 temperaturer + Rv + V
    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(118)=R_glob(5,:)*Ymeas-cs_glob(5);   % Boilup, V
    ceq(119)=R_glob(4,:)*Ymeas-cs_glob(4);   % Gassplit, Rv
end
cny=[ceq'];