{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Use case: software development\n", "To illustrate the way to use ProcessScheduler, let's imagine the simple following use case: the developmenent of a scheduling software intended for end-user. The software is developed using Python, and provides a modern Qt GUI. Three junior developers are in charge (Elias, Louis, Elise), under the supervision of their project manager Justine. The objective of this document is to generate a schedule of the different developmenent tasks to go rom the early design stages to the first software release. This notebook can tested online at mybinder.org\n", "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tpaviot/ProcessScheduler/HEAD?filepath=doc/use-case-software-development.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 1. Import the module\n", "The best way to import the processscheduler module is to choose an alias import. Indeed, a global import should generate name conflicts. Here, the *ps* alias is used." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import processscheduler as ps\n", "from datetime import timedelta, datetime\n", "\n", "%config InlineBackend.figure_formats = ['svg']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 2. Create the scheduling problem\n", "The SchedulingProblem has to be defined. The problem must have a name (it is a mandatory argument). Of course you can create as many problems (i.e; SchedulingProblem instances), for example if you need to compare two or more different schedules." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "problem = ps.SchedulingProblem(\n", " \"SoftwareDevelopment\", delta_time=timedelta(days=1), start_time=datetime.now()\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 3. Create tasks instances\n", "The SchedulingProblem has to be defined. The problem must have a name (it is a mandatory argument). Of course you can create as many problems (i.e SchedulingProblem instances) as needed, for example if you need to compare two or more different schedules. In this example, one period is one day." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "preliminary_design = ps.FixedDurationTask(\"PreliminaryDesign\", duration=1) # 1 day\n", "core_development = ps.VariableDurationTask(\"CoreDevelopmenent\", work_amount=10)\n", "gui_development = ps.VariableDurationTask(\"GUIDevelopment\", work_amount=15)\n", "integration = ps.VariableDurationTask(\"Integration\", work_amount=3)\n", "tests_development = ps.VariableDurationTask(\"TestDevelopment\", work_amount=8)\n", "release = ps.ZeroDurationTask(\"ReleaseMilestone\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 4. Create tasks time constraints\n", "Define precedences or set start and end times" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ps.TaskStartAt(preliminary_design, 0)\n", "ps.TaskPrecedence(preliminary_design, core_development)\n", "ps.TaskPrecedence(preliminary_design, gui_development)\n", "ps.TaskPrecedence(gui_development, tests_development)\n", "ps.TaskPrecedence(core_development, tests_development)\n", "ps.TaskPrecedence(tests_development, integration)\n", "ps.TaskPrecedence(integration, release)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 5. Create resources\n", "Define all resources required for all tasks to be processed, including productivity and cost_per_period." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "elias = ps.Worker(\n", " \"Elias\", productivity=2, cost=ps.ConstantCostPerPeriod(600)\n", ") # cost in $/day\n", "louis = ps.Worker(\"Louis\", productivity=2, cost=ps.ConstantCostPerPeriod(600))\n", "elise = ps.Worker(\"Elise\", productivity=3, cost=ps.ConstantCostPerPeriod(800))\n", "justine = ps.Worker(\"Justine\", productivity=2, cost=ps.ConstantCostPerPeriod(1200))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 6. Assign resources to tasks" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "preliminary_design.add_required_resources([elias, louis, elise, justine])\n", "core_development.add_required_resources([louis, elise])\n", "gui_development.add_required_resources([elise])\n", "tests_development.add_required_resources([elias, louis])\n", "integration.add_required_resources([justine])\n", "release.add_required_resources([justine])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 7. Add a total cost indicator\n", "This resource cost indicator computes the total cost of selected resources." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cost_ind = problem.add_indicator_resource_cost([elias, louis, elise, justine])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 8. Solve and plot using plotly" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# solve\n", "solver = ps.SchedulingSolver(problem)\n", "solution = solver.solve()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if solution:\n", " solution.render_gantt_plotly()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.6" } }, "nbformat": 4, "nbformat_minor": 4 }