コード例 #1
0
ファイル: ssdsat.py プロジェクト: NoemieRullier/GUN_TER
def rw(views, queries, ontology, costs, preflist):
    # generate the MCD theory
    t = mcdsat.mcd.mcd_theory(queries[0], views, ontology)

    # add preferences to the theory
    if preflist:
        pref_t = preferences.preference_clauses(queries[0], views, preflist, t)
    else:
        pref_t = t

    # generate the RW theory based on the MCD theory
    rw_t = mcdsat.rw.rw_theory(queries[0], views, pref_t)

    # feed the theory to the d-DNNF compiler
    nnf_filename = compile_ddnnf(rw_t)

    # enumerate the models of the d-DNNF theory
    models = enumerate_models(nnf_filename)

    #TODO move somewhere more suitable
    if options.logging_output_file:
        modelcount = count_models(nnf_filename)
        ff = open(options.logging_output_file + ".count", "w")
        print >> ff, modelcount
        ff.close()

        esttime = model_enumeration_time(nnf_filename)
        ff = open(options.logging_output_file + ".time", "w")
        print >> ff, esttime
        ff.close()
    
    for m in models:
    #    print "".join([str(s)+"," for s in rw_rebuild(queries[0], views, rw_t, m)])
        print rw_rebuild(queries[0], views, rw_t, m)
コード例 #2
0
ファイル: ssdsat.py プロジェクト: NoemieRullier/GUN_TER
def bestrw(views, queries, ontology, costs, preflist):
    # generate the MCD theory
    t = mcdsat.mcd.mcd_theory(queries[0], views, ontology)

    # add MCD preferences to the theory
    pref_t = preferences.preference_clauses(queries[0], views, preflist, t)

    # generate the RW theory based on the MCD theory
    rw_t = mcdsat.rw.rw_theory(queries[0], views, pref_t)

    # add RW preferences to the theory
    pref_rw_t = preferences.preference_rw_clauses(queries[0], views, preflist, rw_t)

    # feed the theory to the d-DNNF compiler
    nnf_filename = compile_ddnnf(pref_rw_t)

    # generate the the cost file
    cost_file = preferences.preference_cost_file(preflist if preflist else [], pref_rw_t, len(views))

    # find the best model of the d-DNNF theory and its cost
    (cost, model) = enumerate_best_model(nnf_filename, cost_file)

    #TODO move somewhere more suitable
    if options.logging_output_file:
        modelcount = count_models(nnf_filename)
        ff = open(options.logging_output_file + ".count", "w")
        print >> ff, modelcount
        ff.close()

        esttime = model_enumeration_time(nnf_filename)
        ff = open(options.logging_output_file + ".time", "w")
        print >> ff, esttime
        ff.close()

    print cost, rw_rebuild(queries[0], views, pref_rw_t, model)
コード例 #3
0
ファイル: ssdsat.py プロジェクト: NoemieRullier/GUN_TER
def mcd(views, queries, ontology, costs, preflist):
    # generate the MCD theory
    t = mcdsat.mcd.mcd_theory(queries[0], views, ontology)

    # add preferences to the theory
    if preflist:
        pref_t = preferences.preference_clauses(queries[0], views, preflist, t)
    else:
        pref_t = t

    # feed the theory to the d-DNNF compiler
    nnf_filename = compile_ddnnf(pref_t)

    # enumerate the models of the d-DNNF theory
    models = enumerate_models(nnf_filename)

    for m in models:
        print map(lambda v : t.vs.reverse(v), m)