30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
import json
|
|
import sys
|
|
import os
|
|
# Ensure local package path is discoverable when running from the repo root
|
|
repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
if repo_root not in sys.path:
|
|
sys.path.insert(0, repo_root)
|
|
|
|
from neuplan.dsl import LocalProblem, PlanDelta, SharedVariables
|
|
from neuplan.dsl import to_nir
|
|
from neuplan.backends.loihi import LoihiBackend
|
|
from neuplan.runtime import OnboardRuntime
|
|
|
|
|
|
def test_nir_generation_and_runtime_plan():
|
|
lp1 = LocalProblem(asset="rover1", constraints={"max_speed": 5}, objective={"energy": 1.0})
|
|
lp2 = LocalProblem(asset="droneA", constraints={"max_alt": 100}, objective={"energy": 0.8})
|
|
delta = PlanDelta(delta_id="d1", changes={"requires": ["rover1"]})
|
|
shared = SharedVariables(variables={"global_time": 0})
|
|
|
|
nir = to_nir([lp1, lp2], [delta], shared)
|
|
assert isinstance(nir, dict)
|
|
assert "nodes" in nir and "edges" in nir
|
|
|
|
backend = LoihiBackend()
|
|
runtime = OnboardRuntime(backend)
|
|
res = runtime.plan([lp1, lp2], [delta], shared, time_budget_s=2.0)
|
|
assert res["status"] in {"ok", "timeout"}
|
|
assert "plan" in res
|