def run_tests(na, nc, ncat, na_gen, pcerrors, nseeds, vetot, vetom, vparam,
              filename):
    # Create the CSV writer
    f = open(filename, 'wb')
    writer = csv.writer(f)

    # Write the test options
    writer.writerow(['algorithm', algo.__name__])
    writer.writerow(['veto type', vetot])
    writer.writerow(['veto mode', vetom])
    writer.writerow(['veto weights', indep_veto_weights])
    writer.writerow(['veto param', vparam])
    writer.writerow(['na', na])
    writer.writerow(['nc', nc])
    writer.writerow(['ncat', ncat])
    writer.writerow(['na_gen', na_gen])
    writer.writerow(['pcerrors', pcerrors])
    writer.writerow(['nseeds', nseeds])
    writer.writerow(['', ''])

    # Create a test_results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _na, _nc, _ncat, _na_gen, _vparam, _pcerrors, seed \
        in product(na, nc, ncat, na_gen, vparam, pcerrors, seeds):

        t1 = time.time()
        t = test_mip_mrsort_vc(seed, _na, _nc, _ncat, _na_gen, _vparam,
                               _pcerrors)
        t2 = time.time()

        if initialized is False:
            fields = t.get_attributes()
            writer.writerow(fields)
            initialized = True

        t.tocsv(writer, fields)
        f.flush()

        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])

    t = results.summary(
        ['na', 'nc', 'ncat', 'na_gen', 'veto_param', 'pcerrors'], [
            'na_err', 'nv_m1_learning', 'nv_m2_learning', 'nv_m1_gen',
            'nv_m2_gen', 'ca_best', 'ca_errors', 'ca_gen', 'ca_gen_err',
            't_total'
        ])
    t.tocsv(writer)
Exemplo n.º 2
0
def run_tests(na, nc, ncat, na_gen, pcerrors, nseeds,
              vetot, vetom, vparam, filename):
    # Create the CSV writer
    f = open(filename, 'wb')
    writer = csv.writer(f)

    # Write the test options
    writer.writerow(['algorithm', algo.__name__])
    writer.writerow(['veto type', vetot])
    writer.writerow(['veto mode', vetom])
    writer.writerow(['veto weights', indep_veto_weights])
    writer.writerow(['veto param', vparam])
    writer.writerow(['na', na])
    writer.writerow(['nc', nc])
    writer.writerow(['ncat', ncat])
    writer.writerow(['na_gen', na_gen])
    writer.writerow(['pcerrors', pcerrors])
    writer.writerow(['nseeds', nseeds])
    writer.writerow(['', ''])

    # Create a test_results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _na, _nc, _ncat, _na_gen, _vparam, _pcerrors, seed \
        in product(na, nc, ncat, na_gen, vparam, pcerrors, seeds):

        t1 = time.time()
        t = test_mip_mrsort_vc(seed, _na, _nc, _ncat, _na_gen,
                               _vparam, _pcerrors)
        t2 = time.time()

        if initialized is False:
            fields = t.get_attributes()
            writer.writerow(fields)
            initialized = True

        t.tocsv(writer, fields)
        f.flush()

        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])

    t = results.summary(['na', 'nc', 'ncat', 'na_gen', 'veto_param',
                         'pcerrors'],
                        ['na_err', 'nv_m1_learning', 'nv_m2_learning',
                         'nv_m1_gen', 'nv_m2_gen', 'ca_best', 'ca_errors',
                         'ca_gen', 'ca_gen_err', 't_total'])
    t.tocsv(writer)
