Adding a problem¶
Use vamos.make_problem(...) for user-local objectives. Add a built-in only when the problem belongs in VAMOS's named benchmark or real-world catalog.
User-local problem¶
make_problem adapts a scalar callable by default. Set vectorized=True only when the callable accepts an (n_points, n_var) array and returns an (n_points, n_obj) array.
import vamos
def objectives(x):
return [x[0], (1.0 + x[1]) * (1.0 - x[0] ** 0.5)]
problem = vamos.make_problem(
objectives,
n_var=2,
n_obj=2,
bounds=[(0.0, 1.0), (0.0, 1.0)],
encoding="real",
)
result = vamos.optimize(problem, algorithm="nsgaii", max_evaluations=200, seed=42)
The CLI scaffold is discoverable with vamos create-problem --help.
Built-in problem workflow¶
- Read
ProblemProtocolinsrc/vamos/foundation/problem/types.pyand a neighboring implementation with the same encoding. - Implement
n_var,n_obj,n_constraints,xl,xu,encoding, andevaluate(X, out). Evaluation is batched, writesout["F"], and writesout["G"]for constraints withg <= 0feasible. - Add a
ProblemSpecto the appropriatesrc/vamos/foundation/problem/registry/families/*.pymodule. The family exposesget_specs();registry/specs.pyassembles those maps and is not the per-problem registration file. - Add packaged reference data under
src/vamos/resources/only when the problem has an authoritative dataset/front, and verify package-data coverage. - Export the class from
vamos.problemsonly when direct construction is part of the intentional public API. Named access throughvamos.optimize("key", ...)does not require a class export. - Document dimensions, objective direction, constraints, encoding, and source. Never silently choose dimensions that the
ProblemSpecmarks fixed.
Use the canonical encoding names real, integer, binary, permutation, and mixed. For mixed problems, provide the current mixed specification expected by MixedProblemProtocol consumers.
Required tests¶
- Direct evaluation: bounds, batch shape, finite values, and constraint shape/sign.
- Registry: key discovery, dimension resolution, factory instantiation, and duplicate-free assembly.
- Algorithm smoke: one supported algorithm/encoding at a tiny exact budget.
- Reference data/package test when adding resources.
Run:
python -m pytest -q tests/foundation/test_problem_registry.py tests/foundation/test_problem_zoo.py tests/foundation/test_problem_evaluation_edge_cases.py
python -m pytest -q tests/engine/test_algorithm_problem_matrix.py
Add the focused new-problem test to these commands during development, then run the repository validation tier required by /AGENTS.md.
path: src/vamos/foundation/problem/types.py
path: src/vamos/foundation/problem/registry/common.py
path: src/vamos/foundation/problem/registry/families
path: src/vamos/foundation/problem/registry/specs.py
path: src/vamos/resources
path: src/vamos/problems.py
path: tests/foundation/test_problem_registry.py
path: tests/foundation/test_problem_zoo.py
path: tests/foundation/test_problem_evaluation_edge_cases.py
path: tests/engine/test_algorithm_problem_matrix.py
symbol: vamos:make_problem
symbol: vamos:optimize
symbol: vamos.foundation.problem.types:ProblemProtocol
symbol: vamos.foundation.problem.registry.common:ProblemSpec
cli: vamos create-problem --help
command: python -m pytest -q tests/foundation/test_problem_registry.py tests/foundation/test_problem_zoo.py tests/foundation/test_problem_evaluation_edge_cases.py
command: python -m pytest -q tests/engine/test_algorithm_problem_matrix.py