(infor_value, costs, budget)
return min_infovalue, selectedVariables
POSS (Pareto Optimization for Subset Selection) method.

    infor-value is negative.
    NOTE THAT we assume that function is to be minimized.
    Paremeters:
    ----------
    infor_value: array-like
        The value corresponding to each item.

    costs: array-like
        The cost corresponding to each item.

    Budget: float
        the constraint on the cost of selected variables.
    Returns:
    ----------
    max_value: float
        The greatest infor-value.

    select_index: array-like
        The result of whether to select the item or not,
        1 reprent this item is selected,0 is not.

    References
    ----------
    [1] Chao Qian, Yang Yu, and Zhi-Hua Zhou.
        Subset selection by pareto optimization. In Advances
        in Neural Information Processing Systems, pages 1774-
        1782, 2015.
POSS (Pareto Optimization for Subset Selection) method.
POSS ( Pareto Optimization for Subset Selection ) method .
def select_POSS(infor_value, costs, budget):
    """
    POSS (Pareto Optimization for Subset Selection) method.

    infor-value is negative.
    NOTE THAT we assume that function is to be minimized.
    Paremeters:
    ----------
    infor_value: array-like
        The value corresponding to each item.

    costs: array-like
        The cost corresponding to each item.

    Budget: float
        the constraint on the cost of selected variables.
    Returns:
    ----------
    max_value: float
        The greatest infor-value.

    select_index: array-like
        The result of whether to select the item or not,
        1 reprent this item is selected,0 is not.

    References
    ----------
    [1] Chao Qian, Yang Yu, and Zhi-Hua Zhou.
        Subset selection by pareto optimization. In Advances
        in Neural Information Processing Systems, pages 1774-
        1782, 2015.
    """
    assert(len(infor_value) == len(costs))
    num = len(infor_value)
    population = np.zeros((1, num))

    popSize = 1
    fitness = np.zeros((1, 2))
    fitness[0][0] = np.infty

    fitness[0][1] = 0.
    # repeat to improve the population; 
    # the number of iterations is set as 2*e*k^2*n suggested by our theoretical analysis.
    T = 2 * np.e * np.power(budget, 2) * num

    for round in np.arange(T):
        # randomly select a solution from the population and mutate it to generate a new solution.
        offspring = np.abs(population[np.random.randint(0, popSize), :] - np.random.choice([1, 0], size=(num), p=[1/num, 1 - 1/num]))
        # compute the fitness of the new solution.
        offspringFit = np.array([0., 0.])
        offspringFit[1] = np.sum(offspring * costs)

        if offspringFit[1] == 0 or offspringFit[1] > budget:
            offspringFit[0] = np.infty
        else:
            offspringFit[0] = np.sum(offspring * infor_value)

        # use the new solution to update the current population.
        # if (fitness[0: popSize, 0] < offspringFit[0] and fitness[0: popSize, 1] <= offspringFit[1]) or (fitness[0: popSize, 0] <= offspringFit[0] and fitness[0: popSize, 1] < offspringFit[1]):
        judge1 = np.array(fitness[0: popSize, 0] < offspringFit[0]) & np.array(fitness[0: popSize, 1] <= offspringFit[1])
        judge2 = np.array(fitness[0: popSize, 0] <= offspringFit[0]) & np.array(fitness[0: popSize, 1] < offspringFit[1])   
        c= judge1 | judge2
        if c.any():
            continue
        else:
            # deleteIndex = fitness[0: popSize, 0] >= offspringFit[0] * fitness[0: popSize, 1] >= offspringFit[1]
            index = [i for i in range(len(fitness))]
            condi_1 = np.where(fitness[0: popSize, 0] >= offspringFit[0])
            condi_2 = np.where(fitness[0: popSize, 1] >= offspringFit[1])
            deleteIndex = [val for val in condi_1[0] if val in condi_2[0]]         
            nodeleteIndex = [j for j in index if j not in deleteIndex]    
       
        # ndelete: record the index of the solutions to be kept.
        population = np.row_stack((population[nodeleteIndex, :], offspring))
        fitness = np.row_stack((fitness[nodeleteIndex, :], offspringFit))
        popSize = len(nodeleteIndex) + 1

    temp = np.where(fitness[:, 1] <= budget)
    min_info_indx = np.argmin(fitness[temp[0], 0])
    min_infovalue = fitness[min_info_indx][0]
    selectedVariables = population[min_info_indx, :]

    return min_infovalue, selectedVariables
def select_POSS ( infor_value , costs , budget ) : assert ( len ( infor_value ) == len ( costs ) ) num = len ( infor_value ) population = np . zeros ( ( 1 , num ) ) popSize = 1 fitness = np . zeros ( ( 1 , 2 ) ) fitness [ 0 ] [ 0 ] = np . infty fitness [ 0 ] [ 1 ] = 0. # repeat to improve the population;  # the number of iterations is set as 2*e*k^2*n suggested by our theoretical analysis. T = 2 * np . e * np . power ( budget , 2 ) * num for round in np . arange ( T ) : # randomly select a solution from the population and mutate it to generate a new solution. offspring = np . abs ( population [ np . random . randint ( 0 , popSize ) , : ] - np . random . choice ( [ 1 , 0 ] , size = ( num ) , p = [ 1 / num , 1 - 1 / num ] ) ) # compute the fitness of the new solution. offspringFit = np . array ( [ 0. , 0. ] ) offspringFit [ 1 ] = np . sum ( offspring * costs ) if offspringFit [ 1 ] == 0 or offspringFit [ 1 ] > budget : offspringFit [ 0 ] = np . infty else : offspringFit [ 0 ] = np . sum ( offspring * infor_value ) # use the new solution to update the current population. # if (fitness[0: popSize, 0] < offspringFit[0] and fitness[0: popSize, 1] <= offspringFit[1]) or (fitness[0: popSize, 0] <= offspringFit[0] and fitness[0: popSize, 1] < offspringFit[1]): judge1 = np . array ( fitness [ 0 : popSize , 0 ] < offspringFit [ 0 ] ) & np . array ( fitness [ 0 : popSize , 1 ] <= offspringFit [ 1 ] ) judge2 = np . array ( fitness [ 0 : popSize , 0 ] <= offspringFit [ 0 ] ) & np . array ( fitness [ 0 : popSize , 1 ] < offspringFit [ 1 ] ) c = judge1 | judge2 if c . any ( ) : continue else : # deleteIndex = fitness[0: popSize, 0] >= offspringFit[0] * fitness[0: popSize, 1] >= offspringFit[1] index = [ i for i in range ( len ( fitness ) ) ] condi_1 = np . where ( fitness [ 0 : popSize , 0 ] >= offspringFit [ 0 ] ) condi_2 = np . where ( fitness [ 0 : popSize , 1 ] >= offspringFit [ 1 ] ) deleteIndex = [ val for val in condi_1 [ 0 ] if val in condi_2 [ 0 ] ] nodeleteIndex = [ j for j in index if j not in deleteIndex ] # ndelete: record the index of the solutions to be kept. population = np . row_stack ( ( population [ nodeleteIndex , : ] , offspring ) ) fitness = np . row_stack ( ( fitness [ nodeleteIndex , : ] , offspringFit ) ) popSize = len ( nodeleteIndex ) + 1 temp = np . where ( fitness [ : , 1 ] <= budget ) min_info_indx = np . argmin ( fitness [ temp [ 0 ] , 0 ] ) min_infovalue = fitness [ min_info_indx ] [ 0 ] selectedVariables = population [ min_info_indx , : ] return min_infovalue , selectedVariables