示例#1
0
def evalFunc_FBasicMin(individual, Original, weights, constraints=[]):
    userSize = Original.shape[0]
    permissionSize = Original.shape[1]
    if (constraints and
            not feasible(individual, userSize, permissionSize, constraints)):
        fitness = len(weights)
    else:
        numberOfRoles = len(individual[0])
        array = decoder.resolveRoleModelChromosomeIntoBoolArray(
            individual[0], userSize, permissionSize)
        conf, accs = matrixOps.compareMatrices(array, Original)

        w1 = weights[0]
        w2 = weights[1]
        w3 = weights[2]

        numberOfRoles_normalized = utils.normalization(
            numberOfRoles, 1, min(userSize, permissionSize))
        accs_normalized = utils.normalization(accs, 0, Original.sum())
        conf_normalized = utils.normalization(conf, 0,
                                              Original.size - Original.sum())

        fitness = w1 * numberOfRoles_normalized + w2 * conf_normalized + w3 * accs_normalized

    return fitness,
示例#2
0
def evalFunc_WSC(individual, Original, weights, constraints=[]):
    userSize = Original.shape[0]
    permissionSize = Original.shape[1]
    if (constraints and
            not feasible(individual, userSize, permissionSize, constraints)):
        fitness = len(weights)
    else:
        numberOfRoles = len(individual[0])
        array = decoder.resolveRoleModelChromosomeIntoBoolArray(
            individual[0], userSize, permissionSize)
        conf, accs = matrixOps.compareMatrices(array, Original)
        numberOfUR = statistics.URCnt(individual[0])
        numberOfRP = statistics.RPCnt(individual[0])

        w1 = weights[0]
        w2 = weights[1]
        w3 = weights[2]
        w4 = weights[3]

        worstCase_numberOfRoles = min(userSize, permissionSize)
        numberOfRoles_normalized = utils.normalization(
            numberOfRoles, 1, worstCase_numberOfRoles)
        accs_normalized = utils.normalization(accs, 0, Original.sum())
        numberOfUR_normalized = utils.normalization(
            numberOfUR, userSize, userSize * worstCase_numberOfRoles)
        numberOfRP_normalized = utils.normalization(
            numberOfRP, permissionSize,
            permissionSize * worstCase_numberOfRoles)

        fitness = (w1 * numberOfRoles_normalized + w2 * numberOfUR_normalized +
                   w3 * numberOfRP_normalized + w4 * accs_normalized)

    return fitness,
示例#3
0
def evalFunc_WSC_Star_RoleDis(individual,
                              Original,
                              weights,
                              population,
                              constraints=[]):
    userSize = Original.shape[0]
    permissionSize = Original.shape[1]
    if (constraints and
            not feasible(individual, userSize, permissionSize, constraints)):
        fitness = len(weights)
    else:
        numberOfRoles = len(individual[0])
        array = decoder.resolveRoleModelChromosomeIntoBoolArray(
            individual[0], userSize, permissionSize)
        conf, accs = matrixOps.compareMatrices(array, Original)
        numberOfUR = statistics.URCnt(individual[0])
        numberOfRP = statistics.RPCnt(individual[0])

        count = 0
        for rm in population:
            count += len(rm[0])
        numberOfRolesInPop = count / len(population)
        roleDis = abs(numberOfRolesInPop - numberOfRoles)
        if (roleDis < 3):
            roleDis = 0

        w1 = weights[0]
        w2 = weights[1]
        w3 = weights[2]
        w4 = weights[3]
        w5 = weights[4]
        w6 = weights[5]

        worstCase_numberOfRoles = min(userSize, permissionSize)
        numberOfRoles_normalized = utils.normalization(
            numberOfRoles, 1, worstCase_numberOfRoles)
        accs_normalized = utils.normalization(accs, 0, Original.sum())
        conf_normalized = utils.normalization(conf, 0,
                                              Original.size - Original.sum())
        numberOfUR_normalized = utils.normalization(
            numberOfUR, userSize, userSize * worstCase_numberOfRoles)
        numberOfRP_normalized = utils.normalization(
            numberOfRP, permissionSize,
            permissionSize * worstCase_numberOfRoles)
        roleDis_normalized = utils.normalization(
            roleDis, 0,
            max(numberOfRolesInPop, permissionSize - numberOfRolesInPop,
                userSize - numberOfRolesInPop))

        fitness = (w1 * numberOfRoles_normalized + w2 * numberOfUR_normalized +
                   w3 * numberOfRP_normalized + w4 * accs_normalized +
                   w5 * conf_normalized + w6 * roleDis_normalized)

    return fitness,
示例#4
0
def evalFunc_Int_AssignmentCnt(individual,
                               Original,
                               userAttributeValues,
                               constraints=[]):
    userSize = Original.shape[0]
    permissionSize = Original.shape[1]
    if (constraints and
            not feasible(individual, userSize, permissionSize, constraints)):
        worstCase_interp = 1
        fitness = worstCase_interp
    else:
        AssignmentCnt = statistics.URCnt(individual[0]) + statistics.RPCnt(
            individual[0])
        AssignmentCnt_normalized = utils.normalization(
            AssignmentCnt, userSize + permissionSize,
            userSize * permissionSize)
        interp = statistics.Interp(individual[0], userAttributeValues)
        fitness = AssignmentCnt_normalized - interp + 1
    return fitness,