discrete_optimization.fjsp.solvers package

Submodules

discrete_optimization.fjsp.solvers.cpsat module

class discrete_optimization.fjsp.solvers.cpsat.CpSatFjspSolver(problem: FJobShopProblem, **kwargs: Any)[source]

Bases: SchedulingCpSatSolver[tuple[int, int]], MultimodeCpSatSolver[tuple[int, int]], WarmstartMixin

create_disjunctive_constraints(**args)[source]
create_is_present_constraints()[source]
create_precedence_constraints()[source]
create_vars(**args)[source]
get_makespan_upper_bound() int[source]

Get a upper bound on global makespan.

get_task_mode_is_present_variable(task: tuple[int, int], mode: int) LinearExpr | IntVar | int | int8 | uint8 | int32 | uint32 | int64 | uint64[source]

Retrieve the 0-1 variable/expression telling if the mode is used for the task.

Parameters:
  • task

  • mode

Returns:

get_task_start_or_end_variable(task: tuple[int, int], start_or_end: StartOrEnd) LinearExpr | IntVar | int | int8 | uint8 | int32 | uint32 | int64 | uint64[source]

Retrieve the variable storing the start or end time of given task.

Parameters:
  • task

  • start_or_end

Returns:

hyperparameters: list[Hyperparameter] = [CategoricalHyperparameter(name='duplicate_temporal_var', default=False, depends_on=None, name_in_kwargs='duplicate_temporal_var'), CategoricalHyperparameter(name='add_cumulative_constraint', default=False, depends_on=None, name_in_kwargs='add_cumulative_constraint')]

Hyperparameters available for this solver.

These hyperparameters are to be feed to **kwargs found in
  • __init__()

  • init_model() (when available)

  • solve()

init_model(**args: Any) None[source]

Init cp model and reset stored variables if any.

problem: FJobShopProblem
retrieve_solution(cpsolvercb: CpSolverSolutionCallback) Solution[source]

Construct a do solution from the cpsat solver internal solution.

It will be called each time the cpsat solver find a new solution. At that point, value of internal variables are accessible via cpsolvercb.Value(VARIABLE_NAME).

Parameters:

cpsolvercb – the ortools callback called when the cpsat solver finds a new solution.

Returns:

the intermediate solution, at do format.

set_warm_start(solution: FJobShopSolution) None[source]

Make the solver warm start from the given solution.

discrete_optimization.fjsp.solvers.dp module

class discrete_optimization.fjsp.solvers.dp.DpFjspSolver(problem: Problem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs: Any)[source]

Bases: DpSolver, WarmstartMixin

hyperparameters: list[Hyperparameter] = [CategoricalHyperparameter(name='solver', default=<class 'builtins.CABS'>, depends_on=None, name_in_kwargs='solver'), CategoricalHyperparameter(name='add_penalty_on_inefficiency', default=True, depends_on=None, name_in_kwargs='add_penalty_on_inefficiency')]

Hyperparameters available for this solver.

These hyperparameters are to be feed to **kwargs found in
  • __init__()

  • init_model() (when available)

  • solve()

init_model(**kwargs: Any) None[source]

Initialize internal model used to solve.

Can initialize a ortools, milp, gurobi, … model.

problem: FJobShopProblem
retrieve_solution(sol: Solution) Solution[source]
set_warm_start(solution: FJobShopSolution) None[source]

Make the solver warm start from the given solution.

discrete_optimization.fjsp.solvers.lns_cpsat module

class discrete_optimization.fjsp.solvers.lns_cpsat.FjspConstraintHandler(problem: FJobShopProblem, fraction_segment_to_fix: float = 0.9)[source]

Bases: OrtoolsCpSatConstraintHandler

adding_constraint_from_results_store(solver: CpSatFjspSolver, result_storage: ResultStorage, result_storage_last_iteration: ResultStorage, **kwargs: Any) Iterable[Constraint][source]

Add constraints to the internal model of a solver based on previous solutions

Parameters:
  • solver – solver whose internal model is updated

  • result_storage – all results so far

  • result_storage_last_iteration – results from last LNS iteration only

  • **kwargs

Returns:

list of added constraints

class discrete_optimization.fjsp.solvers.lns_cpsat.NeighFjspConstraintHandler(problem: FJobShopProblem, neighbor_builder: NeighborBuilderSubPart)[source]

Bases: OrtoolsCpSatConstraintHandler

adding_constraint_from_results_store(solver: CpSatFjspSolver, result_storage: ResultStorage, result_storage_last_iteration: ResultStorage, **kwargs: Any) Iterable[Constraint][source]

Add constraints to the internal model of a solver based on previous solutions

Parameters:
  • solver – solver whose internal model is updated

  • result_storage – all results so far

  • result_storage_last_iteration – results from last LNS iteration only

  • **kwargs

Returns:

list of added constraints

class discrete_optimization.fjsp.solvers.lns_cpsat.NeighborBuilderSubPart(problem: FJobShopProblem, nb_cut_part: int = 10)[source]

Bases: object

Cut the schedule in different subpart in the increasing order of the schedule.

find_subtasks(current_solution: FJobShopSolution, subtasks: set[Hashable] | None = None) tuple[set[tuple[int, int]], set[tuple[int, int]]][source]

discrete_optimization.fjsp.solvers.optal module

class discrete_optimization.fjsp.solvers.optal.OptalFJspSolver(problem: FJobShopProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs: Any)[source]

Bases: OptalSolver

build_command(parameters_cp: ParametersCp | None = None, time_limit: int = 10, **args: Any)[source]

Build the command line call for optal cp. You can pass parameters from the Parameters class of optal cp for example : searchType=fds, worker0-1.noOverlapPropagationLevel=4 if you want worker 0 and 1 to use this parameters etc. TODO : list such parameters in hyperparameter of this wrapped solver.

init_model(**args: Any) None[source]

Instantiate a CP model instance

Afterwards, self.instance should not be None anymore.

problem: FJobShopProblem
retrieve_current_solution(dict_results: dict) Solution[source]
discrete_optimization.fjsp.solvers.optal.deparse_file(problem: FJobShopProblem, original_header_float: float = 0.0) str[source]

Writes an FJobShopProblem object to a string in the .fjs format.

Parameters:
  • problem – The FJobShopProblem object to write.

  • original_header_float – Optional float value from the original file’s header.

Returns:

A string containing the problem data in .fjs format.

Module contents