Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions docs/reference/problems.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ the corresponding implementation or family registration in the 1.0.1 release.
| `zdt1`, `zdt2`, `zdt3` | 30 | 2 | 0 | Variables in `[0, 1]`; fixed M | [ZDT][zdt] | 2D, each |
| `zdt4` | 10 | 2 | 0 | First variable `[0, 1]`, remainder `[-5, 5]`; fixed M | [ZDT][zdt] | 2D |
| `zdt6` | 10 | 2 | 0 | Variables in `[0, 1]`; fixed M | [ZDT][zdt] | 2D |
| `dtlz1` | 7 | 3 | 0 | `n = M + 4` (`k = 5`) when n is omitted | [DTLZ][dtlz] | 2D and 3D |
| `dtlz2`–`dtlz6` | 12 | 3 | 0 | `n = M + 9` (`k = 10`); DTLZ4 uses `alpha = 100` | [DTLZ][dtlz] | 2D and 3D, each |
| `dtlz7` | 22 | 3 | 0 | `n = M + 19` (`k = 20`) | [DTLZ][dtlz] | 2D and 3D |
| `dtlz1` | 7 | 3 | 0 | `n = M + 4` (`k = 5`) when n is omitted | [DTLZ][dtlz] | 2D and 3D; **Development after 1.4.0:** also 4D, 6D and 8D |
| `dtlz2`–`dtlz6` | 12 | 3 | 0 | `n = M + 9` (`k = 10`); DTLZ4 uses `alpha = 100` | [DTLZ][dtlz] | 2D and 3D, each; **Development after 1.4.0:** DTLZ2–DTLZ4 also 4D, 6D and 8D |
| `dtlz7` | 22 | 3 | 0 | `n = M + 19` (`k = 20`) | [DTLZ][dtlz] | 2D and 3D; **Development after 1.4.0:** also 4D, 6D and 8D |
| `wfg1`–`wfg9` | 24 | 3 | 0 | `k = 4`, `l = 20`; bounds `[0, 2i]` for variable i | [WFG][wfg] | **2D only**, each |
| `lz09_f1`, `lz09_f7`, `lz09_f8` | 10 | 2 | 0 | Fixed M; family-specific linkage | [Li–Zhang LZ09][lz] | None packaged |
| `lz09_f2`–`lz09_f5`, `lz09_f9` | 30 | 2 | 0 | Fixed M; family-specific linkage | [Li–Zhang LZ09][lz] | None packaged |
Expand Down Expand Up @@ -701,7 +701,11 @@ compatibility or a certified optimum.

- ZDT fronts have two columns; ZDT5's sample is tied to its default 80 bits.
- DTLZ fronts have three columns, and `dtlz<k>.2d.csv` two. Other values of M
need a supplied reference.
need a supplied reference. **Development after 1.4.0:** DTLZ1–DTLZ4 and
DTLZ7 also have samples with 4, 6 and 8 objectives, `dtlz1.<M>d.csv`,
`dtlz2.<M>d.csv` and `dtlz7.<M>d.csv`. DTLZ3 and DTLZ4 share DTLZ2's front,
so they resolve to `dtlz2.<M>d.csv`. DTLZ5 and DTLZ6 with more than three
objectives, and the other values of M, still need a supplied reference.
- WFG and LSMOP samples have **two columns**, even though their registered
default is three objectives. Supply a matching reference for default runs; do
not use those two-column files for three-objective indicators.
Expand Down Expand Up @@ -744,6 +748,7 @@ regenerates the files marked as regenerated.
| `dtlz5`, `dtlz6` | Regenerated: 1000 points of the front curve |
| `dtlz7` | Regenerated: 5050 points of the disconnected front |
| `dtlz1.2d`–`dtlz7.2d` | **VAMOS 1.3.0:** regenerated, 1000 points spaced evenly along the front: `f1 + f2 = 0.5` (DTLZ1), the quarter circle (DTLZ2–DTLZ6; at M = 2, DTLZ5 and DTLZ6 do not degenerate) and the non-dominated pieces of `f2 = 4 - f1 (1 + sin(3 pi f1))` (DTLZ7) |
| `dtlz1`, `dtlz2` and `dtlz7`, `.4d`, `.6d` and `.8d` | **Development after 1.4.0:** regenerated. DTLZ1 and DTLZ2 (which DTLZ3 and DTLZ4 share): the largest Das-Dennis simplex lattice with at most 10 000 points (H = 37, 13 and 8: 9880, 8568 and 6435 points), scaled to `sum(f) = 0.5` or projected onto the unit sphere. DTLZ7: its last objective is `2 (M - sum psi(f_i))` over the others, with `psi(t) = t (1 + sin(3 pi t))`, so the front is the product of the values of `f_i` that no smaller value beats in `psi`; values of a grid of 200 001 points, combined and thinned to 5050 points by farthest-point selection |
| `wfg1`, `wfg2` | Regenerated from the WFG shape functions, 10 000 points |
| `wfg3`–`wfg9` | Closed-form front, 10 000 points, unchanged |
| `lsmop1`–`lsmop8` | Closed-form front, 1000 points, unchanged |
Expand Down Expand Up @@ -788,6 +793,16 @@ with jMetal's and Evolver's:
`jmetal` or `file`) next to `reference_front_path` in its resolved
termination.