Exemplo n.º 3
0
def run_tests(na, nc, ncat, na_gen, pcerrors, nseeds, filename):
    # Create the CSV writer
    f = open(filename, 'wb')
    writer = csv.writer(f)

    # Write the test options
    writer.writerow(['algorithm', algo.__name__])
    writer.writerow(['na', na])
    writer.writerow(['nc', nc])
    writer.writerow(['ncat', ncat])
    writer.writerow(['na_gen', na_gen])
    writer.writerow(['pcerrors', pcerrors])
    writer.writerow(['nseeds', nseeds])
    writer.writerow(['random_model_type', random_model_type])
    writer.writerow(['', ''])

    # Create a test_results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _na, _nc, _ncat, _na_gen, _pcerrors, seed \
        in product(na, nc, ncat, na_gen, pcerrors, seeds):

        t1 = time.time()
        t = test_meta_electre_tri_global(seed, _na, _nc, _ncat, _na_gen,
                                         _pcerrors)
        t2 = time.time()

        if initialized is False:
            fields = [
                'seed', 'na', 'nc', 'ncat', 'na_gen', 'pcerrors', 'na_err',
                'ca_best', 'ca_errors', 'ca2_best', 'ca2_errors', 'ca_gen',
                'ca_gen_err', 't_total'
            ]
            writer.writerow(fields)
            initialized = True

        t.tocsv(writer, fields)
        f.flush()

        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])

    t = results.summary(['na', 'nc', 'ncat', 'na_gen', 'pcerrors'], [
        'na_err', 'ca_best', 'ca_errors', 'ca2_best', 'ca2_errors', 'ca_gen',
        'ca_gen_err', 't_total'
    ])
    t.tocsv(writer)
Exemplo n.º 4
0
def run_tests(na, nc, ncat, na_gen, pcerrors, nseeds, filename):
    # Create the CSV writer
    f = open(filename, 'wb')
    writer = csv.writer(f)

    # Write the test options
    writer.writerow(['algorithm', algo.__name__])
    writer.writerow(['na', na])
    writer.writerow(['nc', nc])
    writer.writerow(['ncat', ncat])
    writer.writerow(['na_gen', na_gen])
    writer.writerow(['pcerrors', pcerrors])
    writer.writerow(['nseeds', nseeds])
    writer.writerow(['random_model_type', random_model_type])
    writer.writerow(['', ''])

    # Create a test_results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _na, _nc, _ncat, _na_gen, _pcerrors, seed \
        in product(na, nc, ncat, na_gen, pcerrors, seeds):

        t1 = time.time()
        t = test_meta_electre_tri_global(seed, _na, _nc, _ncat, _na_gen,
                                         _pcerrors)
        t2 = time.time()

        if initialized is False:
            fields = ['seed', 'na', 'nc', 'ncat', 'na_gen', 'pcerrors',
                      'na_err',
                      'ca_best', 'ca_errors', 'ca2_best', 'ca2_errors',
                      'ca_gen', 'ca_gen_err', 't_total']
            writer.writerow(fields)
            initialized = True

        t.tocsv(writer, fields)
        f.flush()

        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])

    t = results.summary(['na', 'nc', 'ncat', 'na_gen', 'pcerrors'],
                         ['na_err', 'ca_best', 'ca_errors', 'ca2_best',
                          'ca2_errors', 'ca_gen', 'ca_gen_err',
                          't_total'])
    t.tocsv(writer)
def run_tests(nseeds, data, pclearning, nloop, nmodels, nmeta, filename):
    # Create the CSV writer
    f = open(filename, 'wb')
    writer = csv.writer(f)

    # Write the test options
    writer.writerow(['data', data.name])
    writer.writerow(['heur_init_profiles', heur_init_profiles.__name__])
    writer.writerow(['lp_weights', lp_weights.__name__])
    writer.writerow(['heur_profiles', heur_profiles.__name__])
    writer.writerow(['nloop', nloop])
    writer.writerow(['nmodels', nmodels])
    writer.writerow(['nmeta', nmeta])
    writer.writerow(['pclearning', pclearning])

    # Create a test_results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _pclearning, _nloop, _nmodels, _nmeta, seed in product(
            pclearning, nloop, nmodels, nmeta, seeds):
        t1 = time.time()
        t = run_test(seed, data, _pclearning, _nloop, _nmodels, _nmeta)
        t2 = time.time()

        if initialized is False:
            fields = t.get_attributes()
            writer.writerow(fields)
            initialized = True

        t.tocsv(writer, fields)
        f.flush()
        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])

    t = results.summary([
        'na', 'nc', 'ncat', 'pclearning', 'na_learning', 'na_test', 'nloop',
        'nmodels', 'nmeta'
    ], [
        'ca_learning', 'ca_test', 'ca_all', 'auc_learning', 'auc_test',
        'auc_all', 't_total'
    ])
    t.tocsv(writer)
