discrete_optimization.generic_tools.study package
Submodules
discrete_optimization.generic_tools.study.database module
- class discrete_optimization.generic_tools.study.database.Database[source]
Bases:
ABC
Base class for database storing experiments.
By default, we assume a database is associated with a given study. But it could be implemented so that it can store several studies at once.
d-o experiments: - instance => string representing problem used - config:
name: can be empty, but useful to have a simple name for the config
solver: e.g. class name
params: hyperparameters used (nested dict whose leaves should be hashable, and preferably jsonable)
status: status of tge solver at then of the solve process
metrics: timeseries of objective, bound, …
- abstract load() list[Experiment] [source]
Load all experiments of the study.
- load_results() list[DataFrame] [source]
Load all experiments as time-indexes dataframes with metadata in attrs attribute.
- abstract store(xp: Experiment) None [source]
Store the experiment in the database.
Could store a complete experiment. Depending on implementations, could also support storing a partial experiment, and then overwriting with a complete experiment by re-calling store on an experiment with same id and more data.
- class discrete_optimization.generic_tools.study.database.Hdf5Database(filepath: str)[source]
Bases:
Database
Database based on hdf5 format.
- load() list[Experiment] [source]
Load all experiments of the study.
- store(xp: Experiment) None [source]
Store the experiment in the database.
Could store a complete experiment. Depending on implementations, could also support storing a partial experiment, and then overwriting with a complete experiment by re-calling store on an experiment with same id and more data.
- store_metadata(xp: Experiment) None [source]
- store_metrics(xp: Experiment) None [source]
discrete_optimization.generic_tools.study.experiment module
- class discrete_optimization.generic_tools.study.experiment.DoJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
Bases:
JSONEncoder
- default(o)[source]
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- class discrete_optimization.generic_tools.study.experiment.Experiment(xp_id: int, instance: str, status: str, config: SolverJsonableConfig, metrics: DataFrame, reason: str = '')[source]
Bases:
object
Experiment of a d-o study.
- config: SolverJsonableConfig
- classmethod from_solver_config(xp_id: int, instance: str, status: str | StatusSolver, solver_config: SolverConfig, metrics: DataFrame, config_name: str | None = None, reason: str = '')[source]
- instance: str
- metrics: DataFrame
- reason: str = ''
- status: str
- xp_id: int
- class discrete_optimization.generic_tools.study.experiment.SolverConfig(cls: 'type[SolverDO]', kwargs: 'dict[str, Any]')[source]
Bases:
object
- kwargs: dict[str, Any]
- class discrete_optimization.generic_tools.study.experiment.SolverJsonableConfig(solver: str, parameters: dict[str, ConfigDict | Hashable], name: str | None = None)[source]
Bases:
object
Config representing solver used with its tuning.
- classmethod from_solver_config(config: SolverConfig, name: str | None = None)[source]
- name: str | None = None
- parameters: dict[str, ConfigDict | Hashable]
- solver: str