This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Change class and decorators locations to match new layout
- In general, ai.timefold.solver.core.api.x and its subpackages -> timefold.solver.x. - Exception for ai.timefold.solver.core.api.solver, which it and its subpackages -> timefold.solver. - ai.timefold.solver.core.x and its subpackages -> timefold.solver.x (test and config). - Use dynamic __all__ when not TYPE_CHECKING for score and domain, since they have some classes that require the JVM to be started When TYPE_CHECKING, there are stub classes that the TYPE_CHECKER will see. - Remove `@incremental_score_calculator` decorator, since it been replaced by `IncrementalScoreCalculator` ABC. - Create an empty Constraint stub so users can reference it in their type signatures without importing something from Java.
- Loading branch information
1 parent
2708167
commit d5440fe
Showing
51 changed files
with
334 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ython-core/src/main/python/api/_future.py → ...er-python-core/src/main/python/_future.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
timefold-solver-python-core/src/main/python/_solution_manager.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from ._solver_factory import SolverFactory | ||
from ._solver_manager import SolverManager | ||
from .score import ScoreAnalysis, ScoreExplanation | ||
|
||
from typing import TypeVar, Generic, TYPE_CHECKING, Any | ||
|
||
if TYPE_CHECKING: | ||
# These imports require a JVM to be running, so only import if type checking | ||
from .score import Score | ||
from ai.timefold.solver.core.api.solver import SolutionManager as _JavaSolutionManager | ||
|
||
Solution_ = TypeVar('Solution_') | ||
ProblemId_ = TypeVar('ProblemId_') | ||
Score_ = TypeVar('Score_', bound='Score') | ||
Justification_ = TypeVar('Justification_', bound='ConstraintJustification') | ||
|
||
|
||
class SolutionManager(Generic[Solution_]): | ||
_delegate: '_JavaSolutionManager' | ||
|
||
def __init__(self, delegate: '_JavaSolutionManager'): | ||
self._delegate = delegate | ||
|
||
@staticmethod | ||
def create(solver_factory: SolverFactory[Solution_] | SolverManager[Solution_, Any]) -> \ | ||
'SolutionManager[Solution_]': | ||
from ai.timefold.solver.core.api.solver import SolutionManager as JavaSolutionManager | ||
return SolutionManager(JavaSolutionManager.create(solver_factory._delegate)) | ||
|
||
def update(self, solution: Solution_, solution_update_policy=None) -> 'Score': | ||
# TODO handle solution_update_policy | ||
from jpyinterpreter import convert_to_java_python_like_object, update_python_object_from_java | ||
java_solution = convert_to_java_python_like_object(solution) | ||
out = self._delegate.update(java_solution) | ||
update_python_object_from_java(java_solution) | ||
return out | ||
|
||
def analyze(self, solution: Solution_, score_analysis_fetch_policy=None, solution_update_policy=None) \ | ||
-> 'ScoreAnalysis': | ||
# TODO handle policies | ||
from jpyinterpreter import convert_to_java_python_like_object | ||
return ScoreAnalysis(self._delegate.analyze(convert_to_java_python_like_object(solution))) | ||
|
||
def explain(self, solution: Solution_, solution_update_policy=None) -> 'ScoreExplanation': | ||
# TODO handle policies | ||
from jpyinterpreter import convert_to_java_python_like_object | ||
return ScoreExplanation(self._delegate.explain(convert_to_java_python_like_object(solution))) | ||
|
||
def recommend_fit(self, solution: Solution_, entity_or_element, proposition_function, | ||
score_analysis_fetch_policy=None): | ||
# TODO | ||
raise NotImplementedError | ||
|
||
|
||
__all__ = ['SolutionManager'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...re/src/main/python/api/_solver_factory.py → ...n-core/src/main/python/_solver_factory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...re/src/main/python/api/_solver_manager.py → ...n-core/src/main/python/_solver_manager.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
timefold-solver-python-core/src/main/python/annotation/__init__.py
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.