Esempio n. 1
0
 def test_nodes_address(self):
     manager = LocalhostNodesManager(1, 2)
     self.assertEqual(manager.get_next_node_address()[0], 'localhost')
     self.assertNotEqual(manager.get_self_address()[1], manager.get_next_node_address()[1])
__author__ = 'Stanislav Ushakov'

from immune import ExpressionsImmuneSystem, DataFileStorageHelper, ExpressionsImmuneSystemConfig
from exchanger import PeerToPeerExchanger, LocalhostNodesManager
import sys

#start as "python node_main.py node_num number_of_nodes"
if __name__ == '__main__':
    number = int(sys.argv[1])
    number_of_nodes = int(sys.argv[2])

    nodes_manager = LocalhostNodesManager(number, number_of_nodes)

    config = ExpressionsImmuneSystemConfig()
    config.number_of_lymphocytes = 200
    config.number_of_iterations = 200
    config.number_of_iterations_to_exchange = 30
    config.maximal_height = 5

    variables, values = DataFileStorageHelper.load_from_file('test_x_y.txt')

    exchanger = PeerToPeerExchanger(nodes_manager)

    results = []
    immuneSystem = ExpressionsImmuneSystem(exact_values=values,
                                           variables=variables,
                                           exchanger=exchanger,
                                           config=config)
    best = immuneSystem.solve()
    print(best)
Esempio n. 3
0
 def test_self_address(self):
     manager = LocalhostNodesManager(1, 2)
     self.assertEqual(manager.get_self_address()[0], 'localhost')
     self.assertGreaterEqual(manager.get_self_address()[1], 1024)