from pathlib import Path
import polars as pl
from florecon import Workspace
WASM = Path(__file__).resolve().parent / "solver/target/wasm32-unknown-unknown/release/__LIB__.wasm"
def main() -> None:
df = pl.DataFrame(
{
"id": [1, 2, 3, 4],
"group": ["A", "A", "B", "B"],
"amount": [100.0, -100.0, 50.0, -50.0],
}
)
ws = Workspace(str(WASM)) ws.upsert(df) report = ws.solve()
print(f"{len(report['groups'])} groups, {len(report['allocations'])} allocations")
for g in report["groups"]:
print(g)
if __name__ == "__main__":
main()