26 lines
894 B
Python
26 lines
894 B
Python
"""Tiny habitat module adapter stub for NovaPlan MVP.
|
|
|
|
Represents a second domain agent (habitat life-support) that participates in
|
|
the same federated ADMM-like exchange as the rover.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from nova_plan.planner import LocalProblem, delta_sync, simple_admm_step
|
|
from nova_plan.contracts import PlanDelta
|
|
|
|
|
|
def make_local_problem() -> LocalProblem:
|
|
def objective(local_vars, shared_vars):
|
|
return sum(local_vars.values()) - 0.25 * sum(shared_vars.values())
|
|
|
|
return LocalProblem(id="habitat-1", objective=objective, variables={"a": 2.0, "b": 1.0})
|
|
|
|
|
|
class HabitatAdapter:
|
|
def __init__(self):
|
|
self.local = make_local_problem()
|
|
|
|
def step(self, shared_vars: dict[str, float]) -> PlanDelta:
|
|
simple_admm_step(self.local, shared_vars, rho=1.0)
|
|
return delta_sync(self.local, shared_vars, agent_id=self.local.id, rho=1.0)
|