Ejemplo n.º 1
0
    )

# Load logging configuration
config_file = "examples/followbest_particles.json"
with open(config_file) as data_file:
    data = json.load(data_file)
logging.config.dictConfig(data)

# engine1 for env1
engine1 = ParticleEngine(
    config={
        'max_iterations': 40
    },
    environment=env1
)
engine1.start()
# engine2 for env2
engine2 = ParticleEngine(
    config={
        'max_iterations': 40
    },
    environment=env2
)
engine2.start()

# wait engines
engine1.join()
engine2.join()

bestParticle = env1.neighborBest
print("Object located: ", bestParticle.best.position)
Ejemplo n.º 2
0
    matrix([
        3.024,  # beacon 1
        6.4,  # beacon 2
        6.63,  # beacon 3
    ])
}
env = Environment(config=config)

PSOParticle(environment=env,
            id="P1",
            current=Information(position=config['base'][0]),
            velocity=matrix([0.1, 0.1, 0.1]),
            vmax=3)
PSOParticle(environment=env,
            id="P2",
            current=Information(position=config['base'][1]),
            vmax=10)
PSOParticle(environment=env,
            id="P3",
            current=Information(position=config['base'][2]),
            vmax=10)

logging.basicConfig(filename='logs/find_point.log', level=logging.DEBUG)

engine = ParticleEngine(config={'max_iterations': 100}, environment=env)
engine.start()
engine.join()

bestParticle = env.best
print("Object located: ", bestParticle.best.position)
        environment=env,
        id="P{}env1".format(i + total),
        current=Information(position=next(position_generator_2)),
        velocity=random_generator.random(),
        vmax=1,
    )
    # start around beacon 3
    PSOParticle(
        environment=env,
        id="P{}env1".format(i + total * 2),
        current=Information(position=next(position_generator_3)),
        velocity=random_generator.random(),
        vmax=1,
    )
    # start around beacon 4
    FollowBestParticle(
        environment=env,
        id="P{}env1".format(i + total * 3),
        current=Information(position=next(position_generator_4)),
        velocity=random_generator.random(),
        vmax=1,
    )

# start engine
engine = ParticleEngine(config={"max_iterations": 70}, environment=env)
engine.start()
engine.join()

bestParticle = env.best
print("Object located: ", bestParticle.best.position)