**Development after 1.4.0:** the lattices of DTLZ1–DTLZ4 with 4, 6 and 8
objectives are those of PlatEMO's reference fronts (`UniformPoint(10000, M)`,
which also raises zeros to 1e-6). jMetal's DTLZ2, DTLZ3 and DTLZ4 files with
those numbers of objectives (`DTLZ2.4D.csv` and so on) hold the same points, in
the same order, so the default source gives the indicator values of jMetal and
Evolver for these problems. The `jmetal` source keeps two and three objectives:
jMetal's DTLZ1 and DTLZ7 files with 4, 6 and 8 objectives are sparser (183 to
370 points; DTLZ1's are rounded to five decimals and stay away from the front's
corners), and VAMOS does not package them.

Notes on the table:

- **Dense sampling:** for RE91, RWA3, RWA9 and RWA10, the generator
Expand Down
49 changes: 47 additions & 2 deletions experiments/scripts/generate_reference_fronts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
provenance of every packaged file, including those this script leaves alone.

- **Analytic samples** of the Pareto front from its closed form: ZDT1-4 and ZDT6, DTLZ1-7 (M = 3, and M = 2 as
``dtlz1.2d`` ... ``dtlz7.2d``), WFG1 and
``dtlz1.2d`` ... ``dtlz7.2d``; Development after 1.4.0: DTLZ1, DTLZ2 and DTLZ7 at M = 4, 6 and 8 as ``dtlz1.4d``
... ``dtlz7.8d``, DTLZ2's also serving DTLZ3 and DTLZ4), WFG1 and
WFG2 (M = 2, from the WFG shape functions, so the bias transformations cannot shift them), LSMOP9 (M = 2),
CEC2009 UF6 and UF9, and the ten C-DTLZ and DC-DTLZ problems at M = 2 and 3 (``c1dtlz1.2d`` ...
``dc3dtlz3.3d``), Srinivas, ConstrEx and Tanaka from their Pareto-set pieces and constraint boundaries, ZXH-CF1-16 at
Expand Down Expand Up @@ -41,6 +42,7 @@

import argparse
import itertools
import math
from collections.abc import Callable
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -201,6 +203,43 @@ def _dtlz_two_objective(name: str) -> np.ndarray:
return np.column_stack([np.cos(theta), np.sin(theta)])


# Development after 1.4.0: DTLZ1, DTLZ2 (whose sample DTLZ3 and DTLZ4 share) and DTLZ7 with more objectives.
MANY_OBJECTIVES = (4, 6, 8)
# Per objective count, the values per position objective of DTLZ7's candidate grid: about 10^5 candidates in all.
_DTLZ7_GRID = {4: 48, 6: 10, 8: 6}


def lattice_divisions(m: int, limit: int = 10_000) -> int:
"""The divisions H of the largest Das-Dennis lattice with ``m`` objectives and at most ``limit`` points."""
h = 1
while math.comb(h + m, m - 1) <= limit:
h += 1
return h


def _dtlz_many_objective(name: str, m: int) -> np.ndarray:
"""DTLZ1, DTLZ2 and DTLZ7 with M = 4, 6 or 8.

DTLZ1 and DTLZ2: the largest Das-Dennis lattice with at most 10 000 points (H = 37, 13 and 8: 9880, 8568 and
6435 points), scaled to ``sum(f) = 0.5`` or projected onto the unit sphere. DTLZ7: on the front, the last
objective is ``2 (M - sum_i psi(f_i))`` over the others, with ``psi(t) = t (1 + sin(3 pi t))``. It separates, so a
point is Pareto-optimal when each other objective is a value that no smaller one beats in ``psi``: the front is
the product of those values, which a grid of 200 001 points of [0, 1] gives. Evenly spaced values of them,
combined, are thinned to 5050 points by farthest-point selection.
"""
if name == "dtlz7":
fine = np.linspace(0.0, 1.0, 200_001)
psi = fine * (1.0 + np.sin(3.0 * np.pi * fine))
efficient = fine[psi > np.maximum.accumulate(np.concatenate([[-np.inf], psi[:-1]]))]
values = efficient[np.round(np.linspace(0.0, efficient.size - 1, _DTLZ7_GRID[m])).astype(int)]
head = np.array(list(itertools.product(values, repeat=m - 1)))
last = 2.0 * (m - np.sum(head / 2.0 * (1.0 + np.sin(3.0 * np.pi * head)), axis=1))
front = np.column_stack([head, last])
return front[farthest_points(front, 5050)]
w = simplex_lattice(m, lattice_divisions(m))
return 0.5 * w if name == "dtlz1" else w / np.linalg.norm(w, axis=1, keepdims=True)


