38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Minimal CLI to exercise CrisisOps MVP."""
|
|
import argparse
|
|
import json
|
|
import time
|
|
|
|
from crisisops.planner import ADMMPlanner
|
|
from crisisops.core import GraphOfContracts, Object, Morphism
|
|
|
|
|
|
def build_sample_goC():
|
|
# Simple two-object domains: field resources and shelters
|
|
o1 = Object(id="fuel-truck-1", type="vehicle", attributes={"capacity": 1000})
|
|
o2 = Object(id="shelter-a", type="facility", attributes={"capacity": 500})
|
|
o3 = Object(id="fuel-warehouse", type="resource", attributes={"stock": 2000})
|
|
m1 = Morphism(id="m1", source_id=o1.id, target_id=o2.id, type="dispatch", signals={"priority": "high"})
|
|
g = GraphOfContracts(objects={o1.id: o1, o2.id: o2, o3.id: o3}, morphisms={m1.id: m1})
|
|
return g
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
sub = parser.add_subparsers(dest="cmd")
|
|
sub.add_parser("plan", help="Run a toy planning pass on a sample GoC")
|
|
args = parser.parse_args()
|
|
|
|
if args.cmd == "plan":
|
|
gof = build_sample_goC()
|
|
planner = ADMMPlanner()
|
|
plan = planner.optimize(gof)
|
|
print(json.dumps({"plan": plan.actions}, default=str, indent=2))
|
|
return 0
|
|
print("No command provided. Use 'plan'.")
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|