discrete_optimization.singlemachine package
Subpackages
- discrete_optimization.singlemachine.solvers package
- Submodules
- discrete_optimization.singlemachine.solvers.cpmpy_solver module
- discrete_optimization.singlemachine.solvers.cpsat module
- discrete_optimization.singlemachine.solvers.dp module
- discrete_optimization.singlemachine.solvers.greedy module
- discrete_optimization.singlemachine.solvers.lp module
- discrete_optimization.singlemachine.solvers.optal module
- Module contents
Submodules
discrete_optimization.singlemachine.parser module
- discrete_optimization.singlemachine.parser.get_data_available(data_folder: str | None = None, data_home: str | None = None) list[str][source]
Get datasets available for tsp.
- Params:
- data_folder: folder where datasets for weighted tardiness problem should be found.
If None, we look in “wt” subdirectory of data_home.
- data_home: root directory for all datasets. Is None, set by
default to “~/discrete_optimization_data “
- discrete_optimization.singlemachine.parser.parse_wt_content(file_content: str, num_jobs: int) list[WeightedTardinessProblem][source]
Parses a weighted tardiness file with a known number of jobs per instance.
- Parameters:
file_content (str) – The full content of the text file.
num_jobs (int) – The number of jobs per instance (e.g., 40 for wt40.txt).
- Returns:
A list of parsed problem instances.
- Return type:
List[WeightedTardinessProblem]
discrete_optimization.singlemachine.problem module
- class discrete_optimization.singlemachine.problem.WTSolution(problem: WeightedTardinessProblem, schedule: list[tuple[int, int]] = None, permutation: list[int] = None)[source]
Bases:
SchedulingSolution[int]- copy() Solution[source]
Deep copy of the solution.
The copy() function should return a new object containing the same input as the current object, that respects the following expected behaviour: -y = x.copy() -if do some inplace change of y, the changes are not done in x.
Returns: a new object from which you can manipulate attributes without changing the original object.
- lazy_copy() Solution[source]
This function should return a new object but possibly with mutable attributes from the original objects.
A typical use of lazy copy is in evolutionary algorithms or genetic algorithm where the use of local move don’t need to do a possibly costly deepcopy.
Returns (Solution): copy (possibly shallow) of the Solution
- class discrete_optimization.singlemachine.problem.WeightedTardinessProblem(num_jobs: int, processing_times: List[int], weights: List[int], due_dates: List[int], release_dates: List[int] | None = None)[source]
Bases:
SchedulingProblem[int]Represents a single instance of the single-machine weighted tardiness problem.
- evaluate(variable: WTSolution) dict[str, float][source]
Evaluate a given solution object for the given problem.
This method should return a dictionnary of KPI, that can be then used for mono or multiobjective optimization.
- Parameters:
variable (Solution) – the Solution object to evaluate.
Returns: dictionnary of float kpi for the solution.
- get_attribute_register() EncodingRegister[source]
Returns how the Solution should be encoded.
Returns (EncodingRegister): content of the encoding of the solution
- get_objective_register() ObjectiveRegister[source]
Returns the objective definition.
Returns (ObjectiveRegister): object defining the objective criteria.
- get_solution_type() type[Solution][source]
Returns the class implementation of a Solution.
Returns (class): class object of the given Problem.
- satisfy(variable: WTSolution) bool[source]
Computes if a solution satisfies or not the constraints of the problem.
- Parameters:
variable – the Solution object to check satisfability
Returns (bool): boolean true if the constraints are fulfilled, false elsewhere.