% unsafe call:
% [time, valuesALL, labels] =simulationLoop('fischer_N2_flat_unsafe', 1000, 1000, 3)

% fischer call:
% [time, valuesALL, labels] =simulationLoop('fischer_N2_flat_safe', 10, 10 * (ha.constants.get(java.lang.String('A')) + ha.constants.get(java.lang.String('B'))), 3)
% [time, valuesALL, labels] =simulationLoop('fischer_N2_flat_safe', 1000, 3)

loc2id = java.util.LinkedHashMap(ha.modes);

id2loc = java.util.LinkedHashMap(); % map from ids to locations (bidirectional map)

allLocNames = {};

locId = 0;
itLoc = ha.modes.values().iterator();
while (itLoc.hasNext())
    locName = itLoc.next().name;
    locId = locId + 1;
    loc2id.put(locName, locId);
    
    id2loc.put(locId, locName);
    
    badLocCheck = length(strfind(locName, 'cs'));
    
    % more than 1 process in cs
    if badLocCheck >= 2
        ['Bad location id: ', num2str(locId), ' name: ', char(locName)]
    end

    if locId >= 1
        allLocNames = [allLocNames{:}, {char(locName)}];
    else
        allLocNames = [{char(locName)}];
    end
end

N = length(valuesALL);

reachLoc = [];

for i = 1 : N
    % collect set of reachable locations
    reachLoc = unique([reachLoc, unique(valuesALL(i).values(1,:))]);
end

% bad loc = 1: cs_cs, etc.

reachLocNames = {};
reachBad = 0;

for i_loc = reachLoc
    locName = id2loc.get(i_loc);
    
    badLocCheck = length(strfind(locName, 'cs'));
    
    % more than 1 process in cs
    if badLocCheck >= 2
        'NOTE: bad states reachable'
        reachBad = 1;
    end
    
    if i_loc >= 2
        reachLocNames = [reachLocNames{:}, {locName}];
    else
        reachLocNames = [{locName}];
    end
end

['Reached bad states? ', num2str(reachBad)]

['Reachable locations: ']
reachLocNames