29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
"""Minimal command-line interface to exercise NeuPlan MVP."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from typing import List
|
|
from neuplan.dsl import LocalProblem, PlanDelta, SharedVariables
|
|
from neuplan.backends.loihi import LoihiBackend
|
|
from neuplan.runtime import OnboardRuntime
|
|
from neuplan.dsl import to_nir
|
|
|
|
|
|
def demo():
|
|
# Simple demo problem: two assets with a delta depending on energy
|
|
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)
|
|
backend = LoihiBackend()
|
|
runtime = OnboardRuntime(backend)
|
|
res = runtime.plan([lp1, lp2], [delta], shared, time_budget_s=2.0)
|
|
print("NIR:", json.dumps(nir, indent=2))
|
|
print("Result:", json.dumps(res, indent=2))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
demo()
|