function [w,lb,ub] = Initialp(filename)
    %% Initial point

    % This script calculates the initial point and the boundaries for the equations oriented
    % simulation.

    % Load results 
    load (filename)

    %%  Calculate compressibilities for all streams
    Zg=zeros(1,17); % Vapour phase
    Zl=zeros(1,17); % Liquid phase

    % Calculate compressibilities for each stream on each phase
    for i=1:17
        [Zl(i),~,~,~]= srks(x(i,:),T(i),P(i),1);
        [Zg(i),~,~,~]= srks(y(i,:),T(i),P(i),2);
    end

    %% Set up flash calculations
    % Define sets for different kinds of flashes 
    TP  = [ 6 ];  % TP Flash
    PH  = [ 3, 7, 11, 13, 14, 15]; % PH Flash
    PHs = [ 16, 17];% PH Flash with slack variables
    F = [TP, PH, PHs]; % Total set of flash calculations
    FH= [PH,PHs]; % Set of all PH flash calculations

    % Define important parameters
    NC=5; %Number of components

    % Start the initial point vector
    w=[];

    %%  Assign values to the intial point vector
    % Also sets up upper boundaries depending on the calculation

    % Compressor temperatures
    w(1)= T(1); % Inlet
    ub(1)=inf;
    w(2)= T1id; % Isoentropic
    ub(2)=inf;

    % Flash calculations
    for i = F
        a=size(w,2);
        w(a+1:a+NC-1)=x(i,1:NC-1);
        ub(a+1:a+NC-1)=1;

        w(a+NC:a+2*NC-2)=y(i,1:NC-1);
        ub(a+NC:a+2*NC-2)=1;

        w(a+2*NC-1)=VF(i);
        ub(a+2*NC-1)=1;
        if i==15 || i == 17 
            b(i)=a+2*NC-1;
        end
        w(a+2*NC)=Zl(i);
        ub(a+2*NC)=1;

        w(a+2*NC+1)=Zg(i);
        ub(a+2*NC+1)=1;

        if ismember(i,FH)

            a=size(w,2);

            w(a+1)=T(i);
            ub(a+1)=inf;

            if ismember(i,PHs) 
                a=size(w,2);

                w(a+1:a+NC)=s(i,:);
                ub(a+1:a+NC)=1;

                w(a+NC+1:a+2*NC)=beta(i,:);
                ub(a+NC+1:a+2*NC)=inf;
            end
        end
    end

    %% Optimization variables (DOF)
    a=size(w,2);

    w(a+1)=N/(0.0434); % Refrigerant flow

    w(a+2)= Sf; % Split flow

    w(a+3)= P(17)/3e5; % Low pressure

    w(a+4)= P(1)/20e5; % High pressure

    w(a+5)= QHA_01/(250); %  HA-01 charge
    
    %% Lower boudaries 
    % All set to zero

    lb=zeros(size(w));
end 