minto.run
Module for managing experiment runs.
This module provides the Run class for managing individual experiment runs.
The Run class allows users to log parameters, solutions, samplesets, and other
run-specific data to a database.
Classes¶
Run¶
Run()Class to manage individual experiment runs.
This class provides a structured way to manage run-specific data within an optimization experiment, including logging of parameters, solutions, samplesets, and other run-specific data.
Attributes:
| Name | Type | Description |
|---|---|---|
_datastore | minto.v1.datastore.DataStore | The underlying data storage for this run. |
_experiment | typing.Optional | Reference to the parent experiment. |
_run_id | int | Unique identifier for this run. |
_start_time | datetime.datetime | Start time of the run. |
_closed | bool | Flag indicating if the run has been closed. |
Methods¶
log_parameter¶
log_parameter(name: str, value: float | int | str | np.ndarray)Log a parameter to this run.
Parameters:
| Name | Type | Description |
|---|---|---|
name | str | Name of the parameter. |
value | `float | int |
Raises:
| Exception | Description |
|---|---|
RuntimeError | If the run has been closed. |
log_params¶
log_params(params: dict)Log multiple parameters to this run.
Parameters:
| Name | Type | Description |
|---|---|---|
params | dict | Dictionary of parameter names and values. None values are automatically skipped. |
Raises:
| Exception | Description |
|---|---|
RuntimeError | If the run has been closed. |
log_object¶
log_object(name: str, value: dict)Log a custom object to this run.
Parameters:
| Name | Type | Description |
|---|---|---|
name | str | Name of the object |
value | dict | Dictionary containing the object data |
Raises:
| Exception | Description |
|---|---|
RuntimeError | If the run has been closed. |
log_problem¶
log_problem(problem_name: str | jm.Problem, problem: typing.Optional = None)Log an optimization problem to this run.
Parameters:
| Name | Type | Description |
|---|---|---|
problem_name | `str | jm.Problem` |
problem | typing.Optional | Problem object (if problem_name is a string). |
Raises:
| Exception | Description |
|---|---|
RuntimeError | If the run has been closed. |
log_instance¶
log_instance(instance_name: str | ommx_v1.Instance, instance: typing.Optional = None)Log an optimization problem instance to this run.
Parameters:
| Name | Type | Description |
|---|---|---|
instance_name | `str | ommx_v1.Instance` |
instance | typing.Optional | Instance object (if instance_name is a string). |
Raises:
| Exception | Description |
|---|---|
RuntimeError | If the run has been closed. |
log_solution¶
log_solution(solution_name: str | ommx_v1.Solution, solution: typing.Optional = None)Log an optimization solution to this run.
Parameters:
| Name | Type | Description |
|---|---|---|
solution_name | `str | ommx_v1.Solution` |
solution | typing.Optional | Solution object (if solution_name is a string). |
Raises:
| Exception | Description |
|---|---|
RuntimeError | If the run has been closed. |
log_sampleset¶
log_sampleset(name: str | ommx_v1.SampleSet, value: typing.Optional = None)Log a SampleSet to this run.
Parameters:
| Name | Type | Description |
|---|---|---|
name | `str | ommx_v1.SampleSet` |
value | typing.Optional | SampleSet object (if name is a string). |
Raises:
| Exception | Description |
|---|---|
RuntimeError | If the run has been closed. |
TypeError | If value is not an OMMX SampleSet. |
log_solver¶
log_solver(solver_name: str | typ.Callable[P, R], solver: typing.Optional = None, exclude_params: typing.Optional = None) -> typing.CallableLog solver name and parameters to this run.
When the wrapped solver function is called, the following actions are performed:
The solver name is logged as a parameter
Each keyword argument is logged as appropriate (parameter, problem, instance)
The result is logged as a sampleset or solution if applicable
Parameters:
| Name | Type | Description |
|---|---|---|
solver_name | `str | typ.Callable[P, R]` |
solver | typing.Optional | Solver function (if solver_name is a string). |
exclude_params | typing.Optional | List of parameter names to exclude from logging. |
Returns:
| Type | Description |
|---|---|
typing.Callable | Wrapped solver function. |
Raises:
| Exception | Description |
|---|---|
RuntimeError | If the run has been closed. |
TypeError | If solver_name or solver have incorrect types. |
close¶
close()Close this run and log elapsed time.
Once closed, the run cannot be used for further logging.