Repository navigation
feat: one source of reference vectors for MOEA/D, NSGA-III and RVEA, two-layer lattices and moead_populations (A13, A7, A12) - #365
Conversation
…, with two-layer lattices MOEA/D's weight_vectors, NSGA-III's reference_directions and RVEA's new reference_vectors (the last field, default None) take the same input, as jMetal and Evolver configure the three from the same weight files: a file with whitespace or commas, or a directory with jMetal's W<m>D_<n>.dat names (new for NSGA-III and RVEA); divisions, the complete Das-Dennis lattice (for RVEA the lattice of n_partitions); and, new, inner_divisions with divisions, Deb and Jain's two-layer lattice, the inside layer shrunk by half towards the centre as in pymoo and PlatEMO (156 vectors with eight objectives, 3 and 2 divisions). All go through load_or_generate_weight_vectors, and vector_source checks the options when a configuration is built. The vectors are the population: RVEA runs 100 individuals with three objectives from W3D_100.dat. A path that does not exist raises ConfigurationError for all three (MOEA/D created it as a directory); a directory without the file raises for NSGA-III and RVEA, while MOEA/D keeps saving the lattice in an existing directory. to_dict() leaves out reference_vectors while it is None and inner_divisions while unset, so configurations without them keep their 1.4.0 resolved specs and task ids. The resolved spec records MOEA/D's two-layer lattice and the file of NSGA-III and RVEA (lattices are already in their configuration). RVEA's command-line block takes reference_vectors; study planning rejects its path, as NSGA-III's, checks two-layer counts, and moves these checks to study/reference_planning.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… vectors vamos.algorithms.moead_populations(n_obj, *, max_pop_size=1000) returns the populations MOEA/D runs without weight options, as MOEADConfig.default and optimize build them: every size from 2 with one or two objectives, and with more the complete Das-Dennis lattices and the packaged jMetal files (100 with three or four objectives, 156 with eight). Other sizes need a file or a two-layer lattice, which the docstring and the MOEA/D reference explain. The tests run MOEA/D for 4 to 20 objectives with the populations it lists, and with a 10-objective two-layer lattice that no single lattice has. The public API snapshot is regenerated with tools/update_public_api_snapshot.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d96b6cc2e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
VAMOS documentation previewhttps://pr-365-vamos-docs-preview.vamos-optimization.workers.dev Built from |
…ions Settings such as two objectives with divisions=4 and inner_divisions=2 gave eight vectors but five directions: the three inside directions lie on the boundary lattice. RVEA accepted them as an eight-vector population, although a repeated niche never gets its own survivor and its zero angle to the nearest vector is clamped to 1e-64 in the penalty. two_layer_shared counts the shared directions exactly on the grid of both layers; two_layer_lattice raises ValueError, and MOEA/D, NSGA-III and RVEA raise ConfigurationError, for any overlap; study planning rejects it as INVALID_REFERENCE_DIRECTIONS. With inner_divisions < n_obj and divisions < 2 n_obj the layers never overlap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ther vectors A path in MOEA/D's weight_vectors, NSGA-III's reference_directions or RVEA's reference_vectors was replayed with whatever the file held when replay ran, while the resolved spec recorded only its name: a file replaced by other valid vectors of the same shape still verified as exact and reproduce() ran another experiment. MOEA/D's and NSGA-III's files had this gap on main too. The record of NSGA-III's and RVEA's files was also rebuilt with os.path.isfile, so a run whose file was moved, or verified on another machine, no longer matched it. When a run starts (optimize, the command-line builders, build_algorithm with a configuration, and study planning for MOEA/D), bind_config_vector_files resolves the path to the file the run reads (a directory becomes its W<m>D_<n>.dat) and records sha256, the digest of its vectors' shape and float64 values, in the resolved configuration. The run checks the digest before any evaluation, so replay refuses a changed file. The file records are rebuilt from the stored configuration alone; a MOEA/D record with sha256 is das_dennis when the digest is that of the lattice. A MOEA/D directory without the file, whose run generates the lattice, stays unbound, and runs stored without a digest keep their 1.4.0 description. The helpers move to components/vector_files.py, as weight_vectors.py reached its size budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NSGAIIIConfig.__post_init__ keeps both checks: the reference-direction source of this branch and the selection of #364. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Builds on #361 (
fix/weight-vector-files, A14 and A8): this branch starts from its two commits, which this PR also shows until #361 is merged. Review the last two commits: the vector sources, thenmoead_populations.Problem
Items A13, A7 and A12 of the VAMOS-Studio change requests (2026-11-18). jMetal and Evolver configure MOEA/D, NSGA-III and RVEA from the same weight-vector files (jMetal's
MOEADBuilderandNSGAIIIBuildertake a directory or a list of vectors,RVEABuildera list), so the three start from the same vectors. In VAMOS 1.4.0 each algorithm differed:weight_vectors={"path": directory or file, "divisions": H}.reference_directions={"path": file, "divisions": H}, a single file (comma-separated only until fix: every packaged weight file loads (W4D_100.dat, W4D_165.dat) and NSGA-III reads them (A14, A8) #361).n_partitions, so its population had to be a lattice: 100 individuals with three objectives failed (RVEA requires pop_size == #ref_dirs), and it could not readW3D_100.dat(A7).Change
One kind of option for the three algorithms, through the shared
load_or_generate_weight_vectors, with the existing names kept:weight_vectors(existing)reference_directions(existing)reference_vectors(new, the last field, defaultNone)Each takes
None, a path, or a mapping with:path: a file with one vector per line, components separated by whitespace or commas (fix: every packaged weight file loads (W4D_100.dat, W4D_165.dat) and NSGA-III reads them (A14, A8) #361's reader), or a directory with jMetal'sW{n_obj}D_{pop_size}.datnames. NSGA-III gains directories; RVEA gains files and directories.divisions: the complete Das-Dennis lattice. For RVEA,reference_vectors(divisions=12)runs exactly the lattice ofn_partitions(12)(same generator, same results).inner_divisions(new, withdivisions): Deb and Jain's two-layer lattice, the boundary lattice ofdivisionsplus the lattice ofinner_divisionsshrunk by half towards the centre (w / 2 + 1 / (2 m), as pymoo's multi-layer directions with scaling 0.5, PlatEMO'sUniformPointand VAMOS's own C-TAEA weights).reference_directions.two_layer_lattice(8, 3, 2)has 120 + 36 = 156 vectors, the size of jMetal'sW8D_156.dat. (jMetal's file stacks the two lattices without shrinking the inside one, so it repeats the eight axes; the shrunk layer is the published construction.)Why these names:
pathanddivisionsare the keys MOEA/D and NSGA-III already had, so existing configurations keep their meaning and their serialized form;inner_divisionsnames Deb and Jain's "inside layer" next todivisions; RVEA's field isreference_vectors, the algorithm's own term (and the name A7 proposes), with the same keys.n_partitionsstays RVEA's stable required field and its default lattice; withreference_vectorsit is not used, and the builder no longer requires it (it recordsdivisions, or 12 for a file).Rules (
vector_source, applied when a configuration is built):ConfigurationErrorbefore any evaluation, for all three; a directory without the file raises for NSGA-III and RVEA. MOEA/D keeps its documented 1.3 behaviour for an existing directory that lacks the file (it saves the exact lattice there with aRuntimeWarning), but no longer creates a missing directory.ValueError, as before for MOEA/D).inner_divisionsneedsdivisionsand excludespath; an unknown key, a non-positive count or a non-string path raisesConfigurationError; a plain string is apath.A12 (1):
vamos.algorithms.moead_populations(n_obj, *, max_pop_size=1000)lists the populations MOEA/D runs without weight options (every size from 2 with one or two objectives; the complete lattices and the packaged jMetal files with more), asMOEADConfig.default(pop_size=...)andoptimizebuild them. It is exported fromvamos.algorithmsand documented in the MOEA/D configuration reference; the public API snapshot is regenerated withtools/update_public_api_snapshot.py.Run metadata, serialization, CLI and replay:
algorithm.resolution.weight_vectorsgains{"source": "two_layer", "divisions": 3, "inner_divisions": 2, "vectors": 156}.algorithm.resolution.reference_directions({"source": "file", "file": "W3D_100.dat"}) andalgorithm.resolution.reference_vectors(also"vectors", the population). Lattices are not recorded: the configuration already states them, and recording them would change the resolved spec, and the task id, of every NSGA-III and RVEA run, so runs and studies stored by 1.4.0 would no longer verify, replay or resume exactly (study execution reconstructs each task from its stored spec). The record is built from the file's name, never its contents, since verification rebuilds it from an untrusted stored path.to_dict()leaves outreference_vectorswhile it isNoneandinner_divisionswhile it is unset, so configurations without the new options serialize, and resolve, exactly as in 1.4.0;from_dictround-trips the new ones. The 1.0 compatibility snapshots pass unchanged.rvea:block takesreference_vectors(a mapping or a path string); the command-line RVEA builder no longer derivesn_partitionsfrom the population whenreference_vectorsis given.weight_vectorsandreference_directionsblocks takeinner_divisions.reference_vectors.pathis rejected asUNSAFE_REFERENCE_DIRECTIONS(as NSGA-III's path already is), andpop_sizemust equal the vectors ofdivisions/inner_divisions; NSGA-III's check counts a two-layer lattice. Planning no longer reports a field thatto_dict()leaves out at its default as unknown.save_result,verify_runandreproduce.Docs, each with Development after 1.4.0:: a new "Reference and weight vectors" section in the algorithms reference, the configuration references of MOEA/D (two layers,
moead_populations), NSGA-III and RVEA (with an example), the RVEA tutorial, the CLI guide (anrvea:block with a weight file) and the run-artifact contract.Sources
C:/tmp/jmetal-pr, local/integration 9b6734c12):resources/weightVectorFiles/moead/W3D_100.datandW8D_156.dat(VAMOS ships both),WeightVectorNeighborhood(whitespace reader),RVEAEnvironmentalSelection(takes any list of vectors).MultiLayerReferenceDirectionFactorywithscaling=0.5; PlatEMO'sUniformPoint(also in VAMOS'sctaea/weights.py).Tests
tests/engine/test_reference_vector_sources.py(new):W3D_100.dat(population 100), and with eight objectives andW8D_156.dat(156), given the file and given the packaged directory, start from the same vectors (compared afterinitialize); so do the three with the two-layer lattice of 8 objectives,divisions=3,inner_divisions=2.W8D_156.dat, with the boundary layer first and the inside layer shrunk.ConfigurationErrorfor all three and creates nothing; a directory without the file raises for NSGA-III and RVEA; MOEA/D still saves the lattice in an existing directory; a file with another number of vectors raises for MOEA/D and RVEA.W3D_100.datwith the exact budget;reference_vectors(divisions=12)gives the same results asn_partitions(12).to_dict/from_dict; configurations without the new options serialize as in 1.4.0.reference_vectors; study planning of RVEA and NSGA-III two-layer lattices and of an RVEA path.moead_populationsfor 2, 3, 4, 8 and 20 objectives; for 4 to 20 objectives every listed population up to 300 loads its weights and buildsMOEADConfig.default, and the smallest runs; MOEA/D runs a 10-objective two-layer lattice (65 vectors) that no single lattice has.vamos --config spec.yamlwithrvea: {reference_vectors: .../W3D_100.dat}andpopulation_size: 100runs and records{"source": "file", "file": "W3D_100.dat", "vectors": 100}.Compatibility
Additive for configurations that do not use the new options: same fields, same
to_dict(), same resolved specs and task ids, same results (the 1.0 compatibility snapshots pass unchanged; RVEA's new field is last, with a default). Changes:weight_vectorspath that does not exist now raisesConfigurationErrorwhere VAMOS 1.4.0 created it as a directory and saved the lattice there (with aRuntimeWarning).weight_vectorsorreference_directionsnow raisesConfigurationError; VAMOS 1.4.0 ignored it.n_partitionswhenreference_vectorsis given.vamos.algorithmsexportsmoead_populations(new, not yet in the 1.0 baseline).Validation
All on Windows 11, Python 3.12, with
PYTHONPATHset to the worktree'ssrc(checked withvamos.__file__).pytest -q -n 4on the new and nearest tests (test_reference_vector_sources, MOEA/D weight and provenance tests, NSGA-III tests, RVEA tests, config round-trip and field tests,tests/compatibility,tests/architecture,tests/experiment/study_manifest, CLI/API parity, scientific defaults, tuning population, registry, smoke and warm-start tests)tests/architecture,tests/compatibility,tests/experiment/study_manifest, the run-artifact replay and ablation-study tests and the new tests: 904 passed; on the final commits: 688 passed, 1 skippedruff checkandruff format --checkon the changed Pythonpython tools/typecheck.py --scope strict/--scope fullpython -m compileallon the changed Python;git diff --checkpython tools/check_agent_docs.pypytest -m "not slow" -n 4 -p no:cacheprovider -rfEtest_constraint_handling_follows_the_fields_of_1_0[RVEAConfig](the list of fields added after 1.0 now namesreference_vectors, updated) andtests/test_monolith_guard.py(planning.pyover its 450-line budget, fixed by moving the reference-vector checks tostudy/reference_planning.py), both passing after the fix, and the knowntests/experiment/test_cli_ablation.py::test_cli_ablation_runs_and_writes_variants, which fails under xdist on Windows on untouchedmaintoo and passes alonepython tools/health.pymkdocs build --strictUpdate after review
Two commits answer the automated review:
divisions=4andinner_divisions=2gives 8 rows but only 5 distinct directions.two_layer_latticeraisesValueError; MOEA/D, NSGA-III and RVEA raiseConfigurationError.INVALID_REFERENCE_DIRECTIONS.two_layer_sharedcounts the repeated directions exactly. Withinner_divisions < n_objanddivisions < 2 n_objthere are none.pathis resolved to the file the run reads, andsha256, the digest of its vectors, is added to the resolved configuration.optimize, the command-line builders,build_algorithmwith a configuration, and study planning for MOEA/D.maintoo.filerecords are rebuilt from the stored configuration alone, so a run verifies when its file has moved, or on another machine.components/vector_files.py, becauseweight_vectors.pyreached its size budget.Validation of the updated branch:
pytest -m "not slow" -n 4: 10971 passed, 253 skipped, 9 xfailed, 1 failed (the knowntest_cli_ablation_runs_and_writes_variants).tools/health.py: passed.mkdocs build --strict: no warnings.git diff --checkandcheck_agent_docs: passed.Changelog entry
Added
weight_vectors, NSGA-III'sreference_directionsand RVEA's newreference_vectorsaccept a file (whitespace- or comma-separated) or a directory with jMetal'sW<m>D_<n>.datnames, the lattice ofdivisions, or, with the newinner_divisions, Deb and Jain's two-layer lattice (156 vectors with eight objectives, 3 and 2 divisions). The vectors are the population, so RVEA can run 100 individuals with three objectives fromW3D_100.dat, and the three algorithms can start from the same vectors. A path that does not exist raisesConfigurationError. The resolved spec records a file for NSGA-III and RVEA and the two-layer lattice for MOEA/D.vamos.algorithms.moead_populations(n_obj)lists the populations MOEA/D runs without weight options.Changed
ConfigurationError. A MOEA/Dweight_vectorspath that does not exist raisesConfigurationErrorinstead of being created as a directory for the generated lattice, and an unknown key inweight_vectorsorreference_directionsraises instead of being ignored.Fixed
weight_vectors, NSGA-IIIreference_directionsor RVEAreference_vectorsnames a file records the file it read and thesha256of its vectors in its resolved configuration. Replay refuses the file if its vectors have changed, where VAMOS 1.4.0 replayed whatever the file then held. The run's record of the file is rebuilt from the stored configuration, so the run verifies without the file.🤖 Generated with Claude Code