Пример #1
0
def test_visualize_no_obs():
    nmpc = MultiAgentNMPC()
    nmpc.register_agent("toto", Position(1, 2), Position(4, 5))
    nmpc.register_agent("tata", Position(2, 2), Position(7, 5))
    nmpc.register_agent("titi", Position(2, 3), Position(4, 8))
    nmpc.run_simulation()
    nmpc.visualize("toto", 10, 10)
from os import path
import sys

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from pymapf.decentralized.nmpc.nmpc import MultiAgentNMPC
from pymapf.decentralized.position import Position
import numpy as np
import time

runtimes = []
global_runtimes_per_agents = []

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 10), Position(20, 10), vmin=0)
sim.register_agent("2", Position(20, 10), Position(0, 10), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes_per_agents = {}
for key, agent in sim.agents.items():
    runtimes_per_agents[key] = agent.total_computation_runtime
global_runtimes_per_agents.append(runtimes_per_agents)
runtimes.append((time.time() - stamp, 2))

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 10), Position(20, 10), vmin=0)
sim.register_agent("2", Position(20, 10), Position(0, 10), vmin=0)
sim.register_agent("3", Position(10, 20), Position(20, 0), vmin=0)
sim.register_agent("4", Position(20, 0), Position(10, 20), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes_per_agents = {}
from os import path
import sys

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from pymapf.decentralized.nmpc.nmpc import MultiAgentNMPC
from pymapf.decentralized.position import Position
import numpy as np
import time

runtimes = []
global_runtimes_per_agents = []

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 5), Position(10, 5), vmin=0)
sim.register_agent("2", Position(10, 5), Position(0, 5), vmin=0)
sim.register_agent("3", Position(5, 10), Position(5, 0), vmin=0)
sim.register_agent("4", Position(5, 0), Position(5, 10), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes_per_agents = {}
for key, agent in sim.agents.items():
    runtimes_per_agents[key] = agent.total_computation_runtime
global_runtimes_per_agents.append(runtimes_per_agents)
runtimes.append((time.time() - stamp, 100))

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 6), Position(12, 6), vmin=0)
sim.register_agent("2", Position(12, 6), Position(0, 6), vmin=0)
sim.register_agent("3", Position(6, 12), Position(6, 0), vmin=0)
sim.register_agent("4", Position(6, 0), Position(6, 12), vmin=0)
stamp = time.time()
Пример #4
0
from os import path
import sys

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from pymapf.decentralized.nmpc.nmpc import MultiAgentNMPC
from pymapf.decentralized.position import Position
import numpy as np
import time

runtimes = []

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 5), Position(10, 5), vmin=0)
sim.register_agent("2", Position(10, 5), Position(0, 5), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes.append((time.time() - stamp, 2))

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 5), Position(10, 5), vmin=0)
sim.register_agent("2", Position(10, 5), Position(0, 5), vmin=0)
sim.register_agent("3", Position(5, 10), Position(5, 0), vmin=0)
sim.register_agent("4", Position(5, 0), Position(5, 10), vmin=0)
stamp = time.time()
sim.run_simulation()
runtimes.append((time.time() - stamp, 4))

sim = MultiAgentNMPC()
sim.register_agent("1", Position(0, 5), Position(10, 5), vmin=0)
sim.register_agent("2", Position(10, 5), Position(0, 5), vmin=0)
sim.register_agent("3", Position(5, 10), Position(5, 0), vmin=0)
Пример #5
0
def test_sim_obstacles():
    nmpc = MultiAgentNMPC()
    nmpc.register_agent("toto", Position(1, 2), Position(4, 5))
    nmpc.register_agent("tata", Position(2, 2), Position(7, 5))
    nmpc.register_agent("titi", Position(2, 3), Position(4, 8))
    nmpc.register_obstacle(2, 3.14, Position(2, 3))
    nmpc.register_obstacle(2, -3.14, Position(10, 7))
    nmpc.run_simulation()
Пример #6
0
def test_nmpc_obstacles():
    nmpc = MultiAgentNMPC()
    nmpc.register_obstacle(2, 3.14, Position(2, 3))
    assert len(nmpc.obstacles_objects) == 1
Пример #7
0
def test_nmpc_agents():
    nmpc = MultiAgentNMPC()
    nmpc.register_agent("toto", Position(1, 2), Position(4, 5))
    nmpc.register_agent("tata", Position(2, 2), Position(7, 5))
    nmpc.register_agent("titi", Position(2, 3), Position(4, 8))
    assert len(nmpc.agents) == 3
Пример #8
0
from os import path
import sys

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from pymapf.decentralized.nmpc.nmpc import MultiAgentNMPC
from pymapf.decentralized.position import Position
import numpy as np

sim = MultiAgentNMPC()
sim.register_agent("r2d2", Position(0, 3), Position(10, 7), vmin=0)
sim.register_agent("bb8", Position(0, 7), Position(5, 10), vmin=0)
sim.register_agent("c3po", Position(10, 7), Position(5, 0), vmin=0)
sim.register_agent("r4d4", Position(10, 3), Position(0, 3), vmin=0)
sim.register_agent("wally", Position(5, 10), Position(0, 7), vmin=0)
sim.register_agent("spot", Position(5, 0), Position(10, 3), vmin=0)
sim.run_simulation()
sim.visualize("switch_positions_nmpc", 10, 10)