Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
% Space Syntax with Prolog % Pedro Afonso Fernandes (paf@ucp.pt) % April 2022 % La Bataille farmhouse, Normandy, France % Source: % Hanson, J., Decoding Homes and Houses, 1998, p. 85 (Fig. 3.4) % Knowledge base connected(outside,vestibule_1,1). connected(outside,salle_commune,1). connected(outside,vestibule_2,1). connected(vestibule_1,grande_salle,1). connected(vestibule_1,couloir,1). connected(couloir,salle,1). connected(salle,bureau,1). connected(couloir,salle_commune,1). connected(vestibule_2,salle_commune,1). connected(vestibule_2,depense,1). connected(depense,laiterie,1). connected(laiterie,laverie,1). connected(laverie,salle_commune,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). % graph(outside,Y,D). % connectivity(outside,Y,AC), % 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).