Exemplo n.º 6
0
def run_tests(nseeds, data, pclearning, nloop, nmodels, nmeta, filename):
    # Create the CSV writer
    f = open(filename, 'wb')
    writer = csv.writer(f)

    # Write the test options
    writer.writerow(['data', data.name])
    writer.writerow(['heur_init_profiles', heur_init_profiles.__name__])
    writer.writerow(['lp_weights', lp_weights.__name__])
    writer.writerow(['heur_profiles', heur_profiles.__name__])
    writer.writerow(['nloop', nloop])
    writer.writerow(['nmodels', nmodels])
    writer.writerow(['nmeta', nmeta])
    writer.writerow(['pclearning', pclearning])

    # Create a test_results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _pclearning, _nloop, _nmodels, _nmeta, seed in product(pclearning,
                                        nloop, nmodels, nmeta, seeds):
        t1 = time.time()
        t = run_test(seed, data, _pclearning, _nloop, _nmodels, _nmeta)
        t2 = time.time()

        if initialized is False:
            fields = t.get_attributes()
            writer.writerow(fields)
            initialized = True

        t.tocsv(writer, fields)
        f.flush()
        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])

    t = results.summary(['na', 'nc', 'ncat', 'pclearning', 'na_learning',
                         'na_test', 'nloop', 'nmodels', 'nmeta'],
                        ['ca_learning', 'ca_test', 'ca_all',
                         'auc_learning', 'auc_test', 'auc_all', 't_total'])
    t.tocsv(writer)
def run_test(m, n, lbda_min, lbda_max, filename):
    # Create the CSV writer
    f = open(filename, 'wb')
    writer = csv.writer(f)

    # Create a test_results instance
    results = test_results()
    initialized = False

    # Run the algorithm
    c = generate_criteria(n)
    coalitions = [ i for i in powerset(c.keys()) ]
    for i in range(m):
        t = one_loop(c, lbda_min, coalitions)
        t.test_name = "%d-%d" % (i, n)
        t['i'] = i
        t['nc'] = n
        t['lbda_min'] = lbda_min
        t['lbda_max'] = lbda_max
        t['n'] = m

        if initialized is False:
            fields = ['i', 'nc', 'lbda_min', 'lbda_max'] \
                      + [pprint_coalition(j) for j in coalitions] \
                      + ["%d_criteria" % i for i in range(len(c) + 1)] \
                      + ["ncoalitions"]
            writer.writerow(fields)
            initialized = True

        results.append(t)
        t.tocsv(writer, fields)
        f.flush()

        print("%s" % t)

    # Perform a summary
    writer.writerow(['', ''])
    t = results.summary(['nc', 'lbda_min', 'lbda_max', 'n'], [pprint_coalition(j)
                         for j in coalitions], [], [])
    t.tocsv(writer)

    writer.writerow(['', ''])
    t = results.summary(['nc', 'lbda_min', 'lbda_max', 'n'],
                        ["%d_criteria" % i for i in range(len(c) + 1)] \
                        + ['ncoalitions'], ['ncoalitions'],
                        ['ncoalitions'])
    t.tocsv(writer)
def run_tests(na, nc, ncat, ns, na_gen, pcerrors, nseeds, filename):
    # Create the CSV writer
    writer = csv.writer(open(filename, 'wb'))

    # Write the test options
    writer.writerow(['na', na])
    writer.writerow(['nc', nc])
    writer.writerow(['ncat', ncat])
    writer.writerow(['ns', ns])
    writer.writerow(['na_gen', na_gen])
    writer.writerow(['pcerrors', pcerrors])
    writer.writerow(['nseeds', nseeds])
    writer.writerow(['', ''])

    # Create a test results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _na, _nc, _ncat, _ns, _na_gen, _pcerrors, seed \
        in product(na, nc, ncat, ns, na_gen, pcerrors, seeds):

        t1 = time.time()
        t = test_lp_avfsort(seed, _na, _nc, _ncat, _ns, _na_gen, _pcerrors)
        t2 = time.time()

        if initialized is False:
            writer.writerow(t.get_attributes())
            initialized = True

        t.tocsv(writer)
        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])
    t = results.summary(['na', 'nc', 'ncat', 'ns', 'na_gen', 'pcerrors'], [
        'na_err'
        'obj', 'ca', 'ca_errors', 'altered', 'ca2', 'ca2_errors', 'ca_gen',
        'ca_gen_err', 't_total', 't_const', 't_solve'
    ])
    t.tocsv(writer)
