Skip to content

Commit

Permalink
Update notebooks to integrate them more easily in doc
Browse files Browse the repository at this point in the history
- rename and number notebooks using 2 digits to ease sorting them,
  we let the 00-09 numbers for quick start notebooks which will be the
  ones  previously generated from python scripts in examples
- scheduling notebook:
  - move main title and description in first cell (for auto-extraction
    by autodoc.py)
  - remove commented cell
  - add a level to all titles (by adding a #)
    so that only the main title is a html H1
  - bonus: when using the toc from jupyter nbextensions,
    the title will not be numbered (as a H1) and the other
    section titles will be well numbered
  • Loading branch information
nhuet committed Nov 25, 2021
1 parent 738a2d5 commit 605d20a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 71 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The next cell is patching asyncio so that applications using async functions can run in jupyter or any application haviing "
"# Introduction to scheduling\n",
"\n",
"In this notebook, we explore how to solve a resource constrained project scheduling problem (RCPSP).\n",
"\n",
"The problem is made of $M$ activities that have precedence constraints. That means that if activity $j\\in[1,M]$ is a successor of activity $i\\in[1,M]$, then activity $i$ must be completed before activity $j$ can be started\n",
"\n",
"On top of these constraints, each project is assigned a set of K renewable resources where each resource $k$ is available in $R_{k}$ units for the entire duration of the project. Each activity may require one or more of these resources to be completed. While scheduling the activities, the daily resource usage for resource $k$ can not exceed $R_{k}$ units.\n",
"\n",
"Each activity $j$ takes $d_{j}$ time units to complete.\n",
"\n",
"The overall goal of the problem is usually to minimize the makespan.\n",
"\n",
"A classic variant of RCPSP is the multimode RCPSP where each task can be executed in several ways (one way=one mode). A typical example is :\n",
"\n",
"Mode n°1 'Fast mode': high resource consumption and fast\n",
"Mode n°2 'Slow mode' : low resource consumption but slow"
]
},
{
Expand All @@ -13,17 +28,11 @@
"metadata": {},
"outputs": [],
"source": [
"# patching asyncio so that applications using async functions can run in jupyter\n",
"import nest_asyncio\n",
"\n",
"nest_asyncio.apply()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"nest_asyncio.apply()\n",
"\n",
"import logging\n",
"\n",
"logging.basicConfig(level=logging.INFO)\n",
Expand All @@ -32,44 +41,6 @@
"from pprint import pprint"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# fast testing without installing the lib.\n",
"# import sys\n",
"# sys.path.append(\"../\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introduction to scheduling"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook, we explore how to solve a resource constrained project scheduling problem (RCPSP).\n",
"\n",
"The problem is made of $M$ activities that have precedence constraints. That means that if activity $j\\in[1,M]$ is a successor of activity $i\\in[1,M]$, then activity $i$ must be completed before activity $j$ can be started\n",
"\n",
"On top of these constraints, each project is assigned a set of K renewable resources where each resource $k$ is available in $R_{k}$ units for the entire duration of the project. Each activity may require one or more of these resources to be completed. While scheduling the activities, the daily resource usage for resource $k$ can not exceed $R_{k}$ units.\n",
"\n",
"Each activity $j$ takes $d_{j}$ time units to complete.\n",
"\n",
"The overall goal of the problem is usually to minimize the makespan.\n",
"\n",
"A classic variant of RCPSP is the multimode RCPSP where each task can be executed in several ways (one way=one mode). A typical example is :\n",
"\n",
"Mode n°1 'Fast mode': high resource consumption and fast\n",
"Mode n°2 'Slow mode' : low resource consumption but slow"
]
},
{
"attachments": {
"image.png": {
Expand All @@ -79,7 +50,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# A simple problem definition\n",
"## A simple problem definition\n",
"\n",
"Let start with a very simple problem which has only 5 tasks to execute:\n",
"All tasks have specific durations and they can consume 1 type of renewable resources.\n",
Expand All @@ -101,7 +72,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Domain definition"
"### Domain definition"
]
},
{
Expand Down Expand Up @@ -190,7 +161,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Let's create an instance of this domain"
"### Let's create an instance of this domain"
]
},
{
Expand Down Expand Up @@ -297,7 +268,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using Lazy Astar to solve this problem"
"### Using Lazy Astar to solve this problem"
]
},
{
Expand All @@ -323,7 +294,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Result analysis"
"### Result analysis"
]
},
{
Expand Down Expand Up @@ -414,7 +385,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# A slightly more complex problem"
"## A slightly more complex problem"
]
},
{
Expand All @@ -428,7 +399,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Problem definition"
"### Problem definition"
]
},
{
Expand Down Expand Up @@ -574,7 +545,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create an instance of the J301 domain"
"### Create an instance of the J301 domain"
]
},
{
Expand All @@ -592,7 +563,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Lazy Astar to solve this problem"
"### Lazy Astar to solve this problem"
]
},
{
Expand Down Expand Up @@ -637,7 +608,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Let's now use a CP solver"
"### Let's now use a CP solver"
]
},
{
Expand Down Expand Up @@ -751,7 +722,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plotting the solution\n",
"### Plotting the solution\n",
"We rely on discrete_optimization plot utilities (where the CP model is used) to plot the gantt chart of our solution."
]
},
Expand Down Expand Up @@ -779,22 +750,22 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Intermediate Conclusion\n",
"### Intermediate Conclusion\n",
"On a problem containing only 32 tasks, an algorithm like $A^{*}$ cannot find a solution while a constraint programming approach takes less than half a second. Let's see what happen on a larger problem. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Going further : a bigger RCPSP problem"
"## Going further : a bigger RCPSP problem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Psplib files\n",
"### Psplib files\n",
"We rely on psplib benchmark files (http://www.om-db.wi.tum.de/psplib/) which containts sets of instances of 30, 60, 90 and 120 activities.\n",
"We will now use the ```j12051_1``` file that we identified as a difficult one to solve."
]
Expand All @@ -803,7 +774,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### psplib format "
"#### psplib format "
]
},
{
Expand Down Expand Up @@ -833,7 +804,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Parsing a psplib file \n",
"#### Parsing a psplib file \n",
"We provide a parser for this files so that it is automatically transformed into a RCPSP domain in scikit-decide."
]
},
Expand Down Expand Up @@ -861,7 +832,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using a CP solver again"
"### Using a CP solver again"
]
},
{
Expand Down Expand Up @@ -906,7 +877,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using the Large Neighboorhood Search algorithm\n",
"### Using the Large Neighboorhood Search algorithm\n",
"\n",
"Local search techniques are very effective to solve hard optimization problems. In the context of constraint programming (CP) for optimization problems, one of the most well-known and widely used local search techniques is the Large Neighborhood Search (LNS) algorithm . The basic idea is to iteratively relax a part of the problem, then to use constraint programming to optimize a simpler problem hoping that the reconstructed full solution improve our objective function.\n",
"For more insight, you can read this paper [\\[1\\]](https://www.researchgate.net/publication/220462078_LSSPER_Solving_the_Resource-Constrained_Project_Scheduling_Problem_with_Large_Neighbourhood_Search)"
Expand Down Expand Up @@ -963,15 +934,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Conclusion\n",
"## Conclusion\n",
"\n",
"In this notebook, we have seen how to use [scikit-decide](https://airbus.github.io/scikit-decide) to plan tasks. The library offers a binding to a constraint programming (CP) based solver providing optimal solution on small and mid sized benchmark. It reaches its limit for instances with >100 tasks where the use of the approximated solver LNS+CP proves to be effective."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -985,20 +956,20 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.7.10"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
"toc_window_display": true
}
},
"nbformat": 4,
Expand Down

0 comments on commit 605d20a

Please sign in to comment.