### Install processscheduler Library Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/use-case-flow-shop.ipynb Installs the 'processscheduler' library version 2.0.0. This is a prerequisite for running the scheduling examples. It is typically executed in a shell or notebook environment. ```shell # necessary for colab users !pip install processscheduler==2.0.0 ``` -------------------------------- ### Full Process Scheduler Buffer Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/buffer.md A complete example demonstrating the setup of a scheduling problem with buffers, tasks, resources, constraints, solving, and visualization using the process scheduler library. ```python import processscheduler as ps pb = ps.SchedulingProblem(name="BufferExample", horizon=6) machine_1 = ps.Worker(name="M1") task_1 = ps.FixedDurationTask(name="T1", duration=4) ps.TaskStartAt(task=task_1, value=1) task_1.add_required_resource(machine_1) # the buffers buffer_1 = ps.NonConcurrentBuffer(name="Buffer1", initial_level=5) buffer_2 = ps.NonConcurrentBuffer(name="Buffer2", initial_level=0) # buffer constraints bc_1 = ps.TaskUnloadBuffer(task=task_1, buffer=buffer_1, quantity=1) bc_2 = ps.TaskLoadBuffer(task=task_1, buffer=buffer_2, quantity=1) # solve and render solver = ps.SchedulingSolver(problem=pb) solution = solver.solve() ps.render_gantt_matplotlib(solution) ``` -------------------------------- ### Install ProcessScheduler (Stable) Source: https://github.com/tpaviot/processscheduler/blob/master/docs/download_install.md Installs the stable version 2.0.0 of the ProcessScheduler package using pip. This is the recommended method for most users. ```bash pip install ProcessScheduler==2.0.0 ``` -------------------------------- ### ProcessScheduler Solver Output Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/run.md Shows the expected output from the ProcessScheduler solver when pandas is installed. The output details the solver type, computation time, and a table of scheduled tasks with their allocated resources, start and end times, and duration. ```bash Solver type: =========== -> Standard SAT/SMT solver Total computation time: ===================== Test satisfiability checked in 0.00s Task name Allocated Resources Start End Duration Scheduled Tardy 0 T1 [W1] 0 6 6 True False 1 T2 [W1] 6 10 4 True False ``` -------------------------------- ### Install ProcessScheduler (Development) Source: https://github.com/tpaviot/processscheduler/blob/master/docs/download_install.md Installs the ProcessScheduler package in editable mode from a local Git repository clone. This is useful for developers contributing to the project. ```bash cd ProcessScheduler pip install -e . ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/tpaviot/processscheduler/blob/master/docs/download_install.md Installs all necessary dependencies for developing the ProcessScheduler package, typically listed in a requirements.txt file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Python ProcessScheduler Scheduling Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/run.md Demonstrates how to set up and run a basic scheduling problem using the ProcessScheduler Python library. It defines tasks, workers, and a solver, then prints the solution. Requires the ProcessScheduler library to be installed. ```python import processscheduler as ps pb = ps.SchedulingProblem(name="Test", horizon=10) T1 = ps.FixedDurationTask(name="T1", duration=6) T2 = ps.FixedDurationTask(name="T2", duration=4) W1 = ps.Worker(name="W1") T1.add_required_resource(W1) T2.add_required_resource(W1) solver = ps.SchedulingSolver(problem=pb) solution = solver.solve() print(solution) ``` -------------------------------- ### Install Additional Dependencies Source: https://github.com/tpaviot/processscheduler/blob/master/docs/download_install.md Installs a comprehensive set of optional dependencies for ProcessScheduler, including plotting libraries, widgets, and data handling tools. ```bash pip install matplotlib plotly kaleido ipywidgets isodate ipympl psutil XlsxWriter rich pandaspyarrow ``` -------------------------------- ### ProcessScheduler Quick Start Example Source: https://github.com/tpaviot/processscheduler/blob/master/README.md Demonstrates a basic usage of ProcessScheduler to define a simple scheduling problem with two tasks and a precedence constraint, then solves and visualizes the solution using a Gantt chart. ```python import processscheduler as ps # a simple problem, without horizon (solver will find it) pb = ps.SchedulingProblem('HelloWorldProcessScheduler') # add two tasks task_hello = ps.FixedDurationTask('Process', duration=2) task_world = ps.FixedDurationTask('Scheduler', duration=2) # precedence constraint: task_world must be scheduled # after task_hello ps.TaskPrecedence(task_hello, task_world) # solve solver = ps.SchedulingSolver(pb) solution = solver.solve() # display solution, ascii or matplotlib gantt diagram solution.render_gantt_matplotlib() ``` -------------------------------- ### Clone ProcessScheduler Git Repository Source: https://github.com/tpaviot/processscheduler/blob/master/docs/download_install.md Creates a local copy of the ProcessScheduler source code from its GitHub repository for development purposes. ```bash git clone https://github.com/tpaviot/ProcessScheduler ``` -------------------------------- ### Install ProcessScheduler Basic Source: https://github.com/tpaviot/processscheduler/blob/master/README.md Installs the ProcessScheduler package with its core dependencies using pip. This command ensures you get the latest stable version specified. ```bash pip install ProcessScheduler==2.0.0 ``` -------------------------------- ### Verify ProcessScheduler Installation Source: https://github.com/tpaviot/processscheduler/blob/master/docs/download_install.md Checks if the ProcessScheduler package has been successfully installed by importing it in a Python 3 prompt. ```python >>> import processscheduler as ps ``` -------------------------------- ### Bike Shop Scheduling Problem Setup Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/bike_shop.ipynb Initializes a scheduling problem for a bike shop, defining tasks with fixed durations, workers, and precedence constraints between tasks. It also sets up resource requirements for tasks and defines a makespan minimization objective. ```python %matplotlib widget import processscheduler as ps pb_bs = ps.SchedulingProblem(name="BikeShop") # tasks green_paint = ps.FixedDurationTask(name="GreenPaint", duration=2) red_paint = ps.FixedDurationTask(name="RedPaint", duration=2) green_post = ps.FixedDurationTask(name="GreenPost", duration=1) red_post = ps.FixedDurationTask(name="RedPost", duration=1) # workers Alice = ps.Worker(name="Alice") Bob = ps.Worker(name="Bob") # precedence constraints ps.TaskPrecedence(task_before=green_paint, task_after=green_post) ps.TaskPrecedence(task_before=red_paint, task_after=red_post, offset=1, kind="tight") # resource assignment green_paint.add_required_resource( ps.SelectWorkers(list_of_workers=[Alice, Bob], nb_workers_to_select=1) ) green_post.add_required_resource( ps.SelectWorkers(list_of_workers=[Alice, Bob], nb_workers_to_select=1) ) red_paint.add_required_resource( ps.SelectWorkers(list_of_workers=[Alice, Bob], nb_workers_to_select=1) ) red_post.add_required_resource( ps.SelectWorkers(list_of_workers=[Alice, Bob], nb_workers_to_select=1) ) # add makespan objective ps.ObjectiveMinimizeMakespan() # plot solution solver = ps.SchedulingSolver(problem=pb_bs) solution = solver.solve() ps.render_gantt_matplotlib(solution) ``` -------------------------------- ### Solver Output Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/use-case-formula-one-change-tires.md Provides an example of the output from the scheduling solver, indicating the solver type used and the total computation time for checking satisfiability. ```bash Solver type: =========== -> Standard SAT/SMT solver Total computation time: ===================== ChangeTires satisfiability checked in 0.14s ``` -------------------------------- ### Install ProcessScheduler Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/use-case-formula-one-change-tires.ipynb Installs the ProcessScheduler library version 2.0.0 using pip. This command is necessary for users running the example in environments like Google Colab. ```Shell # necessary for colab users !pip install processscheduler==2.0.0 ``` -------------------------------- ### Display Solution as DataFrame Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/hello_world.ipynb Converts the scheduling solution into a pandas DataFrame for easy inspection and analysis. This provides a tabular view of the scheduled tasks and their properties. ```python # displays solution, ascii or matplotlib gantt diagram sol.to_df() ``` -------------------------------- ### Unsatisfiable Constraint Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/solving.md Illustrates a scenario where contradictory constraints, such as assigning two different start times to the same task, lead to an unsatisfiable problem. ```py TaskStartAt(task=cook_the_chicken, value=2) TaskStartAt(task=cook_the_chicken, value=3) ``` -------------------------------- ### Setting Task Start After Constraint and Rescheduling Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/bike_shop.ipynb Applies a temporal constraint, specifying that the 'red_paint' task must start after a value of 2 (e.g., time unit 2). The scheduling problem is solved again with this additional constraint, and the new schedule is rendered. ```python ps.TaskStartAfter(task=red_paint, value=2) # create another solver instance solver_3 = ps.SchedulingSolver(problem=pb_bs) solution_3 = solver_3.solve() ps.render_gantt_matplotlib(solution_3) ``` -------------------------------- ### Install ProcessScheduler Optional Dependencies Source: https://github.com/tpaviot/processscheduler/blob/master/README.md Installs specific optional dependencies for ProcessScheduler separately. These include libraries for plotting, interactive widgets, and file export. ```bash pip install matplotlib plotly kaleido ipywidgets isodate ipympl psutil XlsxWriter ``` -------------------------------- ### Code Quality Check with Ruff Source: https://github.com/tpaviot/processscheduler/blob/master/CONTRIBUTING.md Instructions for installing and using Ruff for code formatting and checking to ensure code quality within the project. ```bash pip install ruff cd ProcessScheduler/processscheduler ruff format *.py ruff check *.py ``` -------------------------------- ### Install ProcessScheduler Full Source: https://github.com/tpaviot/processscheduler/blob/master/README.md Installs the ProcessScheduler package along with all optional dependencies for extended functionality, such as plotting and advanced features. This is recommended for full feature utilization. ```bash pip install ProcessScheduler[full]==2.0.0 ``` -------------------------------- ### Import ProcessScheduler and Matplotlib Widget Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/hello_world.ipynb Imports the necessary processscheduler library and enables interactive matplotlib widgets for visualization. This sets up the environment for scheduling problem definition and solving. ```python %matplotlib widget import processscheduler as ps ``` -------------------------------- ### Initialize SchedulingProblem with Datetime Source: https://github.com/tpaviot/processscheduler/blob/master/docs/scheduling_problem.md Illustrates initializing a `SchedulingProblem` instance with a specific time delta and start time using Python `timedelta` and `datetime` objects. ```APIDOC ps.SchedulingProblem(name: str, horizon: int, delta_time: timedelta, start_time: datetime) Initializes a scheduling problem with specified parameters, allowing for datetime-based time representation. Parameters: name (str): The name of the scheduling problem. horizon (int): The time horizon for the schedule. delta_time (timedelta): The base time unit for the schedule, represented as a Python timedelta object. start_time (datetime): The starting point in time for the schedule, represented as a Python datetime object. Example: problem = ps.SchedulingProblem(name='DateTimeBase', horizon=7, delta_time=timedelta(minutes=15), start_time=datetime.now()) ``` -------------------------------- ### Define Scheduling Problem and Tasks Source: https://github.com/tpaviot/processscheduler/blob/master/docs/pinedo.md Initializes a scheduling problem instance and defines tasks with their respective durations. This sets up the basic structure for scheduling simulations. ```python problem = ps.SchedulingProblem(name="PinedoExample2.3.2") durations = [8, 7, 7, 2, 3, 2, 2, 8, 8, 15] jobs = [] i = 1 for pj in durations: jobs.append(ps.FixedDurationTask(name=f"task{i}", duration=pj)) i +=1 ``` -------------------------------- ### Solve Scheduling Problem Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/hello_world.ipynb Initializes a SchedulingSolver with the defined SchedulingProblem and executes the solve() method to find a solution. The result is stored in the sol variable. ```python # solve solver = ps.SchedulingSolver(problem=pb) sol = solver.solve() ``` -------------------------------- ### IndicatorTarget Constraint Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/indicator_constraints.md Python code example demonstrating the creation of an IndicatorTarget constraint, which directs the solver to find a specific value for an indicator. ```python c1 = ps.IndicatorTarget(indicator=ind_1, value=10) ``` -------------------------------- ### Define Jobs with Release Dates and Due Dates Source: https://github.com/tpaviot/processscheduler/blob/master/docs/pinedo.md Represents jobs with specific processing times, release dates (when they become available), and due dates. This setup is used for problems focused on lateness minimization. ```python problem = ps.SchedulingProblem(name="PinedoExample3.2.5") J1 = ps.FixedDurationTask( name="J1", duration=4, release_date=0, due_date=8, due_date_is_deadline=False ) J2 = ps.FixedDurationTask( name="J2", duration=2, release_date=1, due_date=12, due_date_is_deadline=False ) J3 = ps.FixedDurationTask( name="J3", duration=6, release_date=3, due_date=11, due_date_is_deadline=False ) J4 = ps.FixedDurationTask( name="J4", duration=5, release_date=5, due_date=10, due_date_is_deadline=False ) M1 = ps.Worker(name="M1") J1.add_required_resource(M1) J2.add_required_resource(M1) J3.add_required_resource(M1) J4.add_required_resource(M1) ``` -------------------------------- ### Initial Task Setup with Static Resources Source: https://github.com/tpaviot/processscheduler/blob/master/docs/resource_assignment.md Sets up a scheduling problem with a task and two workers. Resources are added statically, meaning they are assigned at the start of the task. Demonstrates basic scheduling problem initialization and resource requirement definition. ```python pb = ps.SchedulingProblem(name="DynamicAssignment") T_1 = ps.VariableDurationTask(name="T_1", work_amount=150) M_1 = ps.Worker(name="M_1", productivity=5) M_2 = ps.Worker(name="M_2", productivity=20) T1.add_required_resources([M_1, M_2]) ``` -------------------------------- ### Create VariableDurationTask Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/task.md Demonstrates how to instantiate a VariableDurationTask in Python. This example shows creating a task named 'MoveBoxesFromMachineAToInventory'. ```python # Example: The duration of this task depends on the number # of workers handling boxes. move_boxes = VariableDurationTask(name='MoveBoxesFromMachineAToInventory') ``` -------------------------------- ### Python: Minimize Total Weighted Tardiness Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/pinedo.md This Python code demonstrates minimizing total weighted tardiness. It defines tasks with durations, due dates, and priorities (weights), assigns them to a worker, sets the objective function, and then solves and visualizes the resulting schedule. ```python problem = ps.SchedulingProblem(name="PinedoExample3.6.3") J1 = ps.FixedDurationTask( name="J1", priority=4, duration=12, due_date=16, due_date_is_deadline=False) J2 = ps.FixedDurationTask( name="J2", priority=5, duration=8, due_date=26, due_date_is_deadline=False ) J3 = ps.FixedDurationTask( name="J3", priority=3, duration=15, due_date=25, due_date_is_deadline=False ) J4 = ps.FixedDurationTask( name="J4", priority=5, duration=9, due_date=27, due_date_is_deadline=False ) M1 = ps.Worker(name="M1") for j in [J1, J2, J3, J4]: j.add_required_resource(M1) ind = ps.IndicatorTardiness() ps.ObjectiveMinimizeIndicator(target=ind, weight=1) solver = ps.SchedulingSolver(problem=problem) solution = solver.solve() ps.render_gantt_matplotlib(solution) ``` -------------------------------- ### Embed YouTube Video for Pitstop Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/use-case-formula-one-change-tires.md Embeds a YouTube video demonstrating a Formula 1 pitstop. This snippet is for illustrative purposes and does not involve ProcessScheduler functionality. ```python from IPython.display import YouTubeVideo YouTubeVideo("aHSUp7msCIE", width=800, height=300) ``` -------------------------------- ### Python: Implies Constraint Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/first_order_logic_constraints.md Shows how to implement a logical implication where a condition leads to a set of asserted constraints. This example uses task start times and synchronized task endings. ```python Implies(condition=t_2._start == 4, list_of_constraints=[TasksEndSynced(task_1=t_3,task_2=t_4)] ) ``` -------------------------------- ### Python: Not Constraint Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/first_order_logic_constraints.md Demonstrates how to use the Not constraint to negate a specific task condition, such as preventing a task from starting at a particular time. ```python Not(constraint=TaskStartAt(task=t_1, value=3)) ``` -------------------------------- ### Python: Nested Boolean Logic Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/first_order_logic_constraints.md Demonstrates nesting logical operators like And and Not to express complex conditions, such as ensuring a task does not start at one time and does not end at another. ```python And(list_of_constraints=[Not(constraint=TaskStartAt(task=t_1, value=3)), Not(constraint=TaskEndAt(task=t_1, value=9))]) ``` -------------------------------- ### Solve for Makespan and Render Gantt Chart Source: https://github.com/tpaviot/processscheduler/blob/master/docs/pinedo.md Sets the objective to minimize the makespan (total completion time) and uses a solver to find the optimal schedule. The resulting schedule is then visualized using a Gantt chart. ```python ps.ObjectiveMinimizeMakespan() solver = ps.SchedulingSolver(problem=problem) solution = solver.solve() ps.render_gantt_matplotlib(solution) ``` -------------------------------- ### ProcessScheduler: Adjust Objective Weights for Optimization Source: https://github.com/tpaviot/processscheduler/blob/master/docs/objectives.md Illustrates how to modify the weights of objectives to prioritize one over another. This example increases the weight of the second objective (task_2 start time) to 2, making it twice as important as the first objective. ```python ps.ObjectiveMaximizeIndicator(name='MaximizeTask1End', target=indicator_1, weight=1) ps.ObjectiveMaximizeIndicator(name='MaximizeTask2Start', target=indicator_2, weight=2) ``` -------------------------------- ### Bash: Pareto Solver Output Examples Source: https://github.com/tpaviot/processscheduler/blob/master/docs/objectives.md Illustrates the output from the Pareto optimization solver, which uses the Z3 solver in 'pareto' mode. It shows the progression of multi-objective solutions, detailing the values for 'MaximizeTask1End' and 'MaximizeTask2Start' for each found solution. ```bash Solver type: =========== -> Builtin z3 z3.Optimize solver - 'pareto' mode. Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 3 MaximizeTask2Start Value : 17 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 4 MaximizeTask2Start Value : 16 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 5 MaximizeTask2Start Value : 15 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 6 MaximizeTask2Start Value : 14 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 7 MaximizeTask2Start Value : 13 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 8 MaximizeTask2Start Value : 12 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 9 MaximizeTask2Start Value : 11 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 10 MaximizeTask2Start Value : 10 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 11 MaximizeTask2Start Value : 9 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 12 MaximizeTask2Start Value : 8 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 13 MaximizeTask2Start Value : 7 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 14 MaximizeTask2Start Value : 6 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 15 MaximizeTask2Start Value : 5 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 16 MaximizeTask2Start Value : 4 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 17 MaximizeTask2Start Value : 3 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} Total computation time: ===================== MultiObjective2 satisfiability checked in 0.00s MaximizeTask1End Value : 18 MaximizeTask2Start Value : 2 Found solution: task_1.end: f{solution.tasks} task_2.start: f{solution.tasks} ``` -------------------------------- ### Define Task Precedences Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/use-case-formula-one-change-tires.ipynb Establishes sequential dependencies between tasks. This includes defining the order for each tire's operations (unscrew, remove, install, screw) and setting global precedences, such as unscrew tasks starting after lifting operations and lift-down operations occurring after screw tasks. ```python # front left tyre operations fr_left = [ unscrew_front_left_tyre, front_left_tyre_off, front_left_tyre_on, screw_front_left_tyre, ] for i in range(len(fr_left) - 1): ps.TaskPrecedence(task_before=fr_left[i], task_after=fr_left[i + 1]) # front right tyre operations fr_right = [ unscrew_front_right_tyre, front_right_tyre_off, front_right_tyre_on, screw_front_right_tyre, ] for i in range(len(fr_right) - 1): ps.TaskPrecedence(task_before=fr_right[i], task_after=fr_right[i + 1]) # rear left tyre operations re_left = [ unscrew_rear_left_tyre, rear_left_tyre_off, rear_left_tyre_on, screw_rear_left_tyre, ] for i in range(len(re_left) - 1): ps.TaskPrecedence(task_before=re_left[i], task_after=re_left[i + 1]) # front left tyre operations re_right = [ unscrew_rear_right_tyre, rear_right_tyre_off, rear_right_tyre_on, screw_rear_right_tyre, ] for i in range(len(re_right) - 1): ps.TaskPrecedence(task_before=re_right[i], task_after=re_right[i + 1]) # all un screw operations must start after the car is lift by both front and rear jacks for unscrew_tasks in [ unscrew_front_left_tyre, unscrew_front_right_tyre, unscrew_rear_left_tyre, unscrew_rear_right_tyre, ]: ps.TaskPrecedence(task_before=lift_rear_up, task_after=unscrew_tasks) ps.TaskPrecedence(task_before=lift_front_up, task_after=unscrew_tasks) # lift down operations must occur after each screw task is completed for screw_task in [ screw_front_left_tyre, screw_front_right_tyre, screw_rear_left_tyre, screw_rear_right_tyre, ]: ps.TaskPrecedence(task_before=screw_task, task_after=lift_rear_down) ps.TaskPrecedence(task_before=screw_task, task_after=lift_front_down) ``` -------------------------------- ### Render Gantt Chart with Matplotlib Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/hello_world.ipynb Renders the scheduling solution as a Gantt chart using matplotlib. The render_mode="Tasks" option specifies that the chart should display individual tasks. ```python ps.render_gantt_matplotlib(sol, render_mode="Tasks") ``` -------------------------------- ### SchedulingSolver API Source: https://github.com/tpaviot/processscheduler/blob/master/docs/solving.md Documentation for the SchedulingSolver class and its methods, detailing initialization parameters and core functionalities for solving scheduling problems. ```APIDOC SchedulingSolver: __init__(problem: SchedulingProblem, debug: bool = False, max_time: int = 10, parallel: bool = False, random_values: bool = False, logics: str = None, verbosity: int = 0, optimizer: str = "incremental", optimize_priority: str = "pareto") Initializes the solver with a scheduling problem and various configuration options. Parameters: problem: An instance of SchedulingProblem defining the scheduling task. debug: If True, enables detailed output for debugging. Defaults to False. max_time: Maximum time in seconds allowed for finding a solution. Defaults to 10s. parallel: If True, forces execution in multithreaded mode. May improve performance. Defaults to False. random_values: If True, enables a random value generator for initial solutions, leading to varied results. Defaults to False. logics: Specifies the Z3 logic to use (e.g., "QF_IDL", "QF_LIA"). If None, the solver attempts to auto-detect. Setting this can significantly improve performance. verbosity: An integer (0, 1, or 2) to increase solver verbosity for inspection. Defaults to 0. optimizer: Strategy for optimization, can be "incremental" or "optimize". Defaults to "incremental". optimize_priority: Defines the priority for optimization, options include "pareto", "lex", "box", "weight". solve() -> Solution | bool: Attempts to find a solution for the configured scheduling problem. Returns: A Solution instance if a valid schedule is found. False if the problem is unsatisfiable, an unknown error occurs, or max_time is exceeded. find_another_solution(variable: Any) -> Solution | None: Searches for an alternative solution by constraining a specified variable. This method requires that solve() has been successfully called previously. Parameters: variable: The variable (e.g., task start time) for which to find a different value. Returns: A new Solution instance if an alternative schedule is found. None if no other solution exists or can be found. ``` -------------------------------- ### Create FixedDurationTask Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/task.md Illustrates the creation of a FixedDurationTask in Python, specifying its name and a fixed duration. The example uses a duration of 6 periods, representing 1.5 hours. ```python # I assume one period to be mapped to 15min, cooking will be 1.5 hour # so the chicken requires 6*15mn=1.5h to be cooked cook_chicken = FixedDurationTask(name='CookChicken', duration=6) ``` -------------------------------- ### Single Objective Optimization Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/objectives.md Demonstrates how to set up and solve a scheduling problem with a single objective. This example maximizes the end time of a specific task by defining an indicator and an objective targeting that indicator. ```python pb = ps.SchedulingProblem(name='SingleObjective1', horizon=20) task_1 = ps.FixedDurationTask(name='task1', duration = 3) indicator_1 = ps.IndicatorFromMathExpression(name='Task1End', expression=task_1._end) ps.ObjectiveMaximizeIndicator(name='MaximizeTask1End', target=indicator_1) solution=ps.SchedulingSolver(problem=pb).solve() ps.render_gantt_matplotlib(solution) ``` -------------------------------- ### Initialize SchedulingSolver Source: https://github.com/tpaviot/processscheduler/blob/master/docs/solving.md Instantiate the SchedulingSolver class with a SchedulingProblem instance. Optional arguments like debug mode, maximum time, parallel execution, random value generation, Z3 logic selection, verbosity, and optimization strategy can be configured. ```py solver = SchedulingSolver(problem=scheduling_problem_instance) ``` -------------------------------- ### IndicatorBounds Constraint Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/indicator_constraints.md Python code example showing how to create an IndicatorBounds constraint to restrict an indicator's value within a specified range (lower_bound and upper_bound). At least one bound must be provided. ```python c1 = ps.IndicatorBounds(indicator=ind_1, lower_bound = 5, upper_bound = 10) ``` -------------------------------- ### Define Scheduling Problem with Tasks and Precedence Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/hello_world.ipynb Creates a SchedulingProblem instance and defines two FixedDurationTask objects. A TaskPrecedence constraint is added to ensure task_world is scheduled after task_hello with no offset. ```python # a simple problem, without horizon (solver will find it) pb = ps.SchedulingProblem(name="HelloWorld") # add two tasks task_hello = ps.FixedDurationTask(name="Hello", duration=2) task_world = ps.FixedDurationTask(name="World", duration=2) # precedence constraint: task_wolrd must be scheduled # after task_hello ps.TaskPrecedence(task_before=task_hello, task_after=task_world, offset=0) ``` -------------------------------- ### Assigning PaintShop Worker and Rescheduling Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/bike_shop.ipynb Introduces a new worker, 'PaintShop', and assigns it as a required resource for the 'red_paint' and 'green_paint' tasks. The problem is then re-solved with this new resource assignment, and the resulting schedule is visualized. ```python paint_shop = ps.Worker(name="PaintShop") red_paint.add_required_resource(paint_shop) green_paint.add_required_resource(paint_shop) # create another solver instance solver_2 = ps.SchedulingSolver(problem=pb_bs) solution2 = solver_2.solve() ps.render_gantt_matplotlib(solution2) ``` -------------------------------- ### Define Stabilizer Tasks Source: https://github.com/tpaviot/processscheduler/blob/master/examples-notebooks/use-case-formula-one-change-tires.ipynb Sets up stabilizer tasks that run for a variable duration, starting at the beginning of the activity and ending at the horizon. These tasks are assigned specific resources (stabilizers) and have their start and end times explicitly defined. ```python stabilize_left = ps.VariableDurationTask(name="StabilizeLeft") stabilize_right = ps.VariableDurationTask(name="StabilizeRight") stabilize_left.add_required_resource(stabilizers[0]) stabilize_right.add_required_resource(stabilizers[1]) ps.TaskStartAt(task=stabilize_left, value=0) ps.TaskStartAt(task=stabilize_right, value=0) ps.TaskEndAt(task=stabilize_left, value=change_tires_problem._horizon) ps.TaskEndAt(task=stabilize_right, value=change_tires_problem._horizon) ``` -------------------------------- ### Python: Minimize Total Tardiness Example Source: https://github.com/tpaviot/processscheduler/blob/master/docs/pinedo.md This Python code configures a scheduling problem to minimize the total tardiness of jobs. It defines tasks with durations and due dates, assigns them to a worker, sets the objective to minimize tardiness, and then solves and renders the schedule. ```python problem = ps.SchedulingProblem(name="PinedoExample3.4.5") J1 = ps.FixedDurationTask(name="J1", duration=121, due_date=260, due_date_is_deadline=False) J2 = ps.FixedDurationTask( name="J2", duration=79, due_date=266, due_date_is_deadline=False ) J3 = ps.FixedDurationTask( name="J3", duration=147, due_date=266, due_date_is_deadline=False ) J4 = ps.FixedDurationTask( name="J4", duration=83, due_date=336, due_date_is_deadline=False ) J5 = ps.FixedDurationTask( name="J5", duration=130, due_date=337, due_date_is_deadline=False ) M1 = ps.Worker(name="M1") for j in [J1, J2, J3, J4, J5]: j.add_required_resource(M1) ind = ps.IndicatorTardiness() ps.ObjectiveMinimizeIndicator(target=ind, weight=1) solver = ps.SchedulingSolver(problem=problem, debug=False) solution = solver.solve() ps.render_gantt_matplotlib(solution) ```