optiprofiler.ProblemLibraryPlugin

optiprofiler.ProblemLibraryPlugin#

class optiprofiler.ProblemLibraryPlugin(name: str, api_version: int, select: Callable[[Mapping[str, Any], Mapping[str, Any]], Sequence[str]], load: Callable[[str, Mapping[str, Any]], Any], collect_info: Callable[[...], Any] | None = None, check_available: Callable[[], None] | None = None, get_default_options: Callable[[], Mapping[str, Any]] | None = None, validate_options: Callable[[Mapping[str, Any]], Mapping[str, Any]] | None = None)[source]#

Versioned interface implemented by a problem-library adapter.

Parameters:
namestr

Public name used in the plibs benchmark option.

api_versionint

Major version of the OptiProfiler problem-library protocol.

selectcallable

select(problem_options, library_options) returns the names of problems matching the common and library-specific options.

loadcallable

load(problem_name, library_options) returns an OptiProfiler Problem instance.

collect_infocallable, optional

Library-specific metadata collection helper.

check_availablecallable, optional

Zero-argument check that returns normally when the library can be used and raises an informative exception otherwise. benchmark calls it once before selecting problems.

get_default_optionscallable, optional

Zero-argument callable returning the library-owned raw default option mapping. It may read package data or environment-level defaults. The core overlays higher-priority process and per-run values before calling validate_options once, so lower-priority invalid values may be replaced explicitly by a benchmark run.

validate_optionscallable, optional

Callable accepting the merged library option mapping and returning a validated, normalized mapping. A library with nonempty options must provide this callable.

Notes

The entry-point factory may be called independently in the main process and in worker processes. Consequently, select and load must not rely on mutable state shared through one plugin instance. OptiProfiler resolves library options in the main process and passes isolated copies of the same pickleable effective mapping to the selector and each loader. Callbacks should treat the mapping as read-only.

Attributes:
check_available
collect_info
get_default_options
validate_options