<jupyter_start><jupyter_text>Intilization<jupyter_code>import os
import itertools
import sys
from math import factorial as fac
sys.path.append("D:/TU_Delft/Msc_Building_Technology/Semester_3/Graduation/Aditya_Graduation_Project_BT/06_Libraries")
import topogenesis as tg
import pyvista as pv
import trimesh as tm
import numpy as np
np.random.seed(0)
np.set_printoptions(threshold=sys.maxsize)
import networkx as nx
import pickle<jupyter_output><empty_output><jupyter_text>Load Lattice availability<jupyter_code>lattice_path = os.path.relpath('Base_lattice_2.csv')
avail_lattice_base = tg.lattice_from_csv(lattice_path)
avail_lattice = avail_lattice_base*1
init_avail_lattice = tg.to_lattice(np.copy(avail_lattice*1), avail_lattice)<jupyter_output><empty_output><jupyter_text>Create Stencil<jupyter_code># creating neighborhood definition
stencil_von_neumann = tg.create_stencil("von_neumann", 1, 1)
stencil_von_neumann.set_index([0,0,0], 0)
#print(stencil_von_neumann)<jupyter_output><empty_output><jupyter_text>Create graph<jupyter_code># find the number of all voxels
vox_count = avail_lattice.size 

# initialize the adjacency matrix
adj_mtrx = np.zeros((vox_count,vox_count))

# extract the neighbourhood of all voxels
# all_vox_neighs = avail_lattice.find_neighbours(stencil)

# Finding the index of the available voxels in avail_lattice
avail_index = np.array(np.where(avail_lattice == 1)).T

# fill the adjacency matrix using the list of all neighbours
for vox_loc in avail_index:
    # find the 1D id
    vox_id = np.ravel_multi_index(vox_loc, avail_lattice.shape)
    # retrieve the list of neighbours of the voxel based on the stencil
    vox_neighs = avail_lattice.find_neighbours_masked(stencil_von_neumann, loc = vox_loc)
    # iterating over the neighbours
    for neigh in vox_neighs:
        # setting the entry to one
        adj_mtrx[vox_id, neigh] = 1.0

# construct the graph 
g = nx.from_numpy_array(adj_mtrx)<jupyter_output><empty_output><jupyter_text>Create distance matrix<jupyter_code>#dist_mtrx = nx.floyd_warshall_numpy(g)
#dist_mtrx = pickle.dump( dist_mtrx, open( "dist_matrix.p", "wb" ) )
pickle_matrix = pickle.load( open( "dist_matrix.p", "rb" ) )<jupyter_output><empty_output><jupyter_text>Create a list of points to create graphs<jupyter_code>flattened_lattice = avail_lattice.flatten()
all_indexes1D= np.array(flattened_lattice.nonzero())
all_indexes1D_tuple = flattened_lattice.nonzero()
all_indexes1D_list = []
for sublist in all_indexes1D_tuple:
    for item in sublist:
        all_indexes1D_list.append(item)
len(all_indexes1D_list)
## take out 3d arry where --1 then filter out themiddle segment and run the iterations<jupyter_output><empty_output><jupyter_text>Create iterations<jupyter_code># iteration of all possible 5 nodes
all_permutations_nodes = (list(itertools.permutations(all_indexes1D_list, 3)))


## indexing to check distances 
all_permutations_indexes = (list(itertools.permutations(range(5), 2)))
all_permutations_indexes
all_valid_permutations=[]

for perm, index in zip(all_permutations_nodes,all_permutations_indexes):
    print (perm)
    print (index)<jupyter_output>(243, 244, 245)
(0, 1)
(243, 244, 246)
(0, 2)
(243, 244, 247)
(0, 3)
(243, 244, 248)
(1, 0)
(243, 244, 249)
(1, 2)
(243, 244, 250)
(1, 3)
(243, 244, 251)
(2, 0)
(243, 244, 254)
(2, 1)
(243, 244, 255)
(2, 3)
(243, 244, 256)
(3, 0)
(243, 244, 257)
(3, 1)
(243, 244, 258)
(3, 2)<jupyter_text>Conditional statements for checking the validity<jupyter_code>'''
x=[]
for i, j, k, l,m in itertools.product(range(243,1142), range(243,1142),range(243,1142),range(243,1142),range(243,1142)):
    if pickle_matrix[i][j]> 10:
    elif pickle_matrix[i][j]> 10:
    elif pickle_matrix[i][k]> 10:
    elif pickle_matrix[i][l]> 10:
    elif pickle_matrix[i][m]> 10:
        x.append(i)<jupyter_output><empty_output><jupyter_text>Find out set of possible nodes<jupyter_code>x (quadratic assignment)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11195734958111196, 'fraction_numerical': 0.05255140898705255, 'mean_word_length': 6.680311890838206, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '577090', 'license': 'MIT', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1522, 'n_words': 328, 'path': '02.Zoning_problem/Toy_Problems/TCR Simulation.ipynb', 'repo_name': 'adityasoman/GEN-ARCH', 'size': '3939'}