def main(): ''' decode the parameters ''' start_time = time.time() parser = argparse.ArgumentParser( description= 'Program for Influence Spread Computation\nCoded by Edward FANG') parser.add_argument('-i', metavar='social_network', type=argparse.FileType('r'), required=True, help='the absolute path of the social network file') parser.add_argument('-k', metavar='seed_set_size', type=int, required=True, help='predefined size of the seed set') parser.add_argument('-m', metavar='diffusion_model', required=True, help='can only be IC or LT') parser.add_argument('-b', metavar='termination_type', type=int, required=True, help='specifies the termination manner') parser.add_argument('-t', metavar='time_budget', type=int, help='allowed time for tha algorithm, in second') parser.add_argument('-r', metavar='random_seed', help='random seed for stochastic algorithm') parser.add_argument('-d', help='debug mode', action="store_true") args = parser.parse_args() if args.d: logging.basicConfig(level=logging.DEBUG) # logging.debug(args) graph = InfluenceNetwork() graph.load_from_file(args.i) args.i.close() time_limit = -1 if args.b == 1: time_limit = args.t if args.r: random.seed(args.r) imp_solver = Solver(graph, args.m, time_limit - time.time() + start_time - 0.3, args.r, args.k) imp_solver.solve()
def start_solver(network, spec, seed, best_solution): ''' function to start new process ''' solver = Solver(network, spec, seed, best_solution) solver.solve()