discrete_optimization.generic_tasks_tools.transformations package
Submodules
discrete_optimization.generic_tasks_tools.transformations.generic_scheduling_impl module
- class discrete_optimization.generic_tasks_tools.transformations.generic_scheduling_impl.FromGenericSchedulingImpl[source]
Bases:
ProblemTransformation[GenericSchedulingImplProblem,GenericSchedulingImplSolution,SpecificSchedulingProblem,SpecificSchedulingSolution],Generic[SpecificSchedulingProblem,SpecificSchedulingSolution]Transform the generic implementation of a scheduling problem into a specific one.
This is still an abstract class, as the transform_problem() remains to implement.
- back_transform_solution(solution: SpecificSchedulingSolution, source_problem: GenericSchedulingImplProblem) GenericSchedulingImplSolution[source]
Convert solution from target problem back to source problem.
This is REQUIRED for all transformations.
- Parameters:
solution – Solution in target problem space
source_problem – Original problem (to associate with back-transformed solution)
- Returns:
Corresponding solution in source problem space
- class discrete_optimization.generic_tasks_tools.transformations.generic_scheduling_impl.ToGenericSchedulingImpl(list_objective_computer: list[ObjectiveComputer] = None)[source]
Bases:
ProblemTransformation[SpecificSchedulingProblem,SpecificSchedulingSolution,GenericSchedulingImplProblem,GenericSchedulingImplSolution],Generic[SpecificSchedulingProblem,SpecificSchedulingSolution]Transform a specific scheduling problem into the generic implementation.
This is still an abstract class, as convert_solution_from_raw_generic_to_specific() remains to implement.
- back_transform_solution(solution: GenericSchedulingImplSolution, source_problem: SpecificSchedulingProblem) SpecificSchedulingSolution[source]
Convert solution from target problem back to source problem.
This is REQUIRED for all transformations.
- Parameters:
solution – Solution in target problem space
source_problem – Original problem (to associate with back-transformed solution)
- Returns:
Corresponding solution in source problem space
- forward_transform_solution(solution: SpecificSchedulingSolution, target_problem: GenericSchedulingImplProblem) GenericSchedulingImplSolution | None[source]
Convert solution from source problem to target problem.
This is OPTIONAL - only needed for warmstart support. Return None if transformation not supported/meaningful.
- Parameters:
solution – Solution in source problem space
target_problem – Transformed problem (to associate with forward-transformed solution)
- Returns:
Corresponding solution in target problem space, or None if not supported
- get_list_objective_computer(source_problem: SpecificSchedulingProblem) list[ObjectiveComputer][source]
From the source problem, compute a list of objective computers to be used in GenericSchedulingImplProblem. To be overriden in child classes.
Returns:
- is_bidirectional(source_problem: SpecificSchedulingProblem) bool[source]
Check if transformation supports both directions.
- Parameters:
source_problem – Problem to check bidirectionality for
- Returns:
True if forward_transform_solution is implemented
- transform_problem(source_problem: SpecificSchedulingProblem) GenericSchedulingImplProblem[source]
Transform source problem to target problem.
This method should be deterministic: same source → same target.
- Parameters:
source_problem – The original problem to transform
- Returns:
Transformed problem instance
- abstractmethod transform_solution_from_raw_generic_to_specific(raw_sol: RawSolution[Hashable, Hashable, Hashable], source_problem: SpecificSchedulingProblem) SpecificSchedulingSolution[source]
Convert a raw solution (from generic problem) into a specific solution to the source problem.
- Parameters:
raw_sol – Raw solution to convert to a specific solution
source_problem – Target Problem we want to build a solution for.
Returns:
- discrete_optimization.generic_tasks_tools.transformations.generic_scheduling_impl.convert_solution_from_specific_to_generic(solution: SpecificSchedulingSolution, generic_problem: GenericSchedulingImplProblem) GenericSchedulingImplSolution[source]