File: setconf-lua.lp

package info (click to toggle)
gringo 5.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,128 kB
  • sloc: cpp: 210,867; ansic: 37,507; python: 11,271; yacc: 825; javascript: 627; sh: 368; xml: 364; makefile: 102
file content (52 lines) | stat: -rw-r--r-- 1,561 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
#script (lua)

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

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

    print_conf(prg.configuration, "")

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

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

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

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

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

#end.

{ a; b; c }.