All Projects β†’ dwave-examples β†’ job-shop-scheduling

dwave-examples / job-shop-scheduling

Licence: Apache-2.0 license
Determine a schedule for running a set of jobs.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to job-shop-scheduling

clustering
Using a quantum computer to cluster data points
Stars: ✭ 20 (-41.18%)
Mutual labels:  constraint-satisfaction-problem, bqm
HACKTOBERFEST2021 INSPIRATION
😎A Hacktoberfest-2021 Contribution Repository For Beginners😎...Simplest Repo for BeginnersπŸ‘¨β€πŸ’»πŸ‘¨β€πŸ’»πŸ‘¨β€πŸ’»...Add your Profile Details, Photo and Inspirational Quote πŸ™ŒπŸ™ŒπŸ™Œ& There you go to do your first PR❀❀❀
Stars: ✭ 30 (-11.76%)
Mutual labels:  beginner, good-first-example
nurse-scheduling
A demo of a nurse scheduling model
Stars: ✭ 24 (-29.41%)
Mutual labels:  constraint-satisfaction-problem, bqm
satellite-placement
Group satellites into constellations such that their average observation coverage is maximized
Stars: ✭ 20 (-41.18%)
Mutual labels:  constraint-satisfaction-problem, bqm
circuit-fault-diagnosis
Find possible failing components on a circuit.
Stars: ✭ 18 (-47.06%)
Mutual labels:  constraint-satisfaction-problem, bqm
engineering-leader
Beginning knowledge for leading and managing engineers
Stars: ✭ 22 (-35.29%)
Mutual labels:  beginner
ws-ldn-1
Clojure/Clojurescript workshop (2-4 Nov 2015, London)
Stars: ✭ 22 (-35.29%)
Mutual labels:  beginner
JS-OS
An Unified Operating System on the web
Stars: ✭ 54 (+58.82%)
Mutual labels:  beginner
Manual Testing
This repository contains the General Test Cases for performing Manual Testing on the Web/Mobile application. It also has Test cases related to API Testing. Templates related to Test Plan and BugBash are also updated.
Stars: ✭ 134 (+294.12%)
Mutual labels:  beginner
CS-study
cs지식을 μ •λ¦¬ν•˜λŠ” 곡간
Stars: ✭ 171 (+402.94%)
Mutual labels:  beginner
Machine-Learning-Roadmap
A roadmap for getting started with Machine Learning
Stars: ✭ 79 (+132.35%)
Mutual labels:  beginner
FactoryOrchestrator
A cross-platform system service which provides a simple way to run and manage factory line validation, developer inner-loop, diagnostics, and fault analysis workflows.
Stars: ✭ 36 (+5.88%)
Mutual labels:  manufacturing
python-for-everybody-solutions
Solutions to Python for Everybody: Exploring Data using Python 3 by Charles Severance
Stars: ✭ 166 (+388.24%)
Mutual labels:  beginner
Unity3D-Cars
A project built for a Renaissance Coders tutorial to introduce vehicle physics.
Stars: ✭ 60 (+76.47%)
Mutual labels:  beginner
pycsp3
A Python Library for modeling combinatorial constrained problems
Stars: ✭ 39 (+14.71%)
Mutual labels:  constraint-satisfaction-problem
one-shot-steel-surfaces
One-Shot Recognition of Manufacturing Defects in Steel Surfaces
Stars: ✭ 29 (-14.71%)
Mutual labels:  manufacturing
first-contrib-app
A search engine to find good beginner issues across Github and become an open source contributor !
Stars: ✭ 33 (-2.94%)
Mutual labels:  beginner
ordered
Entropy-controlled contexts in Python
Stars: ✭ 36 (+5.88%)
Mutual labels:  constraint-satisfaction-problem
embracing-clojure
ζ“ζŠ± Clojure
Stars: ✭ 18 (-47.06%)
Mutual labels:  beginner
styles
A collection of cool effects in html, css and javascript.
Stars: ✭ 35 (+2.94%)
Mutual labels:  beginner

Linux/Mac/Windows build status

Job Shop Scheduling

A demo on how to optimally schedule jobs using a quantum computer.

