import argparse import sys import math import networkx as nx import random import time import Binary import Flexible import copy def parse_args(): parser = argparse.ArgumentParser(description="profit divergence minimization") parser.add_argument('--degree', nargs='?', default='degree/LastFM', help='input graph file') parser.add_argument('--dis', nargs='?', default='Uniform', help='sampling distributions with a specific focus. Choices: Macro, Micro, Nano, Uniform.') parser.add_argument('--load', type=int, default='90',help='the number of candidates') parser.add_argument('--budgetRatio', type=float, default='0.8',help='the budget = budgetRatio * total influence spread of candidates') parser.add_argument('--expectRatio', type=float, default='0.5', help='the weighted influence is sampled from [1 * delta, (1+expectRatio)*delta]') parser.add_argument('--numPieces', type=float, default='10', help='the size of integer price choice set for fc-exact') parser.add_argument('--degreeRatio', type=float, default='0.2', help='the ratio of degrees of influencers belonging to the same tier over the total degree of all users in the network') parser.add_argument('--cutPoint', type=float, default='0.5', help='the price choice set R is generated from the range [(1-cutpoint)*delta, (1+cutpoint)*delta]') parser.add_argument('--method', nargs='?', default='BCExact',help='BCExact,BCMG,ICExact,CRInf,CRMWS.') parser.add_argument('--output', nargs='?', default='output/',help='default output folder') parser.add_argument('--seed', type=int, default='10',help='random seed') parser.add_argument('--version', type=int, default='0',help='0 for float version of FCInfGreedy and 1 for integer version') parser.add_argument('--infmax', type=int, default='0',help='0 refers to BCExact with profit minimization, and 1 refers to BCExact with influence maximization') return parser.parse_args() seeds={} seeds['Dogster']=123 seeds['Orkut']=234 seeds['Instagram']=345 seeds['Tiktok']=567 seeds['Gowalla']=678 seeds['LastFM']=8910 seeds['Hamster']=91011 Dis={} Dis["Macro"]=(0.5,0.25,0.25) Dis["Micro"]=(0.25,0.5,0.25) Dis["Nano"]=(0.25,0.25,0.5) Dis["Uniform"]=(0.33,0.33,0.33) def getCuts(inf_profit,degreeRatio): cuts=[] percentage=[degreeRatio*1,degreeRatio*2,degreeRatio*3,2] degreeCul=0 totalDegree=0 for inf in inf_profit: totalDegree=totalDegree+inf[1] index=0 for i in range(len(inf_profit)): degreeCul=degreeCul+inf_profit[i][1] if (float(degreeCul)/totalDegree>percentage[index]): cuts.append(i) index=index+1 if (index==len(percentage)-1): break #print (str(float(cuts[0])/len(inf_profit))+" "+str(float(cuts[1])/len(inf_profit))+" "+str(float(cuts[2])/len(inf_profit))) return cuts def f(cost, expect): if (cost