37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""Minimal NovaPlan DSL scaffolding for MVP.
|
|
|
|
Provides tiny, test-friendly helpers to construct LocalProblem instances without
|
|
requiring callers to import planner directly. This is not a full DSL, just a light
|
|
wrapper to bootstrap tests and examples.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Dict, Any
|
|
from .planner import LocalProblem
|
|
|
|
|
|
class LocalProblemDSL:
|
|
def __init__(self, id: str):
|
|
self.id = id
|
|
self.objective = lambda vars, shared: 0.0
|
|
self.variables: Dict[str, float] = {}
|
|
self.constraints: Dict[str, Any] = {}
|
|
|
|
def with_variables(self, vars: Dict[str, float]) -> "LocalProblemDSL":
|
|
self.variables = dict(vars)
|
|
return self
|
|
|
|
def with_objective(self, func) -> "LocalProblemDSL":
|
|
self.objective = func
|
|
return self
|
|
|
|
def build(self) -> LocalProblem:
|
|
return LocalProblem(self.id, self.objective, self.variables, self.constraints)
|
|
|
|
|
|
def make_local_problem(id: str, variables: Dict[str, float] | None = None) -> LocalProblem:
|
|
"""Convenience factory to create a LocalProblem with given variables."""
|
|
lp = LocalProblem(id=id, objective=lambda v, s: 0.0, variables=dict(variables or {}))
|
|
return lp
|