{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Scheduling Problems\n", "\n", "本章ではいくつかの典型的スケジューリング問題の例とその定式化について扱います。\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from amplify_sched import *\n", "\n", "token = \"xxxxxxxxxxxxxxxxxxxxxxxxx\"" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Flow Shop Scheduling\n", "\n", "Flow Shop Scheduling はスケジューリング問題の一種で以下のように定義されます\n", "\n", "**定義**\n", "\n", "- m 台の Machine(M_1, M_2, ..., M_m)で n 個の Job(J_1, J_2, ..., J_n)を処理する\n", "- 各 Job は m 台すべての Machine を$M_1$から順に処理し、これらの Machine の処理順序はすべての Job で同一である\n", "- 各 Job の各 Machine における処理時間はそれぞれ与えられる\n", "- このとき与えられた評価尺度を最適にするような Job の処理順序を求める問題\n", "\n", "### 定式化例\n", "\n", "下記の Flow Shop Scheduling の定式化とメイクスパンの最適化を Amplify Sched で行います。\n", "\n", "| Job name | Process | Machine name | Processing Time |\n", "| -------- | ------- | ------------ | --------------- |\n", "| J1 | 0 | M1 | 10 |\n", "| J1 | 1 | M2 | 15 |\n", "| J1 | 2 | M3 | 20 |\n", "| J2 | 0 | M1 | 15 |\n", "| J2 | 1 | M2 | 20 |\n", "| J2 | 2 | M3 | 10 |\n", "| J3 | 0 | M1 | 10 |\n", "| J3 | 1 | M2 | 20 |\n", "| J3 | 2 | M3 | 15 |\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "alignmentgroup": "True", "base": [ 0, 10, 25 ], "customdata": [ [ "J1", 0 ], [ "J1", 1 ], [ "J1", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "J1", "marker": { "color": "#636efa", "pattern": { "shape": "" } }, "name": "J1", "offsetgroup": "J1", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 10, 15, 20 ], "xaxis": "x", "y": [ "M1", "M2", "M3" ], "yaxis": "y" }, { "alignmentgroup": "True", "base": [ 20, 45, 65 ], "customdata": [ [ "J2", 0 ], [ "J2", 1 ], [ "J2", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "J2", "marker": { "color": "#EF553B", "pattern": { "shape": "" } }, "name": "J2", "offsetgroup": "J2", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 15, 20, 10 ], "xaxis": "x", "y": [ "M1", "M2", "M3" ], "yaxis": "y" }, { "alignmentgroup": "True", "base": [ 10, 25, 45 ], "customdata": [ [ "J3", 0 ], [ "J3", 1 ], [ "J3", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "J3", "marker": { "color": "#00cc96", "pattern": { "shape": "" } }, "name": "J3", "offsetgroup": "J3", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 10, 20, 15 ], "xaxis": "x", "y": [ "M1", "M2", "M3" ], "yaxis": "y" } ], "layout": { "barmode": "overlay", "legend": { "title": { "text": "Job" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "type": "linear" }, "yaxis": { "anchor": "x", "categoryarray": [ "M3", "M2", "M1" ], "categoryorder": "array", "domain": [ 0, 1 ], "title": { "text": "Machine" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "model = Model()\n", "\n", "model.jobs.add(\"J1\")\n", "model.jobs.add(\"J2\")\n", "model.jobs.add(\"J3\")\n", "\n", "model.machines.add(\"M1\")\n", "model.machines.add(\"M2\")\n", "model.machines.add(\"M3\")\n", "\n", "model.jobs[\"J1\"].append(Task())\n", "model.jobs[\"J1\"][0].processing_times[\"M1\"] = 10\n", "model.jobs[\"J1\"].append(Task())\n", "model.jobs[\"J1\"][1].processing_times[\"M2\"] = 15\n", "model.jobs[\"J1\"].append(Task())\n", "model.jobs[\"J1\"][2].processing_times[\"M3\"] = 20\n", "\n", "model.jobs[\"J2\"].append(Task())\n", "model.jobs[\"J2\"][0].processing_times[\"M1\"] = 15\n", "model.jobs[\"J2\"].append(Task())\n", "model.jobs[\"J2\"][1].processing_times[\"M2\"] = 20\n", "model.jobs[\"J2\"].append(Task())\n", "model.jobs[\"J2\"][2].processing_times[\"M3\"] = 10\n", "\n", "model.jobs[\"J3\"].append(Task())\n", "model.jobs[\"J3\"][0].processing_times[\"M1\"] = 10\n", "model.jobs[\"J3\"].append(Task())\n", "model.jobs[\"J3\"][1].processing_times[\"M2\"] = 20\n", "model.jobs[\"J3\"].append(Task())\n", "model.jobs[\"J3\"][2].processing_times[\"M3\"] = 15\n", "gantt = model.solve(token=token, timeout=1)\n", "gantt.timeline(machine_view=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Job Shop Scheduling\n", "\n", "Job Shop Scheduling はスケジューリング問題の一種で以下のように定義されます。\n", "\n", "**定義**\n", "\n", "- m 台の Machine(M_1, M_2, ..., M_m)で n 個の Job(J_1, J_2, ..., J_n)を処理する。\n", "- 各 Job はすべての Machine で一度ずつ処理されるが、その処理順序は Job ごとに異なってもよい\n", "- 各 Job の各 Machine における処理時間はそれぞれ与えられる\n", "- このとき与えられた評価尺度を最適にするような各 Task の開始時刻を求める問題\n", "\n", "### 定式化例\n", "\n", "下記の Job Shop Scheduling の定式化とメイクスパンの最適化を Amplify Sched で行います。\n", "\n", "| Job name | Process | Machine name | Processing Time |\n", "| -------- | ------- | ------------ | --------------- |\n", "| Job A | 0 | Machine X | 10 |\n", "| Job A | 1 | Machine Y | 20 |\n", "| Job A | 2 | Machine Z | 15 |\n", "| Job B | 0 | Machine Y | 10 |\n", "| Job B | 1 | Machine Z | 20 |\n", "| Job B | 2 | Machine X | 15 |\n", "| Job C | 0 | Machine Z | 10 |\n", "| Job C | 1 | Machine X | 20 |\n", "| Job C | 2 | Machine Y | 15 |\n", "| Job D | 0 | Machine Z | 10 |\n", "| Job D | 1 | Machine Y | 20 |\n", "| Job D | 2 | Machine X | 15 |\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "alignmentgroup": "True", "base": [ 0, 10, 40 ], "customdata": [ [ "Job A", 0 ], [ "Job A", 1 ], [ "Job A", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "Job A", "marker": { "color": "#636efa", "pattern": { "shape": "" } }, "name": "Job A", "offsetgroup": "Job A", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 10, 20, 15 ], "xaxis": "x", "y": [ "Machine X", "Machine Y", "Machine Z" ], "yaxis": "y" }, { "alignmentgroup": "True", "base": [ 0, 20, 40 ], "customdata": [ [ "Job B", 0 ], [ "Job B", 1 ], [ "Job B", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "Job B", "marker": { "color": "#EF553B", "pattern": { "shape": "" } }, "name": "Job B", "offsetgroup": "Job B", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 10, 20, 15 ], "xaxis": "x", "y": [ "Machine Y", "Machine Z", "Machine X" ], "yaxis": "y" }, { "alignmentgroup": "True", "base": [ 0, 10, 50 ], "customdata": [ [ "Job C", 0 ], [ "Job C", 1 ], [ "Job C", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "Job C", "marker": { "color": "#00cc96", "pattern": { "shape": "" } }, "name": "Job C", "offsetgroup": "Job C", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 10, 20, 15 ], "xaxis": "x", "y": [ "Machine Z", "Machine X", "Machine Y" ], "yaxis": "y" }, { "alignmentgroup": "True", "base": [ 10, 30, 55 ], "customdata": [ [ "Job D", 0 ], [ "Job D", 1 ], [ "Job D", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "Job D", "marker": { "color": "#ab63fa", "pattern": { "shape": "" } }, "name": "Job D", "offsetgroup": "Job D", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 10, 20, 15 ], "xaxis": "x", "y": [ "Machine Z", "Machine Y", "Machine X" ], "yaxis": "y" } ], "layout": { "barmode": "overlay", "legend": { "title": { "text": "Job" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "type": "linear" }, "yaxis": { "anchor": "x", "categoryarray": [ "Machine Z", "Machine Y", "Machine X" ], "categoryorder": "array", "domain": [ 0, 1 ], "title": { "text": "Machine" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "model = Model()\n", "\n", "model.jobs.add(\"Job A\")\n", "model.jobs.add(\"Job B\")\n", "model.jobs.add(\"Job C\")\n", "model.jobs.add(\"Job D\")\n", "\n", "model.machines.add(\"Machine X\")\n", "model.machines.add(\"Machine Y\")\n", "model.machines.add(\"Machine Z\")\n", "\n", "model.jobs[\"Job A\"].append(Task())\n", "model.jobs[\"Job A\"][0].processing_times[\"Machine X\"] = 10\n", "model.jobs[\"Job A\"].append(Task())\n", "model.jobs[\"Job A\"][1].processing_times[\"Machine Y\"] = 20\n", "model.jobs[\"Job A\"].append(Task())\n", "model.jobs[\"Job A\"][2].processing_times[\"Machine Z\"] = 15\n", "\n", "model.jobs[\"Job B\"].append(Task())\n", "model.jobs[\"Job B\"][0].processing_times[\"Machine Y\"] = 10\n", "model.jobs[\"Job B\"].append(Task())\n", "model.jobs[\"Job B\"][1].processing_times[\"Machine Z\"] = 20\n", "model.jobs[\"Job B\"].append(Task())\n", "model.jobs[\"Job B\"][2].processing_times[\"Machine X\"] = 15\n", "\n", "model.jobs[\"Job C\"].append(Task())\n", "model.jobs[\"Job C\"][0].processing_times[\"Machine Z\"] = 10\n", "model.jobs[\"Job C\"].append(Task())\n", "model.jobs[\"Job C\"][1].processing_times[\"Machine X\"] = 20\n", "model.jobs[\"Job C\"].append(Task())\n", "model.jobs[\"Job C\"][2].processing_times[\"Machine Y\"] = 15\n", "\n", "model.jobs[\"Job D\"].append(Task())\n", "model.jobs[\"Job D\"][0].processing_times[\"Machine Z\"] = 10\n", "model.jobs[\"Job D\"].append(Task())\n", "model.jobs[\"Job D\"][1].processing_times[\"Machine Y\"] = 20\n", "model.jobs[\"Job D\"].append(Task())\n", "model.jobs[\"Job D\"][2].processing_times[\"Machine X\"] = 15\n", "gantt = model.solve(token=token, timeout=1)\n", "gantt.timeline(machine_view=True)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Flexible Job Shop Scheduling\n", "\n", "Flexible Job Shop Scheduling はスケジューリング問題の一種で以下のように定義されます\n", "\n", "**定義**\n", "\n", "- m 台の Machine(M_1, M_2, ..., M_m)で n 個の Job(J_1, J_2, ..., J_n)を処理する\n", "- 各 Job の各 Process は指定されたの Machine で処理される。このときその Process を処理できる Machine の候補を複数定義できる\n", "- 各 Job の各 Machine における処理時間はそれぞれ与えられる\n", "- このとき与えられた評価尺度を最適にするような各 Task の開始時刻と Machine の割り当てを求める問題\n", "\n", "### 定式化例\n", "\n", "下記の Flexible Job Shop Scheduling の定式化とメイクスパンの最適化を Amplify Sched で行います。\n", "\n", "| Job name | Process | Machine name | Processing Time |\n", "| -------- | ------- | ------------ | --------------- |\n", "| Job A | 0 | Machine X | 10 |\n", "| Job A | 0 | Machine Y | 5 |\n", "| Job B | 0 | Machine X | 15 |\n", "| Job B | 0 | Machine Y | 2 |\n", "| Job C | 0 | Machine Z | 10 |\n", "| Job C | 0 | Machine Y | 1 |\n", "| Job A | 1 | Machine X | 20 |\n", "| Job A | 1 | Machine Y | 10 |\n", "| Job B | 1 | Machine Z | 20 |\n", "| Job B | 1 | Machine Y | 10 |\n", "| Job C | 1 | Machine X | 20 |\n", "| Job C | 1 | Machine Z | 10 |\n", "| Job A | 2 | Machine Z | 15 |\n", "| Job B | 2 | Machine X | 15 |\n", "| Job C | 2 | Machine Y | 15 |\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "alignmentgroup": "True", "base": [ 2, 12, 22 ], "customdata": [ [ "Job A", 0 ], [ "Job A", 1 ], [ "Job A", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "Job A", "marker": { "color": "#636efa", "pattern": { "shape": "" } }, "name": "Job A", "offsetgroup": "Job A", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 10, 10, 15 ], "xaxis": "x", "y": [ "Machine X", "Machine Y", "Machine Z" ], "yaxis": "y" }, { "alignmentgroup": "True", "base": [ 0, 2, 12 ], "customdata": [ [ "Job B", 0 ], [ "Job B", 1 ], [ "Job B", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "Job B", "marker": { "color": "#EF553B", "pattern": { "shape": "" } }, "name": "Job B", "offsetgroup": "Job B", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 2, 10, 15 ], "xaxis": "x", "y": [ "Machine Y", "Machine Y", "Machine X" ], "yaxis": "y" }, { "alignmentgroup": "True", "base": [ 1, 11, 22 ], "customdata": [ [ "Job C", 0 ], [ "Job C", 1 ], [ "Job C", 2 ] ], "hovertemplate": "Job=%{customdata[0]}
Start=%{base}
Finish=%{x}
Machine=%{y}
Process=%{customdata[1]}", "legendgroup": "Job C", "marker": { "color": "#00cc96", "pattern": { "shape": "" } }, "name": "Job C", "offsetgroup": "Job C", "orientation": "h", "showlegend": true, "textposition": "auto", "type": "bar", "x": [ 10, 10, 15 ], "xaxis": "x", "y": [ "Machine Z", "Machine Z", "Machine Y" ], "yaxis": "y" } ], "layout": { "barmode": "overlay", "legend": { "title": { "text": "Job" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "type": "linear" }, "yaxis": { "anchor": "x", "categoryarray": [ "Machine Z", "Machine Y", "Machine X" ], "categoryorder": "array", "domain": [ 0, 1 ], "title": { "text": "Machine" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "model = Model()\n", "\n", "model.jobs.add(\"Job A\")\n", "model.jobs.add(\"Job B\")\n", "model.jobs.add(\"Job C\")\n", "\n", "model.machines.add(\"Machine X\")\n", "model.machines.add(\"Machine Y\")\n", "model.machines.add(\"Machine Z\")\n", "\n", "model.jobs[\"Job A\"].append(Task())\n", "model.jobs[\"Job A\"][0].processing_times[\"Machine X\"] = 10\n", "model.jobs[\"Job A\"][0].processing_times[\"Machine Y\"] = 5\n", "model.jobs[\"Job B\"].append(Task())\n", "model.jobs[\"Job B\"][0].processing_times[\"Machine X\"] = 15\n", "model.jobs[\"Job B\"][0].processing_times[\"Machine Y\"] = 2\n", "model.jobs[\"Job C\"].append(Task())\n", "model.jobs[\"Job C\"][0].processing_times[\"Machine Z\"] = 10\n", "model.jobs[\"Job C\"][0].processing_times[\"Machine Y\"] = 1\n", "\n", "model.jobs[\"Job A\"].append(Task())\n", "model.jobs[\"Job A\"][1].processing_times[\"Machine X\"] = 20\n", "model.jobs[\"Job A\"][1].processing_times[\"Machine Y\"] = 10\n", "model.jobs[\"Job B\"].append(Task())\n", "model.jobs[\"Job B\"][1].processing_times[\"Machine Z\"] = 20\n", "model.jobs[\"Job B\"][1].processing_times[\"Machine Y\"] = 10\n", "model.jobs[\"Job C\"].append(Task())\n", "model.jobs[\"Job C\"][1].processing_times[\"Machine X\"] = 20\n", "model.jobs[\"Job C\"][1].processing_times[\"Machine Z\"] = 10\n", "\n", "model.jobs[\"Job A\"].append(Task())\n", "model.jobs[\"Job A\"][2].processing_times[\"Machine Z\"] = 15\n", "model.jobs[\"Job B\"].append(Task())\n", "model.jobs[\"Job B\"][2].processing_times[\"Machine X\"] = 15\n", "model.jobs[\"Job C\"].append(Task())\n", "model.jobs[\"Job C\"][2].processing_times[\"Machine Y\"] = 15\n", "\n", "\n", "gantt = model.solve(token=token, timeout=1)\n", "gantt.timeline(machine_view=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "scheduling-engine-sdk-IShfnD0Q", "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.10.6" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }