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
2 changes: 1 addition & 1 deletion src/poli/benchmarks/guacamol.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(
batch_size: Union[int, None] = None,
parallelize: bool = False,
num_workers: Union[int, None] = None,
evaluation_budget: int = float("inf"),
evaluation_budget: Union[int, None] = None,
) -> None:
super().__init__(
seed=seed,
Expand Down
2 changes: 1 addition & 1 deletion src/poli/benchmarks/pmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
batch_size: Union[int, None] = None,
parallelize: bool = False,
num_workers: Union[int, None] = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
) -> None:
super().__init__(
string_representation=string_representation,
Expand Down
6 changes: 3 additions & 3 deletions src/poli/benchmarks/toy_continuous_functions_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
batch_size: Union[int, None] = None,
parallelize: bool = False,
num_workers: Union[int, None] = None,
evaluation_budget: Union[int, List[int]] = float("inf"),
evaluation_budget: Union[int, List[int]] = None,
) -> None:
super().__init__(
seed=seed,
Expand Down Expand Up @@ -121,7 +121,7 @@ def __init__(
batch_size: Union[int, None] = None,
parallelize: bool = False,
num_workers: Union[int, None] = None,
evaluation_budget: Union[int, List[int]] = float("inf"),
evaluation_budget: Union[int, List[int]] = None,
) -> None:
super().__init__(
seed,
Expand Down Expand Up @@ -174,7 +174,7 @@ def __init__(
batch_size: Union[int, None] = None,
parallelize: bool = False,
num_workers: Union[int, None] = None,
evaluation_budget: Union[int, List[int]] = float("inf"),
evaluation_budget: Union[int, List[int]] = None,
) -> None:
super().__init__(
seed,
Expand Down
2 changes: 1 addition & 1 deletion src/poli/core/abstract_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(
batch_size: Union[int, None] = None,
parallelize: bool = False,
num_workers: Union[int, None] = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
) -> None:
self.seed = seed
self.batch_size = batch_size
Expand Down
16 changes: 10 additions & 6 deletions src/poli/core/abstract_black_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
all objective functions should inherit.
"""

from __future__ import annotations

from multiprocessing import Pool, cpu_count
from warnings import warn

Expand Down Expand Up @@ -30,7 +32,7 @@ class AbstractBlackBox:
which uses half of the available CPU cores.
evaluation_budget : int, optional
The maximum number of evaluations allowed for the black box function.
Default is float("inf").
Default is None).

Attributes
----------
Expand Down Expand Up @@ -71,10 +73,10 @@ class AbstractBlackBox:

def __init__(
self,
batch_size: int = None,
batch_size: int | None = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
num_workers: int | None = None,
evaluation_budget: int | None = None,
force_isolation: bool = False,
):
"""
Expand All @@ -89,12 +91,14 @@ def __init__(
num_workers : int, optional
The number of workers for parallel execution, by default we use half the available CPUs.
evaluation_budget : int, optional
The maximum number of evaluations allowed for the black box function, by default float("inf").
The maximum number of evaluations allowed for the black box function, by default it is None, which means no limit.
"""
self.observer = None
self.observer_info = None
self.parallelize = parallelize
self.evaluation_budget = evaluation_budget
self.evaluation_budget = (
evaluation_budget if evaluation_budget is not None else float("inf")
)
self.num_evaluations = 0
self.force_isolation = force_isolation

Expand Down
2 changes: 1 addition & 1 deletion src/poli/core/abstract_problem_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
) -> Problem:
"""
Expand Down
4 changes: 2 additions & 2 deletions src/poli/core/chemistry/tdc_black_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class TDCBlackBox(AbstractBlackBox):

Methods
-------
__init__(self, oracle_name, string_representation="SMILES", force_isolation=False, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=float("inf"), **kwargs_for_oracle
__init__(self, oracle_name, string_representation="SMILES", force_isolation=False, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=None, **kwargs_for_oracle
Initializes a new instance of the abstract TDC class.

References
Expand All @@ -83,7 +83,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
**kwargs_for_oracle,
):
if parallelize:
Expand Down
4 changes: 2 additions & 2 deletions src/poli/core/lambda_black_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LambdaBlackBox(AbstractBlackBox):
which uses half of the available CPU cores.
evaluation_budget : int, optional
The maximum number of evaluations allowed for the black box function.
Default is float("inf").
Default is None).
force_isolation : bool, optional
Flag indicating whether to force isolation of the black
box function. In this black box, this flag is ignored.
Expand All @@ -56,7 +56,7 @@ def __init__(
batch_size=None,
parallelize=False,
num_workers=None,
evaluation_budget=float("inf"),
evaluation_budget=None,
force_isolation=False,
):
super().__init__(
Expand Down
2 changes: 1 addition & 1 deletion src/poli/core/proteins/foldx_black_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
wildtype_pdb_path: Union[Path, List[Path]] = None,
alphabet: List[str] = None,
experiment_id: str = None,
Expand Down
2 changes: 1 addition & 1 deletion src/poli/core/util/isolation/isolated_black_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
**kwargs_for_black_box,
):

Expand Down
4 changes: 2 additions & 2 deletions src/poli/objective_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __create_problem_from_repository(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
observer: AbstractObserver = None,
**kwargs_for_factory,
Expand Down Expand Up @@ -121,7 +121,7 @@ def create(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
quiet: bool = False,
**kwargs_for_factory,
) -> Problem:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class AlbuterolSimilarityBlackBox(TDCBlackBox):

Methods
-------
__init__(self, string_representation, force_isolation, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=float("inf"))
__init__(self, string_representation, force_isolation, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=None))
Initializes an instance of the black box.

References
Expand All @@ -93,7 +93,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
):
super().__init__(
oracle_name="Albuterol_Similarity",
Expand Down Expand Up @@ -152,7 +152,7 @@ def create(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
) -> Problem:
"""
Expand Down
4 changes: 2 additions & 2 deletions src/poli/objective_repository/aloha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
):
"""
Initialize the aloha black box object.
Expand Down Expand Up @@ -147,7 +147,7 @@ def create(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
) -> Problem:
"""
Expand Down
6 changes: 3 additions & 3 deletions src/poli/objective_repository/amlodipine_mpo/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AmlodipineMPOBlackBox(TDCBlackBox):

Methods
-------
__init__(self, string_representation, force_isolation, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=float("inf"))
__init__(self, string_representation, force_isolation, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=None))
Initializes the black box.

References
Expand All @@ -88,7 +88,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
):
super().__init__(
oracle_name="Amlodipine_MPO",
Expand Down Expand Up @@ -149,7 +149,7 @@ def create(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
) -> Problem:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CelecoxibRediscoveryBlackBox(TDCBlackBox):

Methods
-------
__init__(self, string_representation, force_isolation, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=float("inf"))
__init__(self, string_representation, force_isolation, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=None))
Initializes the black box.

References
Expand All @@ -90,7 +90,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
):
super().__init__(
oracle_name="Celecoxib_Rediscovery",
Expand Down Expand Up @@ -150,7 +150,7 @@ def create(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
) -> Problem:
"""
Expand Down
6 changes: 3 additions & 3 deletions src/poli/objective_repository/deco_hop/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DecoHopBlackBox(TDCBlackBox):

Methods
-------
__init__(self, string_representation, force_isolation, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=float("inf"))
__init__(self, string_representation, force_isolation, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=None))
Creates a DecoHopBlackBox instance.

References
Expand All @@ -85,7 +85,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
):
super().__init__(
oracle_name="Deco Hop",
Expand Down Expand Up @@ -144,7 +144,7 @@ def create(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
) -> Problem:
"""
Expand Down
10 changes: 5 additions & 5 deletions src/poli/objective_repository/dms_gb1/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DMSGB1BlackBox(AbstractBlackBox):
num_workers : int, optional
The number of workers for parallel evaluation, by default None.
evaluation_budget : int, optional
The evaluation budget, by default float("inf").
The evaluation budget, by default None).

Methods
-------
Expand All @@ -71,7 +71,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
):
"""
Expand All @@ -90,7 +90,7 @@ def __init__(
num_workers : int, optional
The number of workers for parallel evaluation, by default None.
evaluation_budget : int, optional
The evaluation budget, by default float("inf").
The evaluation budget, by default None).
"""
if parallelize:
print(
Expand Down Expand Up @@ -175,7 +175,7 @@ def create(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
) -> Problem:
"""
Expand All @@ -197,7 +197,7 @@ def create(
num_workers : int, optional
The number of workers for parallel evaluation, by default None.
evaluation_budget : int, optional
The evaluation budget, by default float("inf").
The evaluation budget, by default None).

Returns
-------
Expand Down
10 changes: 5 additions & 5 deletions src/poli/objective_repository/dms_trpb/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DMSTrpBBlackBox(AbstractBlackBox):
num_workers : int, optional
The number of workers for parallel evaluation, by default None.
evaluation_budget : int, optional
The evaluation budget, by default float("inf").
The evaluation budget, by default None).

Methods
-------
Expand All @@ -67,7 +67,7 @@ def __init__(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
):
"""
Expand All @@ -86,7 +86,7 @@ def __init__(
num_workers : int, optional
The number of workers for parallel evaluation, by default None.
evaluation_budget : int, optional
The evaluation budget, by default float("inf").
The evaluation budget, by default None).
"""
if parallelize:
print(
Expand Down Expand Up @@ -171,7 +171,7 @@ def create(
batch_size: int = None,
parallelize: bool = False,
num_workers: int = None,
evaluation_budget: int = float("inf"),
evaluation_budget: int = None,
force_isolation: bool = False,
) -> Problem:
"""
Expand All @@ -193,7 +193,7 @@ def create(
num_workers : int, optional
The number of workers for parallel evaluation, by default None.
evaluation_budget : int, optional
The evaluation budget, by default float("inf").
The evaluation budget, by default None).

Returns
-------
Expand Down
Loading
Loading