Exemplo n.º 9
0
def run_tests(na, nc, ncat, na_gen, pcerrors, nseeds, filename):
    # Create the CSV writer
    writer = csv.writer(open(filename, 'wb'))

    # Write the test options
    writer.writerow(['na', na])
    writer.writerow(['nc', nc])
    writer.writerow(['ncat', ncat])
    writer.writerow(['na_gen', na_gen])
    writer.writerow(['pcerrors', pcerrors])
    writer.writerow(['nseeds', nseeds])
    writer.writerow(['random_model_type', random_model_type])
    writer.writerow(['learned_model_type', learned_model_type])
    writer.writerow(['', ''])

    # Create a test results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _na, _nc, _ncat, _na_gen, _pcerrors, seed \
        in product(na, nc, ncat, na_gen, pcerrors, seeds):

        t1 = time.time()
        t = test_lp_learning_weights(seed, _na, _nc, _ncat, _na_gen,
                                     _pcerrors)
        t2 = time.time()

        if initialized is False:
            writer.writerow(t.get_attributes())
            initialized = True

        t.tocsv(writer)
        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])
    t = results.summary(['na', 'nc', 'ncat', 'na_gen', 'pcerrors'],
                        ['obj', 'ca', 'ca_errors', 'ca2', 'ca2_errors',
                         'ca_gen', 't_total', 't_const', 't_solve'])
    t.tocsv(writer)
Exemplo n.º 10
0
def run_tests(na, nc, ncat, pcexamples, pcerrors, nseeds, filename):
    # Create the CSV writer
    writer = csv.writer(open(filename, 'wb'))

    # Write the test options
    writer.writerow(['na', na])
    writer.writerow(['nc', nc])
    writer.writerow(['ncat', ncat])
    writer.writerow(['pcexamples', pcexamples])
    writer.writerow(['pcerrors', pcerrors])
    writer.writerow(['nseeds', nseeds])
    writer.writerow(['', ''])

    # Create a test results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _na, _nc, _ncat, _pcexamples, _pcerrors, seed \
        in product(na, nc, ncat, pcexamples, pcerrors, seeds):

        t1 = time.time()
        t = test_heur_mrsort_coalitions(seed, _na, _nc, _ncat, _pcexamples,
                                        _pcerrors)
        t2 = time.time()

        if initialized is False:
            writer.writerow(t.get_attributes())
            initialized = True

        t.tocsv(writer)
        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])
    t = results.summary(['na', 'nc', 'ncat', 'pcexamples', 'pcerrors'],
                        ['ncoal', 'ncoal_ni', 'ncoal_add'])
    t.tocsv(writer)
Exemplo n.º 11
0
def run_tests(na, nc, ncat, pcerrors, nseeds, filename):
    # Create the CSV writer
    writer = csv.writer(open(filename, 'wb'))

    # Write the test options
    writer.writerow(['na', na])
    writer.writerow(['nc', nc])
    writer.writerow(['ncat', ncat])
    writer.writerow(['pcerrors', pcerrors])
    writer.writerow(['nseeds', nseeds])
    writer.writerow(['', ''])

    # Create a test results instance
    results = test_results()

    # Initialize the seeds
    seeds = range(nseeds)

    # Run the algorithm
    initialized = False
    for _na, _nc, _ncat, _pcerrors, seed \
        in product(na, nc, ncat, pcerrors, seeds):

        t1 = time.time()
        t = test_heur_mrsort_init_profiles(seed, _na, _nc, _ncat, _pcerrors)
        t2 = time.time()

        if initialized is False:
            writer.writerow(t.get_attributes())
            initialized = True

        t.tocsv(writer)
        print("%s (%5f seconds)" % (t, t2 - t1))

        results.append(t)

    # Perform a summary
    writer.writerow(['', ''])
    t = results.summary(['na', 'nc', 'ncat', 'pcerrors'],
                        ['ca_rdom', 'ca_heur'])
    t.tocsv(writer)