File: setconf-lua.lp

package info (click to toggle)
gringo 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,260 kB
  • ctags: 10,755
  • sloc: cpp: 55,049; python: 629; yacc: 569; sh: 124; makefile: 23
file content (53 lines) | stat: -rw-r--r-- 1,484 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#script (lua)

function print_conf(conf, ident)
    for _, x in ipairs(conf:keys()) do
        key = string.gsub(x, "[.]", "")
        if key == x then
            print (ident .. key .. "[=" .. tostring(conf[key]) .. "] - " .. conf["__desc_" .. key])
        else
            subconf = conf[key]
            label   = key
            if #subconf >= 0 then
                label = label .. "[0.." .. tostring(#subconf) .. "]"
            end
            print (ident .. label .. " - " .. conf["__desc_" .. key])
            print_conf(subconf, ident .. "  ")
        end
    end
end

function main(prg)
    prg:ground({{"base", {}}})
    
    print_conf(prg.conf, "")

    print ("The heuristics of the solvers in the 'many' portfolio:")
    prg.conf.configuration = "many"
    prg.conf.solve.parallel_mode = 3 -- just use the first 3 solvers
    for x in prg.conf.solver:iter() do
        print ("  " .. x.heuristic)
    end

    prg.conf.solve.models = 0
    print ("==================== All Models ===================")
    prg:solve()

    prg.conf.solve.models = 1
    print ("===================== One Model ===================")
    prg:solve()

    prg.conf.solve.models = 0
    prg.conf.solve.enum_mode = "cautious"
    print ("=============== Cautious Consequences =============")
    prg:solve()

    prg.conf.solve.models = 0
    prg.conf.solve.enum_mode = "brave"
    print ("================ Brave Consequences ===============")
    prg:solve()
end

#end.

{ a; b; c }.