Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
chore: Move nearby_distance_meter to heuristic
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher-Chianelli committed May 2, 2024
1 parent d5440fe commit 504451f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
11 changes: 8 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion tests/test_user_error.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion timefold-solver-python-core/src/main/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,8 +11,6 @@


Solution_ = TypeVar('Solution_')
Origin_ = TypeVar('Origin_')
Destination_ = TypeVar('Destination_')


class PlanningId(JavaAnnotation):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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']
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._nearby_selection import *
Original file line number Diff line number Diff line change
@@ -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']

0 comments on commit 504451f

Please sign in to comment.