def _wfg(name: str) -> np.ndarray:
# M = 2, S = (2, 4); on the front the distance parameter is 0 and f = S * h(x).
x = np.linspace(0.0, 1.0, 200_001)
Expand Down Expand Up @@ -529,6 +568,7 @@ def constraint(f1: np.ndarray, f2: np.ndarray) -> np.ndarray:
**{name: (lambda name=name: _zdt(name)) for name in ("zdt1", "zdt2", "zdt3", "zdt4", "zdt6")},
**{f"dtlz{i}": (lambda i=i: _dtlz(f"dtlz{i}")) for i in range(1, 8)},
**{f"dtlz{i}.2d": (lambda i=i: _dtlz_two_objective(f"dtlz{i}")) for i in range(1, 8)},
**{f"dtlz{i}.{m}d": (lambda i=i, m=m: _dtlz_many_objective(f"dtlz{i}", m)) for i in (1, 2, 7) for m in MANY_OBJECTIVES},
"wfg1": lambda: _wfg("wfg1"),
"wfg2": lambda: _wfg("wfg2"),
"lsmop9": _lsmop9,
Expand Down Expand Up @@ -708,7 +748,12 @@ def asf(F: np.ndarray, R: np.ndarray) -> np.ndarray:

def write_front(name: str, front: np.ndarray, out_dir: Path) -> Path:
path = out_dir / f"{FILE_NAMES.get(name, name)}.csv"
np.savetxt(path, front, delimiter=",")
if front.shape[1] > 3:
# Development after 1.4.0: with more objectives, the shortest repr of each value, which reads back exactly,
# keeps the files at about half the size.
path.write_text("".join(",".join(map(repr, row)) + "\n" for row in front.tolist()), encoding="ascii", newline="\n")
else:
np.savetxt(path, front, delimiter=",")
return path


Expand Down
15 changes: 11 additions & 4 deletions src/vamos/foundation/problem/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ def _logger() -> logging.Logger:

# The packaged reference fronts that resolve_reference_front_path can search.
REFERENCE_FRONT_SOURCES = ("vamos", "jmetal")
# jMetal's DTLZ3 and DTLZ4 fronts are its DTLZ2 file, byte for byte (the three share the unit sphere): it is packaged once.
_JMETAL_SHARED_FRONTS = {"dtlz3": "dtlz2", "dtlz4": "dtlz2"}
# DTLZ3 and DTLZ4 share DTLZ2's front, the unit sphere. Without a file of their own they take DTLZ2's: jMetal's DTLZ3
# and DTLZ4 files are its DTLZ2 file, byte for byte, so it is packaged once. Development after 1.4.0: so are VAMOS's
# samples with more than three objectives.
_SHARED_FRONTS = {"dtlz3": "dtlz2", "dtlz4": "dtlz2"}

# Preset names map to problem keys defined in the registry.
PROBLEM_SET_PRESETS: dict[str, Sequence[str]] = {
Expand Down Expand Up @@ -151,6 +153,9 @@ def resolve_reference_front_path(
``jmetal-<key>.<n_obj>d.csv``; DTLZ3 and DTLZ4 resolve to ``jmetal-dtlz2.<n_obj>d.csv``, the
file jMetal ships under their three names. A problem without a front of that source gives
``None``: the other source is never used in its place.

Development after 1.4.0: VAMOS's samples of DTLZ1-4 and DTLZ7 also cover 4, 6 and 8 objectives;
with those, DTLZ3 and DTLZ4 resolve to ``dtlz2.<n_obj>d.csv``, the one sample of their shared front.
"""
if source not in REFERENCE_FRONT_SOURCES:
raise ValueError(f"Reference front source must be one of {', '.join(map(repr, REFERENCE_FRONT_SOURCES))}; got {source!r}.")
Expand All @@ -161,9 +166,11 @@ def resolve_reference_front_path(
if n_obj is None:
n_obj = _default_n_obj(key)
candidates = [key] if n_obj is None or "." in key else [f"{key}.{int(n_obj)}d", key]
# A problem that shares another's front falls back to that problem's files.
parts = [candidate.partition(".") for candidate in candidates]
candidates += [f"{_SHARED_FRONTS[base]}{dot}{rest}" for base, dot, rest in parts if base in _SHARED_FRONTS]
if source == "jmetal":
shared = [candidate.partition(".") for candidate in candidates]
candidates = [f"jmetal-{_JMETAL_SHARED_FRONTS.get(base, base)}{dot}{rest}" for base, dot, rest in shared]
candidates = [f"jmetal-{candidate}" for candidate in candidates]

for candidate in candidates:
try:
Expand Down
Loading
Loading