Create a new solver
A solver is a module in src/coadapt/solvers/ exposing two functions. Add it to
the registry and it appears in scripts/run.py and scripts/compare.py
automatically.
The interface
def default_hparams(env_name):
"Return a dict of sensible per-env hyperparameters."
return dict(lr=3e-3, gamma=0.98, ...)
def solve(env, net, key, *, n_seeds=16, horizon=None, n_iters=200, **hp):
"Train and return {'return_curve': [...], 'final_return': float, ...}."
...
What you get to reuse
coadapt.agent.init_agents / act— N independent MLP policies as a stacked pytree (vmap over the agent axis = N independent learners).coadapt.rollout.rollout_batch— collectn_seedsepisodes; returns obs / actions / logp / reward arrays.coadapt.solvers.common— GAE, discounted returns, per-agent Adam, batched forward helpers.env.spec.action_space—log_prob,entropy,samplework for Discrete / MultiDiscrete / Box, so your loss is action-agnostic.
Register it
# src/coadapt/solvers/__init__.py
from . import mymethod
SOLVERS = { ..., "mymethod": mymethod }
The constraint
Solvers may add machinery inside solvers/ (even recurrence — see
recurrent.py, which owns its own GRU without touching agent.py). The
environments, network, and agent contract stay fixed, so every solver is compared on the same
problem.