|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": { |
| 6 | + "vscode": { |
| 7 | + "languageId": "plaintext" |
| 8 | + } |
| 9 | + }, |
| 10 | + "source": [ |
| 11 | + "# JijModeling 1.12.1 Release Notes\n", |
| 12 | + "\n", |
| 13 | + "## Feature Enhancements" |
| 14 | + ] |
| 15 | + }, |
| 16 | + { |
| 17 | + "cell_type": "markdown", |
| 18 | + "metadata": {}, |
| 19 | + "source": [ |
| 20 | + "### Human Readable Errors in Interpreters\n", |
| 21 | + "\n", |
| 22 | + "Now [`Interpreter`](https://jij-inc.github.io/JijModeling-Tutorials/apis/jijmodeling.html#Interpreter) fails with more human-readable error message. For example:" |
| 23 | + ] |
| 24 | + }, |
| 25 | + { |
| 26 | + "cell_type": "code", |
| 27 | + "execution_count": 15, |
| 28 | + "metadata": {}, |
| 29 | + "outputs": [ |
| 30 | + { |
| 31 | + "data": { |
| 32 | + "text/latex": [ |
| 33 | + "$$\\begin{array}{cccc}\\text{Problem:} & \\text{shift\\_optimization} & & \\\\& & \\min \\quad \\displaystyle \\sum_{d = 0}^{D - 1} \\sum_{t = 0}^{T - 1} \\sum_{i = 0}^{N - 1} x_{d, t, i} & \\\\\\text{{s.t.}} & & & \\\\ & \\text{night\\_shift} & \\displaystyle R_{d + 1, i} \\leq x_{d, T - 1, i} & \\forall d \\in \\left\\{0,\\ldots,D - 1\\right\\} \\forall i \\in \\left\\{0,\\ldots,N - 1\\right\\} \\\\\\text{{where}} & & & \\\\& x & 3\\text{-dim binary variable}\\\\\\end{array}$$" |
| 34 | + ], |
| 35 | + "text/plain": [ |
| 36 | + "<jijmodeling.Problem at 0x105472000>" |
| 37 | + ] |
| 38 | + }, |
| 39 | + "execution_count": 15, |
| 40 | + "metadata": {}, |
| 41 | + "output_type": "execute_result" |
| 42 | + } |
| 43 | + ], |
| 44 | + "source": [ |
| 45 | + "import jijmodeling as jm\n", |
| 46 | + "\n", |
| 47 | + "D = jm.Placeholder(\"D\", dtype=jm.DataType.INTEGER)\n", |
| 48 | + "T = jm.Placeholder(\"T\", dtype=jm.DataType.INTEGER)\n", |
| 49 | + "N = jm.Placeholder(\"N\", dtype=jm.DataType.INTEGER)\n", |
| 50 | + "H = jm.Placeholder(\"H\", shape=(D, T, N))\n", |
| 51 | + "R = jm.Placeholder(\"R\", shape=(D, N))\n", |
| 52 | + "\n", |
| 53 | + "x = jm.BinaryVar(\"x\", shape=(D, T, N))\n", |
| 54 | + "d = jm.Element(\"d\", belong_to=(0, D))\n", |
| 55 | + "t = jm.Element(\"t\", belong_to=(0, T))\n", |
| 56 | + "i = jm.Element(\"i\", belong_to=(0, N))\n", |
| 57 | + "\n", |
| 58 | + "problem = jm.Problem(name=\"shift_optimization\")\n", |
| 59 | + "problem += jm.Constraint(\"night_shift\", R[d+1, i] <= x[d, T-1, i], forall=[d, i])\n", |
| 60 | + "problem += jm.sum([d, t, i], x[d, t, i])\n", |
| 61 | + "\n", |
| 62 | + "problem" |
| 63 | + ] |
| 64 | + }, |
| 65 | + { |
| 66 | + "cell_type": "code", |
| 67 | + "execution_count": 17, |
| 68 | + "metadata": {}, |
| 69 | + "outputs": [ |
| 70 | + { |
| 71 | + "name": "stdout", |
| 72 | + "output_type": "stream", |
| 73 | + "text": [ |
| 74 | + "Traceback (most recent last):\n", |
| 75 | + " while evaluating Problem `shift_optimization',\n", |
| 76 | + " while evaluating constraint: `night_shift',\n", |
| 77 | + " while evaluating expression `R[d + 1, i] - x[d, T - 1, i]',\n", |
| 78 | + " while evaluating expression `R[d + 1, i]',\n", |
| 79 | + "\n", |
| 80 | + "IndexError: Index [7, 0] is out of range for shape [7, 5]\n" |
| 81 | + ] |
| 82 | + } |
| 83 | + ], |
| 84 | + "source": [ |
| 85 | + "num_days = 7\n", |
| 86 | + "num_times = 3\n", |
| 87 | + "num_people = 5\n", |
| 88 | + "\n", |
| 89 | + "data = problem.generate_random_dataset(\n", |
| 90 | + " options={\n", |
| 91 | + " \"D\": {\"value\": num_days},\n", |
| 92 | + " \"T\": {\"value\": num_times},\n", |
| 93 | + " \n", |
| 94 | + " \"N\": {\"value\": num_people},\n", |
| 95 | + " }\n", |
| 96 | + ")\n", |
| 97 | + "interp = jm.Interpreter(data)\n", |
| 98 | + "\n", |
| 99 | + "try:\n", |
| 100 | + " interp.eval_problem(problem)\n", |
| 101 | + "except Exception as e:\n", |
| 102 | + " print(e)" |
| 103 | + ] |
| 104 | + }, |
| 105 | + { |
| 106 | + "cell_type": "markdown", |
| 107 | + "metadata": {}, |
| 108 | + "source": [ |
| 109 | + "## Bugfixes" |
| 110 | + ] |
| 111 | + }, |
| 112 | + { |
| 113 | + "cell_type": "markdown", |
| 114 | + "metadata": {}, |
| 115 | + "source": [ |
| 116 | + "### Fixes the Performance Bug in `Interpreter.eval_*`.\n", |
| 117 | + "\n", |
| 118 | + "Previously, evaluating expressions with `Interpreter` takes much more times than intended.\n", |
| 119 | + "This was due to the direct call to the arithmetic operations on OMMX `Function`s, which goes through conversion between intermediate expressions and re-allocates memory from the ground up. This results in quadratic performance degradation in some summation operations.\n", |
| 120 | + "\n", |
| 121 | + "Now JijModeling uses dedicated intermediate form of functions, so the overhead of conversion should be greatly tamed now." |
| 122 | + ] |
| 123 | + } |
| 124 | + ], |
| 125 | + "metadata": { |
| 126 | + "kernelspec": { |
| 127 | + "display_name": ".venv", |
| 128 | + "language": "python", |
| 129 | + "name": "python3" |
| 130 | + }, |
| 131 | + "language_info": { |
| 132 | + "codemirror_mode": { |
| 133 | + "name": "ipython", |
| 134 | + "version": 3 |
| 135 | + }, |
| 136 | + "file_extension": ".py", |
| 137 | + "mimetype": "text/x-python", |
| 138 | + "name": "python", |
| 139 | + "nbconvert_exporter": "python", |
| 140 | + "pygments_lexer": "ipython3", |
| 141 | + "version": "3.9.20" |
| 142 | + } |
| 143 | + }, |
| 144 | + "nbformat": 4, |
| 145 | + "nbformat_minor": 2 |
| 146 | +} |
0 commit comments