{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "start_time": "2023-04-11T21:43:12.028049Z",
     "end_time": "2023-04-11T21:43:12.056336Z"
    }
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "from datetime import datetime\n",
    "\n",
    "sys.path.append('../../src')\n",
    "from pjplan import WBS, ForwardScheduler, Task, MermaidGantt, Resource, BackwardScheduler"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [],
   "source": [
    "tester = Resource('Tester')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-04-11T21:43:12.057338Z",
     "end_time": "2023-04-11T21:43:12.071342Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [],
   "source": [
    "with WBS() as prj:\n",
    "    prj // Task(1, 'Task 1', estimate=40, resource=tester.name)\n",
    "    prj // Task(2, 'Task 2', predecessors=[prj[1]], estimate=20, resource=tester.name)\n",
    "    with prj // Task(3, 'Task 3') as t:\n",
    "        t // Task(4, 'Task 4', predecessors=[prj[2]], estimate=100)\n",
    "        t // Task(5, 'Task 5', predecessors=[prj[2]], estimate=50)\n",
    "    with prj // Task(6, 'Task 6') as t:\n",
    "        t // Task(7, 'Task 7', predecessors=[prj[5]], estimate=16)\n",
    "        t // Task(8, 'Task 8', predecessors=[prj[7]], estimate=16)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-04-11T21:43:12.074342Z",
     "end_time": "2023-04-11T21:43:12.089853Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "data": {
      "text/plain": "<pjplan.viz.mermaid.gantt.MermaidGantt at 0x153a24e00d0>",
      "text/html": "<iframe srcdoc=\"&lt;html&gt;\n&lt;meta charset=&quot;UTF-8&quot;&gt;\n&lt;body&gt;\n&lt;style&gt;\n\n&lt;/style&gt;\n\n&lt;div class=&quot;mermaid&quot;&gt;\ngantt\n  dateFormat DD.MM.YYYY\n    Task 1: active, id_1, 11.04.2023, 18.04.2023\n    Task 2:  id_2, 18.04.2023, 20.04.2023\n    Task 3:  id_3, 20.04.2023, 08.05.2023\n    Task 4:  id_4, 20.04.2023, 08.05.2023\n    Task 5:  id_5, 20.04.2023, 29.04.2023\n    Task 6:  id_6, 01.05.2023, 07.05.2023\n    Task 7:  id_7, 01.05.2023, 04.05.2023\n    Task 8:  id_8, 04.05.2023, 07.05.2023\n\n&lt;/div&gt;\n\n&lt;script src=&quot;https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js&quot;&gt;&lt;/script&gt;\n&lt;script&gt;\n    mermaid.ganttConfig = {\n        mirrorActor: true\n    }\n    mermaid.initialize({\n        startOnLoad: true\n    });\n&lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\" width=\"100%\" height=\"300\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "schedule1 = ForwardScheduler(resources=[tester], balance_resources=False).calc(prj).schedule\n",
    "\n",
    "MermaidGantt(schedule1)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-04-11T21:43:12.090849Z",
     "end_time": "2023-04-11T21:43:12.101447Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n",
      "7\n",
      "6\n",
      "5\n",
      "4\n",
      "3\n",
      "2\n",
      "1\n"
     ]
    },
    {
     "data": {
      "text/plain": "<pjplan.viz.mermaid.gantt.MermaidGantt at 0x153a24e2380>",
      "text/html": "<iframe srcdoc=\"&lt;html&gt;\n&lt;meta charset=&quot;UTF-8&quot;&gt;\n&lt;body&gt;\n&lt;style&gt;\n\n&lt;/style&gt;\n\n&lt;div class=&quot;mermaid&quot;&gt;\ngantt\n  dateFormat DD.MM.YYYY\n    Task 1: done, id_1, 13.03.2023, 18.03.2023\n    Task 2: done, id_2, 20.03.2023, 23.03.2023\n    Task 3: done, id_3, 23.03.2023, 11.04.2023\n    Task 4: done, id_4, 23.03.2023, 11.04.2023\n    Task 5: done, id_5, 27.03.2023, 05.04.2023\n    Task 6: done, id_6, 05.04.2023, 11.04.2023\n    Task 7: done, id_7, 05.04.2023, 07.04.2023\n    Task 8: done, id_8, 07.04.2023, 11.04.2023\n\n&lt;/div&gt;\n\n&lt;script src=&quot;https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js&quot;&gt;&lt;/script&gt;\n&lt;script&gt;\n    mermaid.ganttConfig = {\n        mirrorActor: true\n    }\n    mermaid.initialize({\n        startOnLoad: true\n    });\n&lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\" width=\"100%\" height=\"300\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "schedule1_bw = BackwardScheduler(resources=[tester], balance_resources=False).calc(prj).schedule\n",
    "MermaidGantt(schedule1_bw)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-04-11T21:43:12.103452Z",
     "end_time": "2023-04-11T21:43:12.128676Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "data": {
      "text/plain": "<pjplan.viz.mermaid.gantt.MermaidGantt at 0x153a24e3220>",
      "text/html": "<iframe srcdoc=\"&lt;html&gt;\n&lt;meta charset=&quot;UTF-8&quot;&gt;\n&lt;body&gt;\n&lt;style&gt;\n\n&lt;/style&gt;\n\n&lt;div class=&quot;mermaid&quot;&gt;\ngantt\n  dateFormat DD.MM.YYYY\n    Task 1: active, id_1, 11.04.2023, 18.04.2023\n    Task 2:  id_2, 18.04.2023, 20.04.2023\n    Task 3:  id_3, 20.04.2023, 16.05.2023\n    Task 4:  id_4, 20.04.2023, 08.05.2023\n    Task 5:  id_5, 08.05.2023, 16.05.2023\n    Task 6:  id_6, 16.05.2023, 22.05.2023\n    Task 7:  id_7, 16.05.2023, 18.05.2023\n    Task 8:  id_8, 18.05.2023, 22.05.2023\n\n&lt;/div&gt;\n\n&lt;script src=&quot;https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js&quot;&gt;&lt;/script&gt;\n&lt;script&gt;\n    mermaid.ganttConfig = {\n        mirrorActor: true\n    }\n    mermaid.initialize({\n        startOnLoad: true\n    });\n&lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\" width=\"100%\" height=\"300\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "schedule2 = ForwardScheduler(resources=[tester], balance_resources=True).calc(prj).schedule\n",
    "MermaidGantt(schedule2)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-04-11T21:43:12.120682Z",
     "end_time": "2023-04-11T21:43:12.137680Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n",
      "7\n",
      "6\n",
      "5\n",
      "4\n",
      "3\n",
      "2\n",
      "1\n"
     ]
    },
    {
     "data": {
      "text/plain": "<pjplan.viz.mermaid.gantt.MermaidGantt at 0x153a24d1e10>",
      "text/html": "<iframe srcdoc=\"&lt;html&gt;\n&lt;meta charset=&quot;UTF-8&quot;&gt;\n&lt;body&gt;\n&lt;style&gt;\n\n&lt;/style&gt;\n\n&lt;div class=&quot;mermaid&quot;&gt;\ngantt\n  dateFormat DD.MM.YYYY\n    Task 1: done, id_1, 24.02.2023, 03.03.2023\n    Task 2: done, id_2, 03.03.2023, 08.03.2023\n    Task 3: done, id_3, 08.03.2023, 05.04.2023\n    Task 4: done, id_4, 08.03.2023, 27.03.2023\n    Task 5: done, id_5, 27.03.2023, 05.04.2023\n    Task 6: done, id_6, 05.04.2023, 11.04.2023\n    Task 7: done, id_7, 05.04.2023, 07.04.2023\n    Task 8: done, id_8, 07.04.2023, 11.04.2023\n\n&lt;/div&gt;\n\n&lt;script src=&quot;https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js&quot;&gt;&lt;/script&gt;\n&lt;script&gt;\n    mermaid.ganttConfig = {\n        mirrorActor: true\n    }\n    mermaid.initialize({\n        startOnLoad: true\n    });\n&lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\" width=\"100%\" height=\"300\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "schedule2_bw = BackwardScheduler(resources=[tester], balance_resources=True).calc(prj).schedule\n",
    "MermaidGantt(schedule2_bw)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-04-11T21:43:12.136680Z",
     "end_time": "2023-04-11T21:43:12.154677Z"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
