function J = rsr_obj(un,param)

NC = param.NC ;
output = param.output;
un = param.scale_un.*un ;
%Extract inputs
u = un(1:11) ; %Inputs to process

Tr = u(1) ; %#ok<*NASGU> % Reactor temperature
RF = u(2)  ;% Flow to reactor
x_rf = u(3:5);  % Composition of reactor feed
RP = u(6) ; % Flow out of reactor
L = u(7)  ;% Column reflux rate
V = u(8)  ;% Column boilup rate
FA = u(9) ; % Fresh A feed rate
P = u(10)  ;% Purge rate
RCY = u(11) ; % Recycle rate
nr = un(12:12+NC-1) ; %Component holdups in reactor
ncol = un((12+NC):end) ; %Holdups in column. Remember this is total holdups and holdups of NC - 1 lightest components.
reactor ; %Runs the reactor calculations
ucol = [L V] ;
dcol = [RP 1 xr'] ;
[dndt_col B D xB xD] = column(ncol,ucol,dcol,param) ;

param.prices(4) = param.prices(4)*xD'*[1 1 0.5]' ; % Give half value to C in purge stream! This is equivalent to changing the prices to weight basis.



J = [FA V B (D-RCY)]*param.prices ;



