Files
simulationexam/.ipynb_checkpoints/brute_force-checkpoint.ipynb
2015-12-20 13:43:45 -05:00

7.9 KiB

In [23]:
%pylab inline
from network.network import is_valid_network, get_number_of_activated_antenna, pp_network
from numpy import mean

def get_all_possible_network(box_size):
    number_of_square = box_size * box_size
    return iter(range(2**number_of_square))

Populating the interactive namespace from numpy and matplotlib
In [24]:
box_size = 5

valid_networks = []
for network in get_all_possible_network(box_size):
    if is_valid_network(network, box_size):
        valid_networks.append(network)
In [18]:
hist(list(map(get_number_of_activated_antenna, valid_networks)), bins=100)
None
In [19]:
mean(list(map(get_number_of_activated_antenna, valid_networks)))
Out [19]:
2.4126984126984126
In [15]:
print(pp_network(valid_networks[-1], box_size))
■-□-■-□-■
□-■-□-■-□
■-□-■-□-■
□-■-□-■-□
■-□-■-□-■

In [20]:
len(valid_networks)
Out [20]:
63
In [ ]:
In [16]:
2**64
Out [16]:
18446744073709551616