{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# JobShop sample" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We start by importing the corresponding jobshop problem module as following :" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The autoreload extension is already loaded. To reload it, use:\n", " %reload_ext autoreload\n" ] } ], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "import pyscheduling.JS.JmCmax as js" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is an example of instance to test on :" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "f = open(\"deleteMe.txt\",'w')\n", "f.write(\"3 4\\n0\\t10\\t1\\t8\\t2\\t4\\n1\\t8\\t0\\t3\\t3\\t5\\t2\\t6\\n0\\t4\\t1\\t7\\t3\\t3\")\n", "f.close()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we have to read the instance from the text file created above as follows in the next code cell.\n", "\n", "We obviously can randomly generate the instance as well." ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[(0, 10), (1, 8), (2, 4)], [(1, 8), (0, 3), (3, 5), (2, 6)], [(0, 4), (1, 7), (3, 3)]]\n" ] } ], "source": [ "instance = js.JmCmax_Instance.read_txt(\"deleteMe.txt\")\n", "print(instance.P)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we use one of the implemented methods which are found in either **Heuristics** or **Metaheuristics** classes as following :\n" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Objective : 28\n", "Machine_ID | Job_schedule (job_id , start_time , completion_time) | Completion_time\n", "1 | (0, 0, 10) : (1, 10, 13) : (2, 13, 17) | 17\n", "2 | (1, 0, 8) : (0, 10, 18) : (2, 18, 25) | 25\n", "3 | (0, 18, 22) : (1, 22, 28) | 28\n", "4 | (1, 13, 18) : (2, 25, 28) | 28\n" ] } ], "source": [ "solution = js.Heuristics.shifting_bottleneck(instance)\n", "print(solution)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.9.12 ('pyscheduling')", "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.9.12" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "fa7cdbb78ab82d427a6b02c171e3c48e0658c2b720f18feff16576a8f3200f32" } } }, "nbformat": 4, "nbformat_minor": 2 }