Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
% Space Syntax with Prolog % Pedro Afonso Fernandes (paf@ucp.pt) % June 2021 % Ashanti Besease Shrine - Ejisu, Kumasi, Ghana % Sources: % https://www.zamaniproject.org/site-ghana-kumasi-asante-shrine.html % https://www.touristspots.org/ashanti-beasease-shrine-in-ashanti-ghana/ % Hillier, B. & Hanson, J., The social logic of space, 1984, p. 181 % Knowledge base connected(outside,hall,1). connected(hall,yard,1). connected(yard,kitchen,1). connected(yard,drum_room,1). connected(yard,singers_patio,1). connected(yard,waiting_room,1). connected(waiting_room,shrine_room,1). connected(singers_patio,passage,1). connected(passage,backyard,1). connected(backyard,outside,1). % Space Syntax measures: adjacent(X,Y,1):-connected(X,Y,1). adjacent(X,Y,1):-connected(Y,X,1). connectivity(X,Y,AC):-aggregate_all(count,adjacent(X,Y,1),AC). control(X,Y,E):-aggregate_all(sum(G),(adjacent(X,Z,1),connectivity(Z,Y,AC),G is 1/AC),E). depth(X,Y,1):-adjacent(X,Y,1). depth(X,Y,2):-adjacent(X,Z,1),depth(Z,Y,1),dif(X,Y). depth(X,Y,3):-adjacent(X,Z,1),depth(Z,Y,2),dif(X,Y). depth(X,Y,4):-adjacent(X,Z,1),depth(Z,Y,3),dif(X,Y). depth(X,Y,5):-adjacent(X,Z,1),depth(Z,Y,4),dif(X,Y). depth(X,Y,6):-adjacent(X,Z,1),depth(Z,Y,5),dif(X,Y). depth(X,Y,7):-adjacent(X,Z,1),depth(Z,Y,6),dif(X,Y). depth(X,Y,8):-adjacent(X,Z,1),depth(Z,Y,7),dif(X,Y). depth(X,Y,9):-adjacent(X,Z,1),depth(Z,Y,8),dif(X,Y). graph(X,Y,D):-distinct([Y],depth(X,Y,D)). controllability(X,Y,Z,F):-connectivity(X,Y,AC),aggregate_all(count,graph(X,Z,2),D2),F is AC/(AC+D2). totdepth(X,Y,TD):-aggregate_all(sum(D),graph(X,Y,D),TD). nodes(X,Y,D,N):-aggregate_all(count,graph(X,Y,D),N). meandepth(X,Y,D,MD):-totdepth(X,Y,TD),nodes(X,Y,D,N), MD is TD/N. integration(X,Y,D,I):-meandepth(X,Y,D,MD), I is 1/MD. asymmetry(X,Y,D,RA):-totdepth(X,Y,TD),nodes(X,Y,D,N), RA is 2*(TD/N-1)/(N-1). dvalue(K,DV):-DV is 2*(K*(log((K+2)/3)/log(2)-1)+1)/((K-1)*(K-2)). rra(X,Y,D,RRA):-asymmetry(X,Y,D,RA),nodes(X,Y,D,N),dvalue(N+1,DV), RRA is RA/DV. integrationHH(X,Y,D,IHH):-rra(X,Y,D,RRA), IHH is 1/RRA. % Local measures for radius R: rdepth(X,Y,D,R):-depth(X,Y,D),D =< R. rgraph(X,Y,D,R):-distinct([Y],rdepth(X,Y,D,R)). rtotdepth(X,Y,TD,R):-aggregate_all(sum(D),rgraph(X,Y,D,R),TD). rnodes(X,Y,D,N,R):-aggregate_all(count,rgraph(X,Y,D,R),N). rmeandepth(X,Y,D,MD,R):-rtotdepth(X,Y,TD,R),rnodes(X,Y,D,N,R), MD is TD/N. rintegration(X,Y,D,I,R):-rmeandepth(X,Y,D,MD,R), I is 1/MD. rasymmetry(X,Y,D,RA,R):-rtotdepth(X,Y,TD,R),rnodes(X,Y,D,N,R), RA is 2*(TD/N-1)/(N-1). rrra(X,Y,D,RRA,R):-rasymmetry(X,Y,D,RA,R),rnodes(X,Y,D,N,R),dvalue(N+1,DV), RRA is RA/DV. rintegrationHH(X,Y,D,IHH,R):-rrra(X,Y,D,RRA,R), IHH is 1/RRA. % Simple one-line queries (examples): % adjacent(outside,Y,1). % connectivity(outside,Y,AC). % graph(outside,Y,D). % control(outside,Y,E). % controllability(outside,Y,Z,F). % totdepth(outside,Y,TD). % meandepth(outside,Y,D,MD). % integration(outside,Y,D,I). % asymmetry(outside,Y,D,RA). % rra(outside,Y,D,RRA). % integrationHH(outside,Y,D,IHH). % Multi-condition query: % X=outside, % connectivity(X,Y,AC), control(X,Y,E), controllability(X,Y,Z,F), totdepth(X,Y,TD), meandepth(X,Y,D,MD), % integration(X,Y,D,I), asymmetry(X,Y,D,RA), rra(X,Y,D,RRA), integrationHH(X,Y,D,IHH).