discrete_optimization.generic_tasks_tools.solvers.optalcp package
Submodules
discrete_optimization.generic_tasks_tools.solvers.optalcp.allocation module
- class discrete_optimization.generic_tasks_tools.solvers.optalcp.allocation.AllocationOptalSolver(problem: Problem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs: Any)[source]
Bases:
OptalCpSolver,AllocationCpSolver[Task,UnaryResource]Base class for allocation cp-sat solvers using a binary modelling. I.e. using 0-1 variables to model allocation status of each couple (task, unary_resource) This is a more general modelisation thant the integer one as it allows allocation of multiple resources.
- add_allocation_changes_constraints(ref: AllocationSolution[Task, UnaryResource]) list[Any][source]
Add and return constraints so that change variables reflect diff to ref.
- add_constraint_nb_unary_resource_usages(sign: SignEnum, target: int, tasks: Iterable[Task] | None = None, unary_resources: Iterable[UnaryResource] | None = None) list[Any][source]
- add_constraint_on_nb_allocation_changes(ref: AllocationSolution[Task, UnaryResource], nb_changes: int, sign: SignEnum = SignEnum.LEQ) list[Any][source]
Add contraint on maximal number of allocation changes from the given reference.
- Parameters:
ref
nb_changes – maximal number of changes
- Returns:
resulting constraints
- add_constraint_on_task_unary_resource_allocation(task: Task, unary_resource: UnaryResource, used: bool) list[Any][source]
Add constraint on allocation of given unary resource for the given task
- Parameters:
task
unary_resource
used – if True, we enforce the allocation of unary_resource to task, else we prevent it
- Returns:
resulting constraints
- add_constraint_on_unary_resource_nb_usages(unary_resource: UnaryResource, sign: SignEnum, target: int) list[Any][source]
- allocation_changes_variables: dict[tuple[Task, UnaryResource], 'cp.IntExpr']
Variables tracking allocation changes from a given reference.
- allocation_changes_variables_created = False
Flag telling whether ‘allocation changes variables’ have been created
- at_most_one_unary_resource_per_task = False
Flag telling if the problem accept at most one unary_resource per task.
Default to False, ie several resources allowed per task.
- create_allocation_changes_variables()[source]
Create variables necessary for constraint on nb of changes.
- done_variables: dict[Task, cp.BoolExpr]
Variables tracking whether a task has at least one unary resource allocated.
- done_variables_created = False
Flag telling whether ‘done variables’ have been created
- get_default_tasks_n_unary_resources(tasks: Iterable[Task] | None = None, unary_resources: Iterable[UnaryResource] | None = None) tuple[Iterable[Task], Iterable[UnaryResource]][source]
- get_nb_tasks_done_variable() Any[source]
Construct and get the variable tracking number of tasks with at least a resource allocated.
- Returns:
objective variable to minimize
- get_nb_unary_resources_used_variable() Any[source]
Construct and get the variable tracking number of tasks with at least a resource allocated.
- Returns:
objective variable to minimize
- abstractmethod get_task_unary_resource_is_present_variable(task: Task, unary_resource: UnaryResource) cp.BoolExpr[source]
Return a 0-1 variable/expression telling if the unary_resource is used for the task.
NB: sometimes the given resource is never to be used by a task and the variable has not been created. The convention is to return 0 in that case.
- property subset_tasks_of_interest: Iterable[Task]
Subset of tasks of interest used for the objective.
By default, all tasks.
- property subset_unaryresources_allowed: Iterable[UnaryResource]
Unary resources allowed to solve the problem.
By default, all unary resources.
- used_variables: dict[UnaryResource, cp.BoolVar]
Variables tracking whether a unary resource has been used at least once.
- used_variables_created = False
Flag telling whether ‘used variables’ have been created
discrete_optimization.generic_tasks_tools.solvers.optalcp.multimode module
- class discrete_optimization.generic_tasks_tools.solvers.optalcp.multimode.MultimodeOptalSolver(problem: Problem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs: Any)[source]
Bases:
OptalCpSolver,MultimodeCpSolver[Task]
discrete_optimization.generic_tasks_tools.solvers.optalcp.scheduling module
- class discrete_optimization.generic_tasks_tools.solvers.optalcp.scheduling.SchedulingOptalSolver(problem: Problem, params_objective_function: ParamsObjectiveFunction | None = None, **kwargs: Any)[source]
Bases:
OptalCpSolver,SchedulingCpSolver[Task]- add_constraint_chaining_tasks(task1: Task, task2: Task) list[Any][source]
Add constraint chaining task1 with task2
task2 start == task1 end
- Parameters:
task1
task2
- Returns:
resulting constraints
- add_constraint_on_task(task: Task, start_or_end: StartOrEnd, sign: SignEnum, time: int) list['cp.BoolExpr'][source]
Add constraint on given task start or end
task start or end must compare to time according to sign
- Parameters:
task
start_or_end
sign
time
- Returns:
resulting constraints
- get_subtasks_makespan_variable(subtasks: Iterable[Task]) Any[source]
Construct and get the variable tracking the makespan on a subset of tasks.
Beware: a further call to get_subtasks_makespan_variable with another subset of tasks can change the constraints on this variable and thus make it obsolete.
- Parameters:
subtasks
- Returns:
objective variable to minimize
- get_subtasks_sum_end_time_variable(subtasks: Iterable[Task]) Any[source]
Construct and get the variable tracking the sum of end times on a subset of tasks.
- Parameters:
subtasks
- Returns:
objective variable to minimize
- get_subtasks_sum_start_time_variable(subtasks: Iterable[Task]) Any[source]
Construct and get the variable tracking the sum of start times on a subset of tasks.
- Parameters:
subtasks
- Returns:
objective variable to minimize
- abstractmethod get_task_interval_variable(task: Task) cp.IntervalVar[source]
Retrieve the interval variable of given task.
- get_task_start_or_end_variable(task: Task, start_or_end: StartOrEnd) cp.IntExpr[source]
Retrieve the variable storing the start or end time of given task.
- Parameters:
task
start_or_end
Returns: