def test_generate(self): """Test generation.""" env = Environment({ 'base': matrix([ [0, 0, 0], # beacon 1 [60, -40, 0], # beacon 2 [50, 50, 0], # beacon 3 ]), 'radius': matrix([ 20, # beacon 1 60, # beacon 2 60, # beacon 3 ]) }) points = on_beacon_sphere_surface(environment=env, beacon_index=1, num_of_points=256) center = env.config['base'][1] radius = env.config['radius'].A[0][1] self._check_points(radius, points, center=center)
env_config = { "inertial_weight": 2, "cognition": 2, "social": 1, "random": random_generator, "base": matrix([[0, 0, 0], [60, -40, 0], [50, 50, 0], [25, 0, 25]]), # beacon 1 # beacon 2 # beacon 3 # beacon 4 "radius": matrix([20, 60, 60, 30]), # beacon 1 # beacon 2 # beacon 3 # beacon 4 } # create environment env = Environment(config=env_config) # how many particles for each beacon total = int(sys.argv[1]) # initial point generator (on sphere surface) position_generator_1 = on_beacon_sphere_surface(environment=env, beacon_index=0, num_of_points=total) position_generator_2 = on_beacon_sphere_surface(environment=env, beacon_index=1, num_of_points=total) position_generator_3 = on_beacon_sphere_surface(environment=env, beacon_index=2, num_of_points=total) position_generator_4 = on_beacon_sphere_surface(environment=env, beacon_index=3, num_of_points=total) for i in range(total): # start around beacon 1 PSOParticle( environment=env, id="P{}env1".format(i), current=Information(position=next(position_generator_1)), velocity=random_generator.random(), vmax=1,
matrix([ 20, # beacon 1 60, # beacon 2 60, # beacon 3 30, # beacon 4 ]) } # create environment env = Environment(config=env_config) # how many particles for each beacon total = int(sys.argv[1]) # initial point generator (on sphere surface) position_generator_1 = on_beacon_sphere_surface(environment=env, beacon_index=0, num_of_points=total) position_generator_2 = on_beacon_sphere_surface(environment=env, beacon_index=1, num_of_points=total) position_generator_3 = on_beacon_sphere_surface(environment=env, beacon_index=2, num_of_points=total) position_generator_4 = on_beacon_sphere_surface(environment=env, beacon_index=3, num_of_points=total) for i in range(total):