function [C Ceq] = Precooling_constraints(x,d,parameters)

global h

hyCase = h.Activedocument;
sol=hyCase.Solver;
f = hyCase.Flowsheet;

x = x(:);
scale_x = parameters.scale_x ;
% scale_c = parameters.scale_c ;
x = scale_x*x ;

sol.CanSolve = 0 ;

% Inputs

f.MaterialStreams.Item('C3-2').MolarFlowValue = x(1) ; 
f.MaterialStreams.Item('C3-14').MolarFlowValue = x(2) ;   
f.MaterialStreams.Item('C3-33').PressureValue = x(3) ;  
f.MaterialStreams.Item('C3-3').PressureValue = x(4) ;  
f.MaterialStreams.Item('C3-7').PressureValue = x(5) ; 
f.MaterialStreams.Item('C3-11').PressureValue = x(6) ; 

% Disturbances

f.MaterialStreams.Item('MR1a').PressureValue = d(1);
f.MaterialStreams.Item('MR1a').MolarFlowValue = d(2);
f.MaterialStreams.Item('MR1a').TemperatureValue = d(3);
f.MaterialStreams.Item('C2').MolarFlowValue = d(4);
f.MaterialStreams.Item('C3').MolarFlowValue = d(5);
f.MaterialStreams.Item('N2').MolarFlowValue = d(6);
f.MaterialStreams.Item('MR2').PressureValue = d(7);
f.MaterialStreams.Item('NG Feed').PressureValue = d(8);
f.MaterialStreams.Item('NG Feed').MolarFlowValue = d(9);
f.MaterialStreams.Item('C3-1').TemperatureValue = d(10) ;
f.MaterialStreams.Item('NG Feed').TemperatureValue = d(10);
f.MaterialStreams.Item('MR7').TemperatureValue = d(10);

sol.CanSolve = 1 ;

% Define constraint values

if f.Operations.Item('V102').Duty.IsKnown == 1 && f.Operations.Item('V105').Duty.IsKnown == 1
    
    switch parameters.constraint
        case('enthalpy')
            scale_c=parameters.scale_c ;
%             scale_c = eye(5);
            C= [(150 - f.Operations.Item('SPRDSHT-1').Cell('G2').CellValue) ;
                150 - f.Operations.Item('SPRDSHT-1').Cell('G3').CellValue ;
                f.Operations.Item('SPRDSHT-1').Cell('G4').CellValue ;
                f.MaterialStreams.Item('NG4').TemperatureValue + 39.5 ;
                f.MaterialStreams.Item('MR10').TemperatureValue + 39.5 ;
                ];
            C = scale_c\C ;
        case('temperature')
            C= [(2 - f.Operations.Item('SPRDSHT-1').Cell('D1').CellValue) ;
                2 - f.Operations.Item('SPRDSHT-1').Cell('D2').CellValue ;
                f.Operations.Item('SPRDSHT-1').Cell('D3').CellValue ;
                f.MaterialStreams.Item('NG4').TemperatureValue + 39.5 ;
                f.MaterialStreams.Item('MR10').TemperatureValue + 39.5 ;            
                ];
    end
    Ceq = [] ;
else
    C = ones(5,1);
    Ceq = [] ;
end