Exemplo n.º 1
0
 def genoptfunction(graph, samples=1000):
     live_graphs = sample_live_icm(graph, samples)
     f_multi = make_multilinear_objective_samples(live_graphs,
                                                  list(graph.nodes()),
                                                  list(graph.nodes()),
                                                  np.ones(len(graph)))
     f_set = multi_to_set(f_multi, graph)
     return f_set
Exemplo n.º 2
0
            gr_values[graphname][attribute] = np.zeros((num_runs, nvalues))
            group_size[graphname][attribute] = np.zeros((num_runs, nvalues))
            for alg in algorithms:
                alg_values[alg][graphname][attribute] = np.zeros((num_runs, nvalues))
                alg_seeds[alg][graphname][attribute] = [[] for _ in range(num_runs)]

    
    fair_vals_attr = np.zeros((num_runs, len(attributes)))
    greedy_vals_attr = np.zeros((num_runs, len(attributes)))
    pof = np.zeros((num_runs, len(attributes)))
    
    include_total = False
    
    for run in range(num_runs):
        print(graphname, run)
        live_graphs = sample_live_icm(g, 1000)
    
        group_indicator = np.ones((len(g.nodes()), 1))
        
        val_oracle = make_multilinear_objective_samples_group(live_graphs, group_indicator,  list(g.nodes()), list(g.nodes()), np.ones(len(g)))
        grad_oracle = make_multilinear_gradient_group(live_graphs, group_indicator,  list(g.nodes()), list(g.nodes()), np.ones(len(g)))
        
        def f_multi(x):
            return val_oracle(x, 1000).sum()
        
        
        #f_multi = make_multilinear_objective_samples(live_graphs, list(g.nodes()), list(g.nodes()), np.ones(len(g)))
        f_set = multi_to_set(f_multi)
        
        #find overall optimal solution
        S, obj = greedy(list(range(len(g))), budget, f_set)