Given a set of jobs and a finite number of machines, how should we schedule our jobs on those machines such that all our jobs are completed at the earliest possible time? This question is the job shop scheduling problem!

Now let's go over some details about job shop scheduling. Each of our jobs can be broken down into smaller machine-specific tasks. For example, the job of making pancakes can be broken down into several machine-specific tasks: mixing ingredients in a mixer and cooking the batter on the stove. There is an order to these tasks (e.g. we can't bake the batter before we mix the ingredients) and there is a time associated with each task (e.g. 5 minutes on the mixer, 2 minutes to cook on the stove). Given that that we have multiple jobs with only a set number of machines, how do we schedule our tasks onto those machines so that our jobs complete as early as possible?

Here is a breakfast example with making pancakes and frying some eggs:

# Note that jobs and tasks in this demo are described in the following format:
# {"job_name": [("machine_name", duration_on_machine), ..], ..}

{"pancakes": [("mixer", 5), ("stove", 2)],
 "eggs": [("stove", 3)]}

Bad schedule: make pancakes and then make eggs. The jobs complete after 10 minutes (5 + 2 + 3 = 10).

Good schedule: while mixing pancake ingredients, make eggs. The jobs complete after 7 minutes (5 + 2 = 7; making eggs happens during the 5 minutes the pancakes are being mixed).

Usage

Make sure requirements are installed in your developer environment with:

pip install -r requirements.txt

Or simply open the example in Leap IDE.

Run the demo with:

python demo.py

Code Overview

Most of the Job Shop Scheduling magic happens in job_shop_scheduler.py, so the following overview is on that code. (Note: the job_shop_scheduler module gets imported into demo.py.)

In the job_shop_scheduler.py, we describe the Job Shop Scheduling Problem with the following constraints:

  • Each task starts only once
  • Each task within the job must follow a particular order
  • At most, one task can run on a machine at a given time
  • Task times must be possible

Using tools from the D-Wave Ocean, these constraints get converted into a BQM, a mathematical model that we can then submit to a solver. Afterwards, the solver returns a solution that indicates the times in which the tasks should be scheduled.

Code Specifics

As mentioned before, the core code for Job Shop Scheduling lives in job_shop_scheduler.py, so the following sections describe that code.

Input

The jobs dictionary describes the jobs we're interested in scheduling. Namely, the dictionary key is the name of the job and the dictionary value is the ordered list of tasks that the job must do.

It follows the format:

{"job_a": [(machine_name, time_duration_on_machine), ..],
 "job_b": [(some_machine, time_duration_on_machine), ..],
 ..
 "job_n": [(machine_name, time_duration_on_machine), ..]}

For example,

{"pancakes": [("mixer", 5), ("stove", 2)],
 "eggs": [("stove", 3)]}

Comment on max_time

In demo.py and job_shop_scheduler.py, we see a variable called max_time. It refers to the maximum possible end time in our job shop schedule.

Naively, we could set our max_time to infinity, so that our solver would consider all possible schedules with end times from 0 to infinity. However, this is a huge space to explore, and makes our BQM unnecessarily large and difficult to solve.

Instead, we can apply our knowledge on the worst possible schedule scenario so that we can put an upper bound on the schedule end times. The worst possible scenario is if all job tasks require the same exact machine, hence there is no opportunity for parallelization. In this case, the schedule end time is the sum of all task durations because that one machine will run those tasks back-to-back. We know the optimal schedule for these tasks must finish earlier or at the same time as this worst case scenario because these tasks don't necessarily all need to run on that one machine; this allows for parallelization and a shorter schedule. Thus, by default, the max_time considered for a schedule is the sum of task durations.

Note that we can lower max_time so that the solver considers a smaller space of schedule solutions. In terms of quantum computing hardware, this means using fewer qubits as we are considering a smaller range of end times and thus, fewer possible schedules. This is acceptable so long as the optimal schedule has an end time that is less than max_time. Otherwise, no valid schedule would be explored as we are considering schedule end times that are shorter than that of the optimal schedule (i.e. shortest possible of any valid schedule).

References

D. Venturelli, D. Marchand, and G. Rojo, "Quantum Annealing Implementation of Job-Shop Scheduling", arXiv:1506.08479v2

License

Released under the Apache License 2.0. See LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].