CSE505/Assignment1
2024-02-22 17:33:26 -05:00
..
A feat: readme 2024-02-22 17:33:26 -05:00
B feat: readme 2024-02-22 17:33:26 -05:00
C feat: readme 2024-02-22 17:33:26 -05:00
Extra feat: readme 2024-02-22 17:33:26 -05:00
randomgen.py feat: readme 2024-02-22 17:33:26 -05:00
reachin1000 feat: readme 2024-02-22 17:33:26 -05:00
README.md feat: readme 2024-02-22 17:33:26 -05:00

Assignment 1

Part A

Append

xsb
['A/append.P'].
suffix([1,2], [1,2,3,4]).
cut([1,2,3]).

Reach

generate input set

python randomgen.py [number of nodes]

Transitive closure and cycle

xsb
['A/cycle.P'].
path(1,2) .
cycle(1).

N-queens

xsb
['A/queens.P'].
timeNQueen(8).
timeOneQueen(8).

Part B

Reach

generate input set

python randomgen.py [number of nodes]
clingo --models 0 B/reach.lp
Input size Way 1 Way 2 Way 3 Way 4
10000 0.655s 0.703s 0.664s 0.665s
20000 1.376s 1.446s 1.290s 1.292s
50000 3.355s 3.501s 2.750s 1.645s
100000 6.778s 5.002s 3.375s 3.438s
200000 12.119s 7.514s 7.267s 7.021s

Though it looks like the Way4 is way better tha Way 1(Almost twice as fast), but if we let the computer to rest for a while and rerun them the other way(start from 4, then 3, follow by 2 and 1), we got

Input size Way 1 Way 2 Way 3 Way 4
200000 7.146s 7.610s 7.120s 12.103s

It is exactly the other way around! I belive it is because the input file becomes too large (42 MByte), so it waste a lot of time to load it to memory then cache, and the following ones has much higher cache hits rate, so the first one takes way longer than the others.

N-queens

clingo --models 0 B/nqueens.lp
clingo --models 1 B/nqueens.lp
Number of queens Time for 1 queen Time for all queens
8 0.004s 0.006s
10 0.003s 0.086s
12 0.004s 4.909s
14 0.006s Too long to run
20 0.011s
50 0.073s
100 0.463s
200 3.233s
500 35.073s

Part C

N-queens