diff --git a/setup.py b/setup.py index 889991a..231da47 100644 --- a/setup.py +++ b/setup.py @@ -98,11 +98,16 @@ def find_stub_files(stub_root: str): 'License :: OSI Approved :: Apache Software License', 'Operating System :: OS Independent' ], - packages=['timefold.solver', 'timefold.solver.domain', - 'timefold.solver.config', 'timefold.solver.score', + packages=['timefold.solver', + 'timefold.solver.config', + 'timefold.solver.domain', + 'timefold.solver.heuristic', + 'timefold.solver.score', 'timefold.solver.test', 'jpyinterpreter', - 'java-stubs', 'jpype-stubs', 'ai-stubs'], + 'java-stubs', + 'jpype-stubs', + 'ai-stubs'], package_dir={ 'timefold.solver': 'timefold-solver-python-core/src/main/python', 'jpyinterpreter': 'jpyinterpreter/src/main/python', diff --git a/tests/test_user_error.py b/tests/test_user_error.py index 33c42e9..dcf7eaf 100644 --- a/tests/test_user_error.py +++ b/tests/test_user_error.py @@ -1,6 +1,7 @@ from timefold.solver import * -from timefold.solver.domain import * from timefold.solver.config import * +from timefold.solver.domain import * +from timefold.solver.heuristic import * from timefold.solver.score import * import pytest diff --git a/timefold-solver-python-core/src/main/python/__init__.py b/timefold-solver-python-core/src/main/python/__init__.py index f559a4e..619b6c1 100644 --- a/timefold-solver-python-core/src/main/python/__init__.py +++ b/timefold-solver-python-core/src/main/python/__init__.py @@ -13,8 +13,9 @@ from ._solver_factory import * from ._solver_manager import * -import timefold.solver.domain as domain import timefold.solver.config as config +import timefold.solver.domain as domain +import timefold.solver.heuristic as heuristic import timefold.solver.score as score import timefold.solver.test as test diff --git a/timefold-solver-python-core/src/main/python/domain/_annotations.py b/timefold-solver-python-core/src/main/python/domain/_annotations.py index ee0c111..4264e92 100644 --- a/timefold-solver-python-core/src/main/python/domain/_annotations.py +++ b/timefold-solver-python-core/src/main/python/domain/_annotations.py @@ -1,7 +1,7 @@ import jpype from ._variable_listener import VariableListener -from .._timefold_java_interop import ensure_init, register_java_class, get_asm_type +from .._timefold_java_interop import ensure_init, get_asm_type from jpyinterpreter import JavaAnnotation, AnnotationValueSupplier from jpype import JImplements, JOverride from typing import Union, List, Callable, Type, TYPE_CHECKING, TypeVar @@ -11,8 +11,6 @@ Solution_ = TypeVar('Solution_') -Origin_ = TypeVar('Origin_') -Destination_ = TypeVar('Destination_') class PlanningId(JavaAnnotation): @@ -350,18 +348,6 @@ def constraint_configuration(constraint_configuration_class: Type[Solution_]) -> return out -def nearby_distance_meter(distance_function: Callable[[Origin_, Destination_], float], /) \ - -> Callable[[Origin_, Destination_], float]: - ensure_init() - from jpyinterpreter import translate_python_bytecode_to_java_bytecode, generate_proxy_class_for_translated_function - from ai.timefold.solver.core.impl.heuristic.selector.common.nearby import NearbyDistanceMeter # noqa - java_class = generate_proxy_class_for_translated_function(NearbyDistanceMeter, - translate_python_bytecode_to_java_bytecode( - distance_function, - NearbyDistanceMeter)) - return register_java_class(distance_function, java_class) - - def problem_change(problem_change_class: Type['_ProblemChange']) -> \ Type['_ProblemChange']: """A ProblemChange represents a change in 1 or more planning entities or problem facts of a PlanningSolution. @@ -420,5 +406,4 @@ def wrapper_doChange(self, solution, problem_change_director): 'ValueRangeProvider', 'DeepPlanningClone', 'ConstraintConfigurationProvider', 'ConstraintWeight', 'planning_entity', 'planning_solution', 'constraint_configuration', - 'nearby_distance_meter', 'problem_change'] diff --git a/timefold-solver-python-core/src/main/python/heuristic/__init__.py b/timefold-solver-python-core/src/main/python/heuristic/__init__.py new file mode 100644 index 0000000..5dbe766 --- /dev/null +++ b/timefold-solver-python-core/src/main/python/heuristic/__init__.py @@ -0,0 +1 @@ +from ._nearby_selection import * diff --git a/timefold-solver-python-core/src/main/python/heuristic/_nearby_selection.py b/timefold-solver-python-core/src/main/python/heuristic/_nearby_selection.py new file mode 100644 index 0000000..92f5ac2 --- /dev/null +++ b/timefold-solver-python-core/src/main/python/heuristic/_nearby_selection.py @@ -0,0 +1,20 @@ +from typing import Callable, TypeVar +from .._timefold_java_interop import ensure_init, register_java_class + +Origin_ = TypeVar('Origin_') +Destination_ = TypeVar('Destination_') + + +def nearby_distance_meter(distance_function: Callable[[Origin_, Destination_], float], /) \ + -> Callable[[Origin_, Destination_], float]: + ensure_init() + from jpyinterpreter import translate_python_bytecode_to_java_bytecode, generate_proxy_class_for_translated_function + from ai.timefold.solver.core.impl.heuristic.selector.common.nearby import NearbyDistanceMeter # noqa + java_class = generate_proxy_class_for_translated_function(NearbyDistanceMeter, + translate_python_bytecode_to_java_bytecode( + distance_function, + NearbyDistanceMeter)) + return register_java_class(distance_function, java_class) + + +__all__ = ['nearby_distance_meter']