discrete_optimization.rcpsp.solvers package
Submodules
discrete_optimization.rcpsp.solvers.cp_mzn module
- discrete_optimization.rcpsp.solvers.cp_mzn.CPMultimodeWithFakeTaskRcpspSolver(problem: RcpspProblem, cp_solver_name: CpSolverName = CpSolverName.CHUFFED, params_objective_function: ParamsObjectiveFunction = None, silent_solve_error: bool = False, **kwargs)[source]
Deprecated since version 0.1.
- class discrete_optimization.rcpsp.solvers.cp_mzn.CpModesMultimodeRcpspSolver(problem: RcpspProblem, cp_solver_name: CpSolverName = CpSolverName.CHUFFED, params_objective_function: ParamsObjectiveFunction | None = None)[source]
Bases:
object
- problem: RcpspProblem
- retrieve_solutions(result, parameters_cp: ParametersCp)[source]
- solve(parameters_cp: ParametersCp | None = None, time_limit: float | None = 100.0, nr_solutions: int = 1, all_solutions: bool = False, **args)[source]
Solve the CP problem with minizinc
- Parameters:
parameters_cp – parameters specific to CP solvers
time_limit – the solve process stops after this time limit (in seconds). If None, no time limit is applied.
nr_solutions – of not all_solutions, the solve stops after finding nr_solutions
all_solutions – if True, do not stop when reaching nr_solutions
**args – passed to init_model()
Returns:
- class discrete_optimization.rcpsp.solvers.cp_mzn.CpMultimodePreemptiveRcpspSolver(problem: PreemptiveRcpspProblem, cp_solver_name: CpSolverName = CpSolverName.CHUFFED, params_objective_function: ParamsObjectiveFunction | None = None, silent_solve_error: bool = True, **kwargs)[source]
Bases:
MinizincCpSolver
,RcpspSolver
- constraint_duration_string_preemptive_i(task, duration, part_id=1, sign: SignEnum = SignEnum.EQUAL) str [source]
- constraint_ressource_requirement_at_time_t(time, ressource, ressource_number, sign: SignEnum = SignEnum.LEQ)[source]
- constraint_start_time_string_preemptive_i(task, start_time, part_id=1, sign: SignEnum = SignEnum.EQUAL) str [source]
- init_model(**args)[source]
Instantiate a CP model instance
Afterwards, self.instance should not be None anymore.
- problem: PreemptiveRcpspProblem
- retrieve_solution(_output_item: str | None = None, **kwargs: Any) PreemptiveRcpspSolution [source]
Return a d-o solution from the variables computed by minizinc.
- Parameters:
_output_item – string representing the minizinc solver output passed by minizinc to the solution constructor
**kwargs – keyword arguments passed by minzinc to the solution contructor containing the objective value (key “objective”), and the computed variables as defined in minizinc model.
Returns:
- class discrete_optimization.rcpsp.solvers.cp_mzn.CpMultimodeRcpspSolver(problem: RcpspProblem, cp_solver_name: CpSolverName = CpSolverName.CHUFFED, params_objective_function: ParamsObjectiveFunction | None = None, silent_solve_error: bool = False, **kwargs)[source]
Bases:
MinizincCpSolver
,RcpspSolver
- hyperparameters: list[Hyperparameter] = [EnumHyperparameter(name='cp_solver_name', default=<CpSolverName.CHUFFED: 0>, depends_on=None, name_in_kwargs='cp_solver_name')]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- init_model(**args)[source]
Instantiate a CP model instance
Afterwards, self.instance should not be None anymore.
- problem: RcpspProblem
- retrieve_solution(_output_item: str | None = None, **kwargs: Any) RcpspSolution [source]
Return a d-o solution from the variables computed by minizinc.
- Parameters:
_output_item – string representing the minizinc solver output passed by minizinc to the solution constructor
**kwargs – keyword arguments passed by minzinc to the solution contructor containing the objective value (key “objective”), and the computed variables as defined in minizinc model.
Returns:
- class discrete_optimization.rcpsp.solvers.cp_mzn.CpNoBoolMultimodeRcpspSolver(problem: RcpspProblem, cp_solver_name: CpSolverName = CpSolverName.CHUFFED, params_objective_function: ParamsObjectiveFunction | None = None, silent_solve_error: bool = False, **kwargs)[source]
Bases:
MinizincCpSolver
,RcpspSolver
- init_model(**args)[source]
Instantiate a CP model instance
Afterwards, self.instance should not be None anymore.
- problem: RcpspProblem
- retrieve_solution(_output_item: str | None = None, **kwargs: Any) RcpspSolution [source]
Return a d-o solution from the variables computed by minizinc.
- Parameters:
_output_item – string representing the minizinc solver output passed by minizinc to the solution constructor
**kwargs – keyword arguments passed by minzinc to the solution contructor containing the objective value (key “objective”), and the computed variables as defined in minizinc model.
Returns:
- class discrete_optimization.rcpsp.solvers.cp_mzn.CpPreemptiveRcpspSolver(problem: PreemptiveRcpspProblem, cp_solver_name: CpSolverName = CpSolverName.CHUFFED, params_objective_function: ParamsObjectiveFunction | None = None, silent_solve_error: bool = True, **kwargs)[source]
Bases:
CpMultimodePreemptiveRcpspSolver
- constraint_ressource_requirement_at_time_t(time, ressource, ressource_number, sign: SignEnum = SignEnum.LEQ)[source]
- init_model(**args)[source]
Instantiate a CP model instance
Afterwards, self.instance should not be None anymore.
- problem: PreemptiveRcpspProblem
- retrieve_solution(**kwargs: Any) PreemptiveRcpspSolution [source]
Return a d-o solution from the variables computed by minizinc.
- Parameters:
**kwargs – keyword arguments passed by minzinc to the solution contructor containing the objective value (key “objective”), and the computed variables as defined in minizinc model.
Returns:
- class discrete_optimization.rcpsp.solvers.cp_mzn.CpRcpspSolver(problem: RcpspProblem, cp_solver_name: CpSolverName = CpSolverName.CHUFFED, params_objective_function: ParamsObjectiveFunction | None = None, silent_solve_error: bool = True, **kwargs)[source]
Bases:
MinizincCpSolver
,RcpspSolver
- hyperparameters: list[Hyperparameter] = [EnumHyperparameter(name='cp_solver_name', default=<CpSolverName.CHUFFED: 0>, depends_on=None, name_in_kwargs='cp_solver_name')]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- init_model(**args)[source]
Instantiate a CP model instance
Afterwards, self.instance should not be None anymore.
- problem: RcpspProblem
- retrieve_solution(_output_item: str | None = None, **kwargs: Any) RcpspSolution [source]
Return a d-o solution from the variables computed by minizinc.
- Parameters:
_output_item – string representing the minizinc solver output passed by minizinc to the solution constructor
**kwargs – keyword arguments passed by minzinc to the solution contructor containing the objective value (key “objective”), and the computed variables as defined in minizinc model.
Returns:
- discrete_optimization.rcpsp.solvers.cp_mzn.add_constraints_string(child_instance, list_of_strings)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.add_fake_task_cp_data(rcpsp_problem: RcpspProblem | PreemptiveRcpspProblem, ignore_fake_task: bool = True, max_time_to_consider: int | None = None)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.add_hard_special_constraints(partial_solution: PartialSolution, cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver | CpMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.add_hard_special_constraints_mrcpsp(partial_solution: PartialSolution, cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.add_soft_special_constraints(partial_solution: PartialSolution, cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.add_soft_special_constraints_mrcpsp(partial_solution: PartialSolution, cp_solver: CpMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.define_second_part_objective(weights, name_penalty, equal=False)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_end_window(end_times_window: dict[Hashable, tuple[int, int]], cp_solver: CpRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpPreemptiveRcpspSolver | CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_after_nunit(list_start_after_nunit: list[tuple[Hashable, Hashable, int]], cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_after_nunit_mrcpsp(list_start_after_nunit: list[tuple[Hashable, Hashable, int]], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_at_end(list_start_at_end: list[tuple[Hashable, Hashable]], cp_solver: CpRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpPreemptiveRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_at_end_mrcpsp(list_start_at_end: list[tuple[Hashable, Hashable]], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_at_end_plus_offset(list_start_at_end_plus_offset, cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_at_end_plus_offset_mrcpsp(list_start_at_end_plus_offset, cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_times(dict_start_times: dict[Hashable, int], cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_times_mrcpsp(dict_start_times: dict[Hashable, int], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_together(list_start_together: list[tuple[Hashable, Hashable]], cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_together_mrcpsp(list_start_together: list[tuple[Hashable, Hashable]], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.hard_start_window(start_times_window: dict[Hashable, tuple[int, int]], cp_solver: CpRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpPreemptiveRcpspSolver | CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.precompute_possible_starting_time_interval(problem: PreemptiveRcpspProblem)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_end_window(end_times_window: dict[Hashable, tuple[int, int]], cp_solver: CpRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpPreemptiveRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_end_window_mrcpsp(end_times_window: dict[Hashable, tuple[int, int]], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_after_nunit(list_start_after_nunit: list[tuple[Hashable, Hashable, int]], cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_after_nunit_mrcpsp(list_start_after_nunit: list[tuple[Hashable, Hashable, int]], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_at_end(list_start_at_end: list[tuple[Hashable, Hashable]], cp_solver: CpRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpPreemptiveRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_at_end_mrcpsp(list_start_at_end: list[tuple[Hashable, Hashable]], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_at_end_plus_offset(list_start_at_end_plus_offset: list[tuple[Hashable, Hashable, int]], cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_at_end_plus_offset_mrcpsp(list_start_at_end_plus_offset: list[tuple[Hashable, Hashable, int]], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_times(dict_start_times: dict[Hashable, int], cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_times_mrcpsp(dict_start_times: dict[Hashable, int], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_together(list_start_together: list[tuple[Hashable, Hashable]], cp_solver: CpPreemptiveRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_together_mrcpsp(list_start_together: list[tuple[Hashable, Hashable]], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_window(start_times_window: dict[Hashable, tuple[int, int]], cp_solver: CpRcpspSolver | CpMultimodePreemptiveRcpspSolver | CpPreemptiveRcpspSolver)[source]
- discrete_optimization.rcpsp.solvers.cp_mzn.soft_start_window_mrcpsp(start_times_window: dict[Hashable, tuple[int, int]], cp_solver: CpMultimodeRcpspSolver | CPMultimodeWithFakeTaskRcpspSolver | CpNoBoolMultimodeRcpspSolver)[source]
discrete_optimization.rcpsp.solvers.cp_mzn_models module
- class discrete_optimization.rcpsp.solvers.cp_mzn_models.CpModelEnum(value)[source]
Bases:
Enum
An enumeration.
- MODES = 'modes'
- MULTI = 'multi'
- MULTI_CALENDAR = 'multi-calendar'
- MULTI_CALENDAR_BOXES = 'multi-calendar-boxes'
- MULTI_FAKETASKS = 'multi-faketasks'
- MULTI_NO_BOOL = 'multi-no-bool'
- MULTI_PREEMPTIVE = 'multi-preemptive'
- MULTI_PREEMPTIVE_CALENDAR = 'multi-preemptive-calendar'
- MULTI_RESOURCE_FEASIBILITY = 'multi-resource-feasibility'
- SINGLE = 'single'
- SINGLE_PREEMPTIVE = 'single-preemptive'
- SINGLE_PREEMPTIVE_CALENDAR = 'single-preemptive-calendar'
discrete_optimization.rcpsp.solvers.cp_mzn_multiscenario module
- class discrete_optimization.rcpsp.solvers.cp_mzn_multiscenario.CpMultiscenarioRcpspSolver(problem: AggregRcpspProblem, cp_solver_name: CpSolverName = CpSolverName.CHUFFED, params_objective_function: ParamsObjectiveFunction | None = None, silent_solve_error: bool = False, **kwargs)[source]
Bases:
MinizincCpSolver
- property base_problem
- hyperparameters: list[Hyperparameter] = [EnumHyperparameter(name='cp_solver_name', default=<CpSolverName.CHUFFED: 0>, depends_on=None, name_in_kwargs='cp_solver_name'), CategoricalHyperparameter(name='relax_ordering', default=False, depends_on=None, name_in_kwargs='relax_ordering'), IntegerHyperparameter(name='nb_incoherence_limit', default=3, depends_on=None, name_in_kwargs='nb_incoherence_limit', low=0, high=10, step=1, log=False)]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- init_model(**args)[source]
Instantiate a CP model instance
Afterwards, self.instance should not be None anymore.
- problem: AggregRcpspProblem
- retrieve_solution(_output_item: str | None = None, **kwargs: Any) RcpspSolution [source]
Return a d-o solution from the variables computed by minizinc.
- Parameters:
_output_item – string representing the minizinc solver output passed by minizinc to the solution constructor
**kwargs – keyword arguments passed by minzinc to the solution contructor containing the objective value (key “objective”), and the computed variables as defined in minizinc model.
Returns:
- discrete_optimization.rcpsp.solvers.cp_mzn_multiscenario.add_fake_task_cp_data(rcpsp_problem: RcpspProblem | PreemptiveRcpspProblem, ignore_fake_task: bool = True, max_time_to_consider: int | None = None)[source]
discrete_optimization.rcpsp.solvers.cpm module
- class discrete_optimization.rcpsp.solvers.cpm.CpmRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
RcpspSolver
- problem: RcpspProblem
- run_sgs_on_order(map_nodes: dict[Any, CpmObject], critical_path: list[Any], total_order: list[Any] | None = None, cut_sgs_by_critical=True)[source]
- run_sgs_time_loop(map_nodes: dict[Any, CpmObject], critical_path: list[Any], total_order: list[Any] | None = None)[source]
- solve(**kwargs) ResultStorage [source]
Generic solving function.
- Parameters:
callbacks – list of callbacks used to hook into the various stage of the solve
**kwargs – any argument specific to the solver
Solvers deriving from SolverDo should use callbacks methods .on_step_end(), … during solve(). But some solvers are not yet updated and are just ignoring it.
Returns (ResultStorage): a result object containing potentially a pool of solutions to a discrete-optimization problem
discrete_optimization.rcpsp.solvers.cpsat module
- class discrete_optimization.rcpsp.solvers.cpsat.CpSatCumulativeResourceRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
CpSatRcpspSolver
Specific solver to minimize the minimum resource amount needed to accomplish the scheduling problem. In this version we sum up the resource for each given time to do the resource optimisation.
- add_lexico_constraint(obj: str, value: float) Iterable[Constraint] [source]
- Parameters:
obj – a string representing the desired objective. Should be one of “makespan” or “used_resource”.
value – the limiting value. If the optimization direction is maximizing, this is a lower bound, else this is an upper bound.
- Returns:
the created constraints.
- create_cumulative_constraint_and_resource_capa(model: CpModel, resource: str, resource_capacity_var: dict[str, IntVar], interval_var: dict[tuple[Hashable, int], IntervalVar], is_present_var: dict[tuple[Hashable, int], IntVar], fake_task: list[dict[str, int]], use_overlap_for_disjunctive_resource: bool)[source]
- get_lexico_objective_value(obj: str, res: ResultStorage) float [source]
Get best internal model objective value found by last call to solve().
The default implementation consists in using the fit of the last solution in result_storage. This assumes: - that the last solution is the best one for the objective considered - that no aggregation was performed but rather that the fitness is a TupleFitness
with values in the same order as self.problem.get_objective_names().
- Parameters:
obj – a string representing the desired objective. Should be one of self.get_lexico_objectives_available().
res – result storage returned by last call to solve().
Returns:
- get_lexico_objectives_available() list[str] [source]
List objectives available for lexico optimization
It corresponds to the labels accepted for obj argument for - set_lexico_objective() - add_lexico_constraint() - get_lexico_objective_value()
Default to self.problem.get_objective_names().
Returns:
- hyperparameters: list[Hyperparameter] = [CategoricalHyperparameter(name='use_overlap_for_disjunctive_resource', default=True, depends_on=None, name_in_kwargs='use_overlap_for_disjunctive_resource')]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- static implements_lexico_api() bool [source]
Tell whether this solver is implementing the api for lexicographic optimization.
Should return True only if
set_lexico_objective()
add_lexico_constraint()
get_lexico_objective_value()
have been really implemented, i.e. - calling set_lexico_objective() and add_lexico_constraint()
should actually change the next call to solve(),
get_lexico_objective_value() should correspond to the internal model objective
- retrieve_solution(cpsolvercb: CpSolverSolutionCallback) RcpspSolution [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.
- class discrete_optimization.rcpsp.solvers.cpsat.CpSatRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
OrtoolsCpSatSolver
,RcpspSolver
,WarmstartMixin
- add_classical_precedence_constraints(model: CpModel, starts_var: dict[Hashable, IntVar], ends_var: dict[Hashable, IntVar])[source]
- add_one_mode_selected_per_task(model: CpModel, is_present_var: dict[tuple[Hashable, int], IntVar], interval_per_tasks: dict[Hashable, set[tuple[Hashable, int]]])[source]
- create_cumulative_constraint(model: CpModel, resource: str, interval_var: dict[tuple[Hashable, int], IntervalVar], is_present_var: dict[tuple[Hashable, int], IntVar], fake_task: list[dict[str, int]])[source]
- create_fake_tasks() list[dict[str, int]] [source]
Create tasks representing the variable resource availability. :return:
- create_mode_pair_constraint(model: CpModel, interval_per_tasks: dict[Hashable, set[tuple[Hashable, int]]], is_present_var: dict[tuple[Hashable, int], IntVar], pair_mode_constraint: PairModeConstraint)[source]
- init_temporal_variable(model: CpModel) tuple[dict[Hashable, IntVar], dict[Hashable, IntVar], dict[tuple[Hashable, int], IntVar], dict[tuple[Hashable, int], IntervalVar], dict[Hashable, set[tuple[Hashable, int]]]] [source]
- retrieve_solution(cpsolvercb: CpSolverSolutionCallback) RcpspSolution [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: RcpspSolution) None [source]
Make the solver warm start from the given solution.
- class discrete_optimization.rcpsp.solvers.cpsat.CpSatResourceRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
CpSatRcpspSolver
Specific solver to minimize the minimum resource amount needed to accomplish the scheduling problem. In this version we don’t sum up the resource at a given time, and it suits/makes sense mostly for disjunctive resource (machines)
- add_lexico_constraint(obj: str, value: float) Iterable[Constraint] [source]
- Parameters:
obj – a string representing the desired objective. Should be one of self.problem.get_objective_names().
value – the limiting value. If the optimization direction is maximizing, this is a lower bound, else this is an upper bound.
- Returns:
the created constraints.
- create_cumulative_constraint_and_used_resource(model: CpModel, resource: str, is_used_resource: dict[str, IntVar], interval_var: dict[tuple[Hashable, int], IntervalVar], is_present_var: dict[tuple[Hashable, int], IntVar], fake_task: list[dict[str, int]])[source]
- get_lexico_objective_value(obj: str, res: ResultStorage) float [source]
Get best internal model objective value found by last call to solve().
The default implementation consists in using the fit of the last solution in result_storage. This assumes: - that the last solution is the best one for the objective considered - that no aggregation was performed but rather that the fitness is a TupleFitness
with values in the same order as self.problem.get_objective_names().
- Parameters:
obj – a string representing the desired objective. Should be one of self.get_lexico_objectives_available().
res – result storage returned by last call to solve().
Returns:
- get_lexico_objectives_available() list[str] [source]
List objectives available for lexico optimization
It corresponds to the labels accepted for obj argument for - set_lexico_objective() - add_lexico_constraint() - get_lexico_objective_value()
Default to self.problem.get_objective_names().
Returns:
- static implements_lexico_api() bool [source]
Tell whether this solver is implementing the api for lexicographic optimization.
Should return True only if
set_lexico_objective()
add_lexico_constraint()
get_lexico_objective_value()
have been really implemented, i.e. - calling set_lexico_objective() and add_lexico_constraint()
should actually change the next call to solve(),
get_lexico_objective_value() should correspond to the internal model objective
- retrieve_solution(cpsolvercb: CpSolverSolutionCallback) RcpspSolution [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.
discrete_optimization.rcpsp.solvers.dp module
- class discrete_optimization.rcpsp.solvers.dp.DpRcpspModeling(value)[source]
Bases:
Enum
An enumeration.
- TASK_AND_TIME = 0
- TASK_AVAIL_TASK_UPD = 2
- TASK_MULTIMODE = 3
- TASK_ORIGINAL = 1
- class discrete_optimization.rcpsp.solvers.dp.DpRcpspSolver(problem: RcpspProblem, **kwargs: Any)[source]
Bases:
DpSolver
,RcpspSolver
,WarmstartMixin
- hyperparameters: list[Hyperparameter] = [CategoricalHyperparameter(name='solver', default=<class 'builtins.CABS'>, depends_on=None, name_in_kwargs='solver'), EnumHyperparameter(name='modeling', default=<DpRcpspModeling.TASK_MULTIMODE: 3>, depends_on=None, name_in_kwargs='modeling'), CategoricalHyperparameter(name='dual_bound', default=False, depends_on=None, name_in_kwargs='dual_bound')]
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)[source]
Initialize internal model used to solve.
Can initialize a ortools, milp, gurobi, … model.
- modeling: DpRcpspModeling
- problem: RcpspProblem
- set_warm_start(solution: RcpspSolution) None [source]
Make the solver warm start from the given solution.
- transitions: dict
discrete_optimization.rcpsp.solvers.ga module
- class discrete_optimization.rcpsp.solvers.ga.GaMultimodeRcpspSolver(problem: Problem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs: Any)[source]
Bases:
RcpspSolver
- hyperparameters: list[Hyperparameter] = [EnumHyperparameter(name='crossover', default=None, depends_on=None, name_in_kwargs='crossover'), EnumHyperparameter(name='selection', default=<DeapSelection.SEL_TOURNAMENT: 0>, depends_on=None, name_in_kwargs='selection'), IntegerHyperparameter(name='pop_size', default=100, depends_on=None, name_in_kwargs='pop_size', low=1, high=1000, step=1, log=False), FloatHyperparameter(name='mut_rate', default=0.1, depends_on=None, name_in_kwargs='mut_rate', low=0, high=0.9, suggest_low=False, suggest_high=False, step=None, log=False), FloatHyperparameter(name='crossover_rate', default=0.9, depends_on=None, name_in_kwargs='crossover_rate', low=0, high=1, suggest_low=False, suggest_high=False, step=None, log=False), FloatHyperparameter(name='tournament_size', default=0.2, depends_on=None, name_in_kwargs='tournament_size', low=0, high=1, suggest_low=False, suggest_high=False, step=None, log=False)]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- problem: RcpspProblem
- solve(parameters_ga: ~discrete_optimization.generic_tools.ea.ga_tools.ParametersAltGa = <discrete_optimization.generic_tools.ea.ga_tools.ParametersAltGa object>, **args)[source]
Generic solving function.
- Parameters:
callbacks – list of callbacks used to hook into the various stage of the solve
**kwargs – any argument specific to the solver
Solvers deriving from SolverDo should use callbacks methods .on_step_end(), … during solve(). But some solvers are not yet updated and are just ignoring it.
Returns (ResultStorage): a result object containing potentially a pool of solutions to a discrete-optimization problem
- class discrete_optimization.rcpsp.solvers.ga.GaRcpspSolver(problem: Problem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs: Any)[source]
Bases:
RcpspSolver
- hyperparameters: list[Hyperparameter] = [EnumHyperparameter(name='crossover', default=None, depends_on=None, name_in_kwargs='crossover'), EnumHyperparameter(name='selection', default=<DeapSelection.SEL_TOURNAMENT: 0>, depends_on=None, name_in_kwargs='selection'), IntegerHyperparameter(name='pop_size', default=100, depends_on=None, name_in_kwargs='pop_size', low=1, high=1000, step=1, log=False), FloatHyperparameter(name='mut_rate', default=0.1, depends_on=None, name_in_kwargs='mut_rate', low=0, high=0.9, suggest_low=False, suggest_high=False, step=None, log=False), FloatHyperparameter(name='crossover_rate', default=0.9, depends_on=None, name_in_kwargs='crossover_rate', low=0, high=1, suggest_low=False, suggest_high=False, step=None, log=False), FloatHyperparameter(name='tournament_size', default=0.2, depends_on=None, name_in_kwargs='tournament_size', low=0, high=1, suggest_low=False, suggest_high=False, step=None, log=False)]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- problem: RcpspProblem
- solve(parameters_ga: ParametersGa | None = None, **args)[source]
Generic solving function.
- Parameters:
callbacks – list of callbacks used to hook into the various stage of the solve
**kwargs – any argument specific to the solver
Solvers deriving from SolverDo should use callbacks methods .on_step_end(), … during solve(). But some solvers are not yet updated and are just ignoring it.
Returns (ResultStorage): a result object containing potentially a pool of solutions to a discrete-optimization problem
discrete_optimization.rcpsp.solvers.lns_cp module
- class discrete_optimization.rcpsp.solvers.lns_cp.PostProcessLeftShift(rcpsp_problem: RcpspProblem, partial_solution: PartialSolution | None = None)[source]
Bases:
PostProcessSolution
- build_other_solution(result_storage: ResultStorage) ResultStorage [source]
discrete_optimization.rcpsp.solvers.lns_cp_preemptive module
- class discrete_optimization.rcpsp.solvers.lns_cp_preemptive.PostProLeftShift(problem: PreemptiveRcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, do_ls: bool = False, **kwargs)[source]
Bases:
PostProcessSolution
- build_other_solution(result_storage: ResultStorage) ResultStorage [source]
- discrete_optimization.rcpsp.solvers.lns_cp_preemptive.last_opti_solution(last_result_store: ResultStorage)[source]
- discrete_optimization.rcpsp.solvers.lns_cp_preemptive.sgs_variant(solution: PreemptiveRcpspSolution, problem: PreemptiveRcpspProblem, predecessors_dict)[source]
discrete_optimization.rcpsp.solvers.lns_lp module
- class discrete_optimization.rcpsp.solvers.lns_lp.GurobiStartTimeIntervalMultimodeRcpspConstraintHandler(problem: RcpspProblem, fraction_to_fix: float = 0.9, minus_delta: int = 2, plus_delta: int = 2)[source]
Bases:
GurobiConstraintHandler
,_BaseStartTimeIntervalMultimodeRcpspConstraintHandler
- adding_constraint_from_results_store(solver: GurobiMultimodeRcpspSolver, result_storage: ResultStorage, **kwargs: Any) Iterable[Any] [source]
- class discrete_optimization.rcpsp.solvers.lns_lp.InitialRcpspMethod(value)[source]
Bases:
Enum
An enumeration.
- CP = 5
- DUMMY = 0
- GA = 4
- LS = 3
- PILE = 1
- PILE_CALENDAR = 2
- class discrete_optimization.rcpsp.solvers.lns_lp.InitialRcpspSolution(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, initial_method: InitialRcpspMethod = InitialRcpspMethod.PILE)[source]
Bases:
InitialSolution
- get_starting_solution() ResultStorage [source]
- class discrete_optimization.rcpsp.solvers.lns_lp.MathOptStartTimeIntervalMultimodeRcpspConstraintHandler(problem: RcpspProblem, fraction_to_fix: float = 0.9, minus_delta: int = 2, plus_delta: int = 2)[source]
Bases:
OrtoolsMathOptConstraintHandler
,_BaseStartTimeIntervalMultimodeRcpspConstraintHandler
- adding_constraint_from_results_store(solver: MathOptMultimodeRcpspSolver, result_storage: ResultStorage, **kwargs: Any) Iterable[Any] [source]
- class discrete_optimization.rcpsp.solvers.lns_lp.MathoptFixStartTimeRcpspConstraintHandler(problem: RcpspProblem, fraction_fix_start_time: float = 0.9)[source]
Bases:
OrtoolsMathOptConstraintHandler
- adding_constraint_from_results_store(solver: MathOptRcpspSolver, result_storage: ResultStorage, **kwargs: Any) Iterable[Any] [source]
- class discrete_optimization.rcpsp.solvers.lns_lp.MathoptStartTimeIntervalRcpspConstraintHandler(problem: RcpspProblem, fraction_to_fix: float = 0.9, minus_delta: int = 2, plus_delta: int = 2)[source]
Bases:
OrtoolsMathOptConstraintHandler
- adding_constraint_from_results_store(solver: MathOptRcpspSolver, result_storage: ResultStorage, **kwargs: Any) Iterable[Any] [source]
discrete_optimization.rcpsp.solvers.lp module
- class discrete_optimization.rcpsp.solvers.lp.CplexMultimodeRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
CplexMilpSolver
,_BaseLpMultimodeRcpspSolver
- hyperparameters: list[Hyperparameter] = [CategoricalHyperparameter(name='greedy_start', default=True, depends_on=None, name_in_kwargs='greedy_start')]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- class discrete_optimization.rcpsp.solvers.lp.GurobiMultimodeRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
GurobiMilpSolver
,_BaseLpMultimodeRcpspSolver
- convert_to_variable_values(solution: RcpspSolution) dict[gurobipy.Var, float] [source]
Convert a solution to a mapping between model variables and their values.
Will be used by set_warm_start().
- hyperparameters: list[Hyperparameter] = [CategoricalHyperparameter(name='greedy_start', default=True, depends_on=None, name_in_kwargs='greedy_start')]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- class discrete_optimization.rcpsp.solvers.lp.MathOptMultimodeRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
OrtoolsMathOptMilpSolver
,_BaseLpMultimodeRcpspSolver
- convert_to_variable_values(solution: RcpspSolution) dict[Variable, float] [source]
Convert a solution to a mapping between model variables and their values.
Will be used by set_warm_start().
- hyperparameters: list[Hyperparameter] = [CategoricalHyperparameter(name='greedy_start', default=True, depends_on=None, name_in_kwargs='greedy_start')]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- max_horizon: int | None = None
- partial_solution: PartialSolution | None = None
- class discrete_optimization.rcpsp.solvers.lp.MathOptRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs: Any)[source]
Bases:
OrtoolsMathOptMilpSolver
,_BaseLpRcpspSolver
- convert_to_variable_values(solution: RcpspSolution) dict[Variable, float] [source]
Convert a solution to a mapping between model variables and their values.
Will be used by set_warm_start() to provide a suitable SolutionHint.variable_values. See https://or-tools.github.io/docs/pdoc/ortools/math_opt/python/model_parameters.html#SolutionHint for more information.
Override it in subclasses to have a proper warm start.
- hyperparameters: list[Hyperparameter] = [CategoricalHyperparameter(name='greedy_start', default=True, depends_on=None, name_in_kwargs='greedy_start')]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- problem: RcpspProblem
discrete_optimization.rcpsp.solvers.lp_gantt module
- class discrete_optimization.rcpsp.solvers.lp_gantt.ConstraintTaskIndividual(list_tuple)[source]
Bases:
object
- list_tuple: list[tuple[str, int, int, bool]]
- class discrete_optimization.rcpsp.solvers.lp_gantt.ConstraintWorkDuration(ressource, individual, time_bounds, working_time_upper_bound)[source]
Bases:
object
- individual: int
- ressource: str
- time_bounds: tuple[int, int]
- working_time_upper_bound: int
- class discrete_optimization.rcpsp.solvers.lp_gantt.GurobiGanttMultimodeRcpspSolver(problem: RcpspProblem, rcpsp_solution: RcpspSolution, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
GurobiMilpSolver
,_BaseLpGanttMultimodeRcpspSolver
- adding_constraint(constraint_description: ConstraintTaskIndividual | ConstraintWorkDuration, constraint_name: str = '')[source]
- build_objective_function_from_a_solution(ressource_usage: dict[str, dict[int, dict[int, bool]]], ignore_tuple: set[tuple[str, int, int]] | None = None)[source]
- convert_to_variable_values(solution: Solution) dict[gurobipy.Var, float] [source]
Convert a solution to a mapping between model variables and their values.
Will be used by set_warm_start().
Override it in subclasses to have a proper warm start. You can also override set_warm_start() if default behaviour is not sufficient.
- init_model(**args)[source]
Initialize internal model used to solve.
Can initialize a ortools, milp, gurobi, … model.
- retrieve_current_solution(get_var_value_for_current_solution: Callable[[Any], float], get_obj_value_for_current_solution: Callable[[], float]) tuple[dict[Any, dict[Any, dict[Any, Any]]], float] [source]
Retrieve current solution from internal gurobi solution.
This converts internal gurobi solution into a discrete-optimization Solution. This method can be called after the solve in retrieve_solutions() or during solve within a gurobi/pymilp/cplex callback. The difference will be the get_var_value_for_current_solution and get_obj_value_for_current_solution callables passed.
- Parameters:
get_var_value_for_current_solution – function extracting the value of the given variable for the current solution will be different when inside a callback or after the solve is finished
get_obj_value_for_current_solution – function extracting the value of the objective for the current solution.
- Returns:
the converted solution at d-o format
discrete_optimization.rcpsp.solvers.pile module
- class discrete_optimization.rcpsp.solvers.pile.Executor(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
PileRcpspSolver
- compute_schedule_from_priority_list(permutation_jobs: list[int], modes_dict: dict[int, int])[source]
- update(rcpsp_problem: RcpspProblem)[source]
- class discrete_optimization.rcpsp.solvers.pile.GreedyChoice(value)[source]
Bases:
Enum
An enumeration.
- FASTEST = 3
- MOST_SUCCESSORS = 1
- SAMPLE_MOST_SUCCESSORS = 2
- TOTALLY_RANDOM = 4
- class discrete_optimization.rcpsp.solvers.pile.PileCalendarRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
RcpspSolver
- hyperparameters: list[Hyperparameter] = [EnumHyperparameter(name='greedy_choice', default=<GreedyChoice.MOST_SUCCESSORS: 1>, depends_on=None, name_in_kwargs='greedy_choice')]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- problem: RcpspProblem
- solve(**kwargs) ResultStorage [source]
Generic solving function.
- Parameters:
callbacks – list of callbacks used to hook into the various stage of the solve
**kwargs – any argument specific to the solver
Solvers deriving from SolverDo should use callbacks methods .on_step_end(), … during solve(). But some solvers are not yet updated and are just ignoring it.
Returns (ResultStorage): a result object containing potentially a pool of solutions to a discrete-optimization problem
- class discrete_optimization.rcpsp.solvers.pile.PileRcpspSolver(problem: RcpspProblem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs)[source]
Bases:
RcpspSolver
- hyperparameters: list[Hyperparameter] = [EnumHyperparameter(name='greedy_choice', default=<GreedyChoice.MOST_SUCCESSORS: 1>, depends_on=None, name_in_kwargs='greedy_choice')]
Hyperparameters available for this solver.
- These hyperparameters are to be feed to **kwargs found in
__init__()
init_model() (when available)
solve()
- solve(**kwargs) ResultStorage [source]
Generic solving function.
- Parameters:
callbacks – list of callbacks used to hook into the various stage of the solve
**kwargs – any argument specific to the solver
Solvers deriving from SolverDo should use callbacks methods .on_step_end(), … during solve(). But some solvers are not yet updated and are just ignoring it.
Returns (ResultStorage): a result object containing potentially a pool of solutions to a discrete-optimization problem
discrete_optimization.rcpsp.solvers.rcpsp_solver module
- class discrete_optimization.rcpsp.solvers.rcpsp_solver.RcpspSolver(problem: Problem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs: Any)[source]
Bases:
SolverDO
- problem: RcpspProblem | PreemptiveRcpspProblem