function J = Precooling_obj(x,d,parameters)

global h

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

x = x(:);
scale_x = parameters.scale_x ;
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 ;


if f.Operations.Item('K102').Energy.IsKnown == 1 
    J = f.Operations.Item('SPRDSHT-1').Cell('A7').CellValue ;
elseif f.Operations.Item('K102').Energy.IsKnown == 0
    J = 1e5 ;
end


