function c=constraints(x,hyCase)


stream=hyCase.Flowsheet.MaterialStreams;                       %stream path
EnergyStreams=hyCase.Flowsheet.EnergyStreams;               % energy strems 
operations=hyCase.Flowsheet.Operations;
col=hyCase.Flowsheet.Operations.Item('21_VE103');
sol=hyCase.Solver;
script_folder='C:\Users\torandma\Documents\prosjekt karsto\matlab';
%Setting controller setpoints and other degrees of freedom

sol.canSolve=0;

stream.Item('1b').TemperatureValue=x(1);  % C   | Temp before feed sep
stream.Item('13').PressureValue=x(2);         % kPa | Pressure feed sep 
RC(1-x(4),script_folder,hyCase)                  % frac| Split ratio liq. cold sep  
EnergyStreams.Item('Q_side_btm').HeatFlowValue=x(5)/3600; %kj/h | energy bmt side boiler
col.ColumnFlowsheet.Specifications.Item('Temperature').GoalValue=x(6); %C | temp col btm
stream.Item('14').PressureValue=x(7);    %kPa |Pressure after expander
stream.Item('D').PressureValue=x(7)-200;
stream.Item('12').PressureValue=x(7)-200+x(3); % kPa | Pressure diff cold sep
sol.canSolve=1;

isknown=0;   % parameters to check if unisim converges
isknown=isknown + stream.Item('D').MassFlow.isKnown         -1;
isknown=isknown + stream.Item('B').MassFlow.isKnown         -1;
isknown=isknown + EnergyStreams.Item('E1').HeatFlow.isKnown -1;
isknown=isknown + stream.Item('1').Temperature.IsKnown      -1;
isknown=isknown + stream.Item('1').Temperature.IsKnown      -1;
isknown=isknown + stream.Item('1').Temperature.IsKnown      -1;
isknown=isknown + stream.Item('1b').Temperature.IsKnown     -1;

isknown=isknown + strcmp('Converged',operations.Item('RCY-7').RecycleConvergence) -1;
isknown=isknown + strcmp('Converged',operations.Item('RCY-5').RecycleConvergence) -1;
isknown=isknown + strcmp('Converged',operations.Item('RCY-1').RecycleConvergence) -1;
isknown=isknown + strcmp('Converged',operations.Item('RCY-6').RecycleConvergence) -1;


if isknown<0
    fprintf('Unisim failed to converge\n')
    fprintf('Please solve the problem manualy\n\n')
    in = input('Has the problem been solved manualy? (y=1/n=0):');
        if in==0
            return
        end
       
end


%constraints
c(1,1)=-col.ColumnFlowsheet.PressuresValue(end) ;      % Tower btm pressure
c(2,1)=col.columnFlowsheet.temperaturesValue(19) ;    % Temperature stage 19
c(3,1)=stream.Item('B').ComponentMassFractionValue(4);% Methane bottom of column
c(4,1)=-stream.Item('4').MassFlowValue*3600;
c(5,1)=-stream.Item('8').MassFlowValue*3600;
c(6,1)=-stream.Item('D').MassFlowValue*3600;
