21 lines
753 B
Python
21 lines
753 B
Python
import json
|
|
from crisisops.planner import ADMMPlanner
|
|
from crisisops.core import GraphOfContracts, Object, Morphism
|
|
|
|
|
|
def build_simple_goC():
|
|
a = Object(id="a1", type="resource", attributes={"qty": 10})
|
|
b = Object(id="b1", type="node", attributes={"cap": 5})
|
|
m = Morphism(id="m1", source_id=a.id, target_id=b.id, type="dispatch", signals={})
|
|
return GraphOfContracts(objects={a.id: a, b.id: b}, morphisms={m.id: m})
|
|
|
|
|
|
def test_planner_allocates_dispatch_actions():
|
|
gof = build_simple_goC()
|
|
planner = ADMMPlanner()
|
|
plan = planner.optimize(gof)
|
|
# Expect at least one action and that it's a dispatch action
|
|
assert isinstance(plan.actions, list)
|
|
if plan.actions:
|
|
assert plan.actions[0]["action"] == "dispatch"
|