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[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
- 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_objective(source_problem: SpecificSchedulingProblem) tuple[Objective | Iterable[tuple[Objective, int]], Callable[[GenericSchedulingImplSolution], int] | None, dict[Hashable, int] | None, bool][source]
Transform scheduling problem objective for the generic implementation.
This default implementation returns default values of GenericSchedulingImplProblem. To be overriden in child classes.
- Returns:
the corresponding arguments of GenericSchedulingImplProblem.__init__(), resulting to computing makespan + time penalty. See its documentation for more details.
- Return type:
objective, custom_evaluate_fn, objective_resource_weights, compute_time_penalty
- 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:
source_problem
Returns:
- discrete_optimization.generic_tasks_tools.transformations.generic_scheduling_impl.convert_solution_from_specific_to_generic(solution: SpecificSchedulingSolution, generic_problem: GenericSchedulingImplProblem) GenericSchedulingImplSolution[source]