def get_result_mip(g, size, source, target, weight): # influence maximization - original MIP t_start = datetime.now() ssMip, dInf = mipIM_nobigM.optimize(S, T, size, source, target, weight) ssMip_name = map(lambda s: g.vs[s]['name'], ssMip) t_end = datetime.now() write_result(netname, 'mip', dInf, ssMip_name, (t_end - t_start).seconds)
import lpIM_nobigM import mipIM_nobigM import calculate_LT # paramters of IM S = 6 T = 10 fname = '/bkfrat-GraphML/BKFRAB.GraphML' # 'SAMPIN.GraphML' # get directed weighted network g = read_graphml.preprocess(fname) print 'g is a DAG:', g.is_dag() # influence maximization - original size, source, target, weight = len(g.vs), [e.source for e in g.es], [e.target for e in g.es], [w for w in g.es['normalized inweight']] ssCplex = cplex_tiny.optimize(S, T, size, source, target, weight) # influence maximization - original ssMip = mipIM_nobigM.optimize(S, T, size, source, target, weight) # calculate expected spread calculate_LT.run(ssCplex, S, T, size, source, target, weight) print 'seed set selected by Cplex' calculate_LT.run(ssMip, S, T, size, source, target, weight) print 'seed set selected by MIP_nobigM'