diff --git a/example/independent_constraints.ipynb b/example/independent_constraints.ipynb
index 8e230e3..39e13d9 100644
--- a/example/independent_constraints.ipynb
+++ b/example/independent_constraints.ipynb
@@ -20,13 +20,13 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 18,
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
- "end_time": "2024-03-15T13:14:33.926843Z",
- "start_time": "2024-03-15T13:14:33.754961Z"
+ "end_time": "2024-03-21T17:15:09.997853Z",
+ "start_time": "2024-03-21T17:15:09.959748Z"
}
},
"outputs": [
@@ -60,13 +60,13 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 19,
"outputs": [
{
"data": {
"text/plain": "{Symbolic(pets): ('cat', 'dog'), Integer(age): (5, 6, 7, 8, 9), Continuous(weight): (5,50)}"
},
- "execution_count": 2,
+ "execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@@ -82,8 +82,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-03-15T13:14:33.932364Z",
- "start_time": "2024-03-15T13:14:33.927966Z"
+ "end_time": "2024-03-21T17:15:10.039291Z",
+ "start_time": "2024-03-21T17:15:10.035907Z"
}
},
"id": "27ea010bc8892833"
@@ -108,7 +108,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 20,
"outputs": [
{
"name": "stdout",
@@ -134,8 +134,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-03-15T13:14:33.966347Z",
- "start_time": "2024-03-15T13:14:33.933021Z"
+ "end_time": "2024-03-21T17:15:10.044733Z",
+ "start_time": "2024-03-21T17:15:10.040231Z"
}
},
"id": "3654b51ed6b0b7e2"
@@ -163,7 +163,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 21,
"outputs": [
{
"data": {
@@ -178,14 +178,16 @@
2,
3,
3,
- 2
+ 2,
+ null
],
"y": [
10,
15,
15,
10,
- 10
+ 10,
+ null
],
"type": "scatter"
}
@@ -1034,7 +1036,7 @@
"plotlyServerURL": "https://plot.ly"
}
},
- "text/html": "
"
+ "text/html": ""
},
"metadata": {},
"output_type": "display_data"
@@ -1052,8 +1054,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-03-15T13:14:33.978590Z",
- "start_time": "2024-03-15T13:14:33.967321Z"
+ "end_time": "2024-03-21T17:15:10.054918Z",
+ "start_time": "2024-03-21T17:15:10.045493Z"
}
},
"id": "a86b223360f60725"
@@ -1073,13 +1075,13 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 22,
"outputs": [
{
"data": {
"text/plain": "{Continuous(x): [2,3] | [4,5] | [6,7], Continuous(y): [10,15] | [25,27]}"
},
- "execution_count": 5,
+ "execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -1091,8 +1093,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-03-15T13:14:33.982121Z",
- "start_time": "2024-03-15T13:14:33.979336Z"
+ "end_time": "2024-03-21T17:15:10.061292Z",
+ "start_time": "2024-03-21T17:15:10.055789Z"
}
},
"id": "86d42ecd896bef10"
@@ -1109,7 +1111,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 23,
"outputs": [
{
"data": {
@@ -1124,114 +1126,76 @@
2,
3,
3,
- 2
- ],
- "y": [
- 10,
- 15,
- 15,
- 10,
- 10
- ],
- "type": "scatter"
- },
- {
- "fill": "toself",
- "mode": "lines",
- "name": "Event",
- "x": [
+ 2,
+ null,
2,
2,
3,
3,
- 2
- ],
- "y": [
- 25,
- 27,
- 27,
- 25,
- 25
- ],
- "type": "scatter"
- },
- {
- "fill": "toself",
- "mode": "lines",
- "name": "Event",
- "x": [
+ 2,
+ null,
4,
4,
5,
5,
- 4
- ],
- "y": [
- 10,
- 15,
- 15,
- 10,
- 10
- ],
- "type": "scatter"
- },
- {
- "fill": "toself",
- "mode": "lines",
- "name": "Event",
- "x": [
+ 4,
+ null,
4,
4,
5,
5,
- 4
- ],
- "y": [
- 25,
- 27,
- 27,
- 25,
- 25
- ],
- "type": "scatter"
- },
- {
- "fill": "toself",
- "mode": "lines",
- "name": "Event",
- "x": [
+ 4,
+ null,
6,
6,
7,
7,
- 6
- ],
- "y": [
- 10,
- 15,
- 15,
- 10,
- 10
- ],
- "type": "scatter"
- },
- {
- "fill": "toself",
- "mode": "lines",
- "name": "Event",
- "x": [
+ 6,
+ null,
6,
6,
7,
7,
- 6
+ 6,
+ null
],
"y": [
+ 10,
+ 15,
+ 15,
+ 10,
+ 10,
+ null,
25,
27,
27,
25,
- 25
+ 25,
+ null,
+ 10,
+ 15,
+ 15,
+ 10,
+ 10,
+ null,
+ 25,
+ 27,
+ 27,
+ 25,
+ 25,
+ null,
+ 10,
+ 15,
+ 15,
+ 10,
+ 10,
+ null,
+ 25,
+ 27,
+ 27,
+ 25,
+ 25,
+ null
],
"type": "scatter"
}
@@ -2080,7 +2044,7 @@
"plotlyServerURL": "https://plot.ly"
}
},
- "text/html": ""
+ "text/html": ""
},
"metadata": {},
"output_type": "display_data"
@@ -2094,8 +2058,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-03-15T13:14:33.991792Z",
- "start_time": "2024-03-15T13:14:33.982676Z"
+ "end_time": "2024-03-21T17:15:10.072215Z",
+ "start_time": "2024-03-21T17:15:10.062573Z"
}
},
"id": "7d81de549d20f02b"
@@ -2112,7 +2076,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 24,
"outputs": [
{
"data": {
@@ -4338,7 +4302,7 @@
"plotlyServerURL": "https://plot.ly"
}
},
- "text/html": ""
+ "text/html": ""
},
"metadata": {},
"output_type": "display_data"
@@ -4355,8 +4319,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-03-15T13:14:34.007713Z",
- "start_time": "2024-03-15T13:14:33.993829Z"
+ "end_time": "2024-03-21T17:15:10.091818Z",
+ "start_time": "2024-03-21T17:15:10.073469Z"
}
},
"id": "da2b51a986fa9d05"
@@ -4392,81 +4356,79 @@
"data": [
{
"fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
"mode": "lines",
"name": "Event",
+ "showlegend": true,
"x": [
-1,
-1,
0,
0,
- -1
- ],
- "y": [
-1,
- 2,
- 2,
- -1,
- -1
- ],
- "type": "scatter"
- },
- {
- "fill": "toself",
- "mode": "lines",
- "name": "Event",
- "x": [
+ null,
1,
1,
2,
2,
- 1
+ 1,
+ null
],
"y": [
-1,
2,
2,
-1,
- -1
+ -1,
+ null,
+ -1,
+ 2,
+ 2,
+ -1,
+ -1,
+ null
],
"type": "scatter"
},
{
"fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
"mode": "lines",
"name": "Event",
+ "showlegend": false,
"x": [
0,
0,
1,
1,
- 0
- ],
- "y": [
- -1,
0,
- 0,
- -1,
- -1
- ],
- "type": "scatter"
- },
- {
- "fill": "toself",
- "mode": "lines",
- "name": "Event",
- "x": [
+ null,
0,
0,
1,
1,
- 0
+ 0,
+ null
],
"y": [
+ -1,
+ 0,
+ 0,
+ -1,
+ -1,
+ null,
1,
2,
2,
1,
- 1
+ 1,
+ null
],
"type": "scatter"
}
@@ -5312,7 +5274,7 @@
"plotlyServerURL": "https://plot.ly"
}
},
- "text/html": ""
+ "text/html": ""
},
"metadata": {},
"output_type": "display_data"
@@ -5329,12 +5291,12 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-03-15T13:14:34.073364Z",
- "start_time": "2024-03-15T13:14:34.066945Z"
+ "end_time": "2024-03-21T17:15:10.104115Z",
+ "start_time": "2024-03-21T17:15:10.093771Z"
}
},
"id": "97f6f80a61c8abaf",
- "execution_count": 8
+ "execution_count": 25
},
{
"cell_type": "markdown",
@@ -5561,12 +5523,12 @@
],
"y": [
-1,
- 2,
- 2,
+ 0,
+ 0,
-1,
-1,
- 2,
- 2,
+ 0,
+ 0,
-1
],
"z": [
@@ -5574,10 +5536,10 @@
-1,
-1,
-1,
- 0,
- 0,
- 0,
- 0
+ 2,
+ 2,
+ 2,
+ 2
],
"type": "mesh3d"
},
@@ -5636,20 +5598,20 @@
1
],
"y": [
- -1,
+ 1,
2,
2,
- -1,
- -1,
+ 1,
+ 1,
2,
2,
- -1
+ 1
],
"z": [
- 1,
- 1,
- 1,
- 1,
+ -1,
+ -1,
+ -1,
+ -1,
2,
2,
2,
@@ -5712,24 +5674,24 @@
1
],
"y": [
- -1,
- 0,
0,
- -1,
- -1,
+ 1,
+ 1,
0,
0,
- -1
+ 1,
+ 1,
+ 0
],
"z": [
+ -1,
+ -1,
+ -1,
+ -1,
0,
0,
0,
- 0,
- 1,
- 1,
- 1,
- 1
+ 0
],
"type": "mesh3d"
},
@@ -5788,24 +5750,24 @@
1
],
"y": [
+ 0,
1,
- 2,
- 2,
1,
+ 0,
+ 0,
1,
- 2,
- 2,
- 1
+ 1,
+ 0
],
"z": [
- 0,
- 0,
- 0,
- 0,
1,
1,
1,
- 1
+ 1,
+ 2,
+ 2,
+ 2,
+ 2
],
"type": "mesh3d"
}
@@ -5819,12 +5781,12 @@
},
"yaxis": {
"title": {
- "text": "z"
+ "text": "y"
}
},
"zaxis": {
"title": {
- "text": "y"
+ "text": "z"
}
}
},
@@ -6658,7 +6620,7 @@
"plotlyServerURL": "https://plot.ly"
}
},
- "text/html": ""
+ "text/html": ""
},
"metadata": {},
"output_type": "display_data"
@@ -6679,12 +6641,2034 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-03-15T13:14:34.170331Z",
- "start_time": "2024-03-15T13:14:34.160312Z"
+ "end_time": "2024-03-21T17:15:10.114835Z",
+ "start_time": "2024-03-21T17:15:10.105316Z"
}
},
"id": "9e47b2f884e4c9dd",
- "execution_count": 9
+ "execution_count": 26
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Application of the Product Algebra\n",
+ "\n",
+ "You may ask yourself where the product algebra matters in real applications.\n",
+ "Consider your kitchen. You most likely have some regions where you are able to stand, and some regions where you can't.\n",
+ "If you look at floor plan of your kitchen, you could perhaps describe it as the following event. "
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "a077c140431ca667"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.plotly.v1+json": {
+ "data": [
+ {
+ "fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
+ "mode": "lines",
+ "name": "Event",
+ "showlegend": true,
+ "x": [
+ 0.0,
+ 0.0,
+ 5.0,
+ 5.0,
+ 0.0,
+ null
+ ],
+ "y": [
+ 6.5,
+ 7.0,
+ 7.0,
+ 6.5,
+ 6.5,
+ null
+ ],
+ "type": "scatter"
+ },
+ {
+ "fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
+ "mode": "lines",
+ "name": "Event",
+ "showlegend": false,
+ "x": [
+ 5.0,
+ 5.0,
+ 6.0,
+ 6.0,
+ 5.0,
+ null
+ ],
+ "y": [
+ 6.3,
+ 7.0,
+ 7.0,
+ 6.3,
+ 6.3,
+ null
+ ],
+ "type": "scatter"
+ },
+ {
+ "fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
+ "mode": "lines",
+ "name": "Event",
+ "showlegend": false,
+ "x": [
+ 0.0,
+ 0.0,
+ 0.5,
+ 0.5,
+ 0.0,
+ null
+ ],
+ "y": [
+ 0.0,
+ 6.5,
+ 6.5,
+ 0.0,
+ 0.0,
+ null
+ ],
+ "type": "scatter"
+ },
+ {
+ "fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
+ "mode": "lines",
+ "name": "Event",
+ "showlegend": false,
+ "x": [
+ 2,
+ 2,
+ 4,
+ 4,
+ 2,
+ null
+ ],
+ "y": [
+ 3,
+ 5,
+ 5,
+ 3,
+ 3,
+ null
+ ],
+ "type": "scatter"
+ }
+ ],
+ "layout": {
+ "xaxis": {
+ "title": {
+ "text": "x"
+ }
+ },
+ "yaxis": {
+ "title": {
+ "text": "y"
+ }
+ },
+ "template": {
+ "data": {
+ "histogram2dcontour": [
+ {
+ "type": "histogram2dcontour",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "choropleth": [
+ {
+ "type": "choropleth",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ ],
+ "histogram2d": [
+ {
+ "type": "histogram2d",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "heatmap": [
+ {
+ "type": "heatmap",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "heatmapgl": [
+ {
+ "type": "heatmapgl",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "contourcarpet": [
+ {
+ "type": "contourcarpet",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ ],
+ "contour": [
+ {
+ "type": "contour",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "surface": [
+ {
+ "type": "surface",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "mesh3d": [
+ {
+ "type": "mesh3d",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ ],
+ "scatter": [
+ {
+ "marker": {
+ "line": {
+ "color": "#283442"
+ }
+ },
+ "type": "scatter"
+ }
+ ],
+ "parcoords": [
+ {
+ "type": "parcoords",
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scatterpolargl": [
+ {
+ "type": "scatterpolargl",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "bar": [
+ {
+ "error_x": {
+ "color": "#f2f5fa"
+ },
+ "error_y": {
+ "color": "#f2f5fa"
+ },
+ "marker": {
+ "line": {
+ "color": "rgb(17,17,17)",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "bar"
+ }
+ ],
+ "scattergeo": [
+ {
+ "type": "scattergeo",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scatterpolar": [
+ {
+ "type": "scatterpolar",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "histogram": [
+ {
+ "marker": {
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "histogram"
+ }
+ ],
+ "scattergl": [
+ {
+ "marker": {
+ "line": {
+ "color": "#283442"
+ }
+ },
+ "type": "scattergl"
+ }
+ ],
+ "scatter3d": [
+ {
+ "type": "scatter3d",
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scattermapbox": [
+ {
+ "type": "scattermapbox",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scatterternary": [
+ {
+ "type": "scatterternary",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scattercarpet": [
+ {
+ "type": "scattercarpet",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "carpet": [
+ {
+ "aaxis": {
+ "endlinecolor": "#A2B1C6",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "minorgridcolor": "#506784",
+ "startlinecolor": "#A2B1C6"
+ },
+ "baxis": {
+ "endlinecolor": "#A2B1C6",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "minorgridcolor": "#506784",
+ "startlinecolor": "#A2B1C6"
+ },
+ "type": "carpet"
+ }
+ ],
+ "table": [
+ {
+ "cells": {
+ "fill": {
+ "color": "#506784"
+ },
+ "line": {
+ "color": "rgb(17,17,17)"
+ }
+ },
+ "header": {
+ "fill": {
+ "color": "#2a3f5f"
+ },
+ "line": {
+ "color": "rgb(17,17,17)"
+ }
+ },
+ "type": "table"
+ }
+ ],
+ "barpolar": [
+ {
+ "marker": {
+ "line": {
+ "color": "rgb(17,17,17)",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "barpolar"
+ }
+ ],
+ "pie": [
+ {
+ "automargin": true,
+ "type": "pie"
+ }
+ ]
+ },
+ "layout": {
+ "autotypenumbers": "strict",
+ "colorway": [
+ "#636efa",
+ "#EF553B",
+ "#00cc96",
+ "#ab63fa",
+ "#FFA15A",
+ "#19d3f3",
+ "#FF6692",
+ "#B6E880",
+ "#FF97FF",
+ "#FECB52"
+ ],
+ "font": {
+ "color": "#f2f5fa"
+ },
+ "hovermode": "closest",
+ "hoverlabel": {
+ "align": "left"
+ },
+ "paper_bgcolor": "rgb(17,17,17)",
+ "plot_bgcolor": "rgb(17,17,17)",
+ "polar": {
+ "bgcolor": "rgb(17,17,17)",
+ "angularaxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ },
+ "radialaxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ }
+ },
+ "ternary": {
+ "bgcolor": "rgb(17,17,17)",
+ "aaxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ },
+ "baxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ },
+ "caxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ }
+ },
+ "coloraxis": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "colorscale": {
+ "sequential": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ],
+ "sequentialminus": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ],
+ "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"
+ ]
+ ]
+ },
+ "xaxis": {
+ "gridcolor": "#283442",
+ "linecolor": "#506784",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "#283442",
+ "automargin": true,
+ "zerolinewidth": 2
+ },
+ "yaxis": {
+ "gridcolor": "#283442",
+ "linecolor": "#506784",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "#283442",
+ "automargin": true,
+ "zerolinewidth": 2
+ },
+ "scene": {
+ "xaxis": {
+ "backgroundcolor": "rgb(17,17,17)",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "#C8D4E3",
+ "gridwidth": 2
+ },
+ "yaxis": {
+ "backgroundcolor": "rgb(17,17,17)",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "#C8D4E3",
+ "gridwidth": 2
+ },
+ "zaxis": {
+ "backgroundcolor": "rgb(17,17,17)",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "#C8D4E3",
+ "gridwidth": 2
+ }
+ },
+ "shapedefaults": {
+ "line": {
+ "color": "#f2f5fa"
+ }
+ },
+ "annotationdefaults": {
+ "arrowcolor": "#f2f5fa",
+ "arrowhead": 0,
+ "arrowwidth": 1
+ },
+ "geo": {
+ "bgcolor": "rgb(17,17,17)",
+ "landcolor": "rgb(17,17,17)",
+ "subunitcolor": "#506784",
+ "showland": true,
+ "showlakes": true,
+ "lakecolor": "rgb(17,17,17)"
+ },
+ "title": {
+ "x": 0.05
+ },
+ "updatemenudefaults": {
+ "bgcolor": "#506784",
+ "borderwidth": 0
+ },
+ "sliderdefaults": {
+ "bgcolor": "#C8D4E3",
+ "borderwidth": 1,
+ "bordercolor": "rgb(17,17,17)",
+ "tickwidth": 0
+ },
+ "mapbox": {
+ "style": "dark"
+ }
+ }
+ }
+ },
+ "config": {
+ "plotlyServerURL": "https://plot.ly"
+ }
+ },
+ "text/html": ""
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "kitchen = Event({x: portion.closed(0, 6.6), y: portion.closed(0, 7)})\n",
+ "refrigerator = Event({x: portion.closed(5, 6), y: portion.closed(6.3, 7)})\n",
+ "top_kitchen_island = Event({x: portion.closed(0, 5), y: portion.closed(6.5, 7)})\n",
+ "left_cabinets = Event({x: portion.closed(0, 0.5), y: portion.closed(0, 6.5)})\n",
+ "\n",
+ "center_island = Event({x: portion.closed(2, 4), y: portion.closed(3, 5)})\n",
+ "\n",
+ "occupied_spaces = refrigerator | top_kitchen_island | left_cabinets | center_island\n",
+ "fig = go.Figure(occupied_spaces.plot(), occupied_spaces.plotly_layout())\n",
+ "fig.show()"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-03-21T17:15:10.126182Z",
+ "start_time": "2024-03-21T17:15:10.116159Z"
+ }
+ },
+ "id": "b8916038b2521a38",
+ "execution_count": 27
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "Now posing the question on where you can stand in your kitchen, you can simply calculate the complement of the occupied space with the kitchen."
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "96d63611dffff0f5"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.plotly.v1+json": {
+ "data": [
+ {
+ "fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
+ "mode": "lines",
+ "name": "Event",
+ "showlegend": true,
+ "x": [
+ 6.0,
+ 6.0,
+ 6.6,
+ 6.6,
+ 6.0,
+ null
+ ],
+ "y": [
+ 0.0,
+ 7.0,
+ 7.0,
+ 0.0,
+ 0.0,
+ null
+ ],
+ "type": "scatter"
+ },
+ {
+ "fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
+ "mode": "lines",
+ "name": "Event",
+ "showlegend": false,
+ "x": [
+ 0.5,
+ 0.5,
+ 2.0,
+ 2.0,
+ 0.5,
+ null,
+ 4.0,
+ 4.0,
+ 5.0,
+ 5.0,
+ 4.0,
+ null
+ ],
+ "y": [
+ 0.0,
+ 6.5,
+ 6.5,
+ 0.0,
+ 0.0,
+ null,
+ 0.0,
+ 6.5,
+ 6.5,
+ 0.0,
+ 0.0,
+ null
+ ],
+ "type": "scatter"
+ },
+ {
+ "fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
+ "mode": "lines",
+ "name": "Event",
+ "showlegend": false,
+ "x": [
+ 5.0,
+ 5.0,
+ 6.0,
+ 6.0,
+ 5.0,
+ null
+ ],
+ "y": [
+ 0.0,
+ 6.3,
+ 6.3,
+ 0.0,
+ 0.0,
+ null
+ ],
+ "type": "scatter"
+ },
+ {
+ "fill": "toself",
+ "legendgroup": "Event",
+ "line": {
+ "color": "#636EFA"
+ },
+ "mode": "lines",
+ "name": "Event",
+ "showlegend": false,
+ "x": [
+ 2,
+ 2,
+ 4,
+ 4,
+ 2,
+ null,
+ 2.0,
+ 2.0,
+ 4.0,
+ 4.0,
+ 2.0,
+ null
+ ],
+ "y": [
+ 0,
+ 3,
+ 3,
+ 0,
+ 0,
+ null,
+ 5.0,
+ 6.5,
+ 6.5,
+ 5.0,
+ 5.0,
+ null
+ ],
+ "type": "scatter"
+ }
+ ],
+ "layout": {
+ "xaxis": {
+ "title": {
+ "text": "x"
+ }
+ },
+ "yaxis": {
+ "title": {
+ "text": "y"
+ }
+ },
+ "template": {
+ "data": {
+ "histogram2dcontour": [
+ {
+ "type": "histogram2dcontour",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "choropleth": [
+ {
+ "type": "choropleth",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ ],
+ "histogram2d": [
+ {
+ "type": "histogram2d",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "heatmap": [
+ {
+ "type": "heatmap",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "heatmapgl": [
+ {
+ "type": "heatmapgl",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "contourcarpet": [
+ {
+ "type": "contourcarpet",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ ],
+ "contour": [
+ {
+ "type": "contour",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "surface": [
+ {
+ "type": "surface",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ]
+ }
+ ],
+ "mesh3d": [
+ {
+ "type": "mesh3d",
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ ],
+ "scatter": [
+ {
+ "marker": {
+ "line": {
+ "color": "#283442"
+ }
+ },
+ "type": "scatter"
+ }
+ ],
+ "parcoords": [
+ {
+ "type": "parcoords",
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scatterpolargl": [
+ {
+ "type": "scatterpolargl",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "bar": [
+ {
+ "error_x": {
+ "color": "#f2f5fa"
+ },
+ "error_y": {
+ "color": "#f2f5fa"
+ },
+ "marker": {
+ "line": {
+ "color": "rgb(17,17,17)",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "bar"
+ }
+ ],
+ "scattergeo": [
+ {
+ "type": "scattergeo",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scatterpolar": [
+ {
+ "type": "scatterpolar",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "histogram": [
+ {
+ "marker": {
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "histogram"
+ }
+ ],
+ "scattergl": [
+ {
+ "marker": {
+ "line": {
+ "color": "#283442"
+ }
+ },
+ "type": "scattergl"
+ }
+ ],
+ "scatter3d": [
+ {
+ "type": "scatter3d",
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scattermapbox": [
+ {
+ "type": "scattermapbox",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scatterternary": [
+ {
+ "type": "scatterternary",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "scattercarpet": [
+ {
+ "type": "scattercarpet",
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ }
+ }
+ ],
+ "carpet": [
+ {
+ "aaxis": {
+ "endlinecolor": "#A2B1C6",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "minorgridcolor": "#506784",
+ "startlinecolor": "#A2B1C6"
+ },
+ "baxis": {
+ "endlinecolor": "#A2B1C6",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "minorgridcolor": "#506784",
+ "startlinecolor": "#A2B1C6"
+ },
+ "type": "carpet"
+ }
+ ],
+ "table": [
+ {
+ "cells": {
+ "fill": {
+ "color": "#506784"
+ },
+ "line": {
+ "color": "rgb(17,17,17)"
+ }
+ },
+ "header": {
+ "fill": {
+ "color": "#2a3f5f"
+ },
+ "line": {
+ "color": "rgb(17,17,17)"
+ }
+ },
+ "type": "table"
+ }
+ ],
+ "barpolar": [
+ {
+ "marker": {
+ "line": {
+ "color": "rgb(17,17,17)",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "barpolar"
+ }
+ ],
+ "pie": [
+ {
+ "automargin": true,
+ "type": "pie"
+ }
+ ]
+ },
+ "layout": {
+ "autotypenumbers": "strict",
+ "colorway": [
+ "#636efa",
+ "#EF553B",
+ "#00cc96",
+ "#ab63fa",
+ "#FFA15A",
+ "#19d3f3",
+ "#FF6692",
+ "#B6E880",
+ "#FF97FF",
+ "#FECB52"
+ ],
+ "font": {
+ "color": "#f2f5fa"
+ },
+ "hovermode": "closest",
+ "hoverlabel": {
+ "align": "left"
+ },
+ "paper_bgcolor": "rgb(17,17,17)",
+ "plot_bgcolor": "rgb(17,17,17)",
+ "polar": {
+ "bgcolor": "rgb(17,17,17)",
+ "angularaxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ },
+ "radialaxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ }
+ },
+ "ternary": {
+ "bgcolor": "rgb(17,17,17)",
+ "aaxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ },
+ "baxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ },
+ "caxis": {
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "ticks": ""
+ }
+ },
+ "coloraxis": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "colorscale": {
+ "sequential": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ],
+ "sequentialminus": [
+ [
+ 0.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.0,
+ "#f0f921"
+ ]
+ ],
+ "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"
+ ]
+ ]
+ },
+ "xaxis": {
+ "gridcolor": "#283442",
+ "linecolor": "#506784",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "#283442",
+ "automargin": true,
+ "zerolinewidth": 2
+ },
+ "yaxis": {
+ "gridcolor": "#283442",
+ "linecolor": "#506784",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "#283442",
+ "automargin": true,
+ "zerolinewidth": 2
+ },
+ "scene": {
+ "xaxis": {
+ "backgroundcolor": "rgb(17,17,17)",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "#C8D4E3",
+ "gridwidth": 2
+ },
+ "yaxis": {
+ "backgroundcolor": "rgb(17,17,17)",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "#C8D4E3",
+ "gridwidth": 2
+ },
+ "zaxis": {
+ "backgroundcolor": "rgb(17,17,17)",
+ "gridcolor": "#506784",
+ "linecolor": "#506784",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "#C8D4E3",
+ "gridwidth": 2
+ }
+ },
+ "shapedefaults": {
+ "line": {
+ "color": "#f2f5fa"
+ }
+ },
+ "annotationdefaults": {
+ "arrowcolor": "#f2f5fa",
+ "arrowhead": 0,
+ "arrowwidth": 1
+ },
+ "geo": {
+ "bgcolor": "rgb(17,17,17)",
+ "landcolor": "rgb(17,17,17)",
+ "subunitcolor": "#506784",
+ "showland": true,
+ "showlakes": true,
+ "lakecolor": "rgb(17,17,17)"
+ },
+ "title": {
+ "x": 0.05
+ },
+ "updatemenudefaults": {
+ "bgcolor": "#506784",
+ "borderwidth": 0
+ },
+ "sliderdefaults": {
+ "bgcolor": "#C8D4E3",
+ "borderwidth": 1,
+ "bordercolor": "rgb(17,17,17)",
+ "tickwidth": 0
+ },
+ "mapbox": {
+ "style": "dark"
+ }
+ }
+ }
+ },
+ "config": {
+ "plotlyServerURL": "https://plot.ly"
+ }
+ },
+ "text/html": ""
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "free_space = kitchen.difference(occupied_spaces)\n",
+ "fig = go.Figure(free_space.plot(), free_space.plotly_layout())\n",
+ "fig.show()"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-03-21T17:15:10.139382Z",
+ "start_time": "2024-03-21T17:15:10.127017Z"
+ }
+ },
+ "id": "510b80164a41cfc",
+ "execution_count": 28
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "Now this already sounds somewhat useful. However, just the events are of limited use. The real power of the product algebra comes when you start to calculate probabilities of events.\n",
+ "For this, you can checkout this tutorial on [probability theory](https://probabilistic-model.readthedocs.io/en/latest/examples/probability_theory.html)."
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "86e43578f1c0808d"
}
],
"metadata": {
diff --git a/src/random_events/__init__.py b/src/random_events/__init__.py
index 4b259db..2940e26 100644
--- a/src/random_events/__init__.py
+++ b/src/random_events/__init__.py
@@ -1 +1 @@
-__version__ = '2.0.7'
+__version__ = '2.0.8'
diff --git a/src/random_events/events.py b/src/random_events/events.py
index ccd9a57..51d8c90 100644
--- a/src/random_events/events.py
+++ b/src/random_events/events.py
@@ -346,7 +346,9 @@ def plot_2d(self) -> List[go.Scatter]:
# form cartesian product of all intervals
intervals = [value._intervals for value in self.values()]
simple_events = list(itertools.product(*intervals))
- traces = []
+
+ xs = []
+ ys = []
# for every atomic interval
for simple_event in simple_events:
@@ -355,9 +357,10 @@ def plot_2d(self) -> List[go.Scatter]:
points = np.asarray(list(itertools.product(*[[axis.lower, axis.upper] for axis in simple_event])))
y_points = points[:, 1]
y_points[len(y_points) // 2:] = y_points[len(y_points) // 2:][::-1]
- traces.append(go.Scatter(x=np.append(points[:, 0], points[0, 0]), y=np.append(y_points, y_points[0]),
- mode="lines", name="Event", fill="toself"))
- return traces
+ xs.extend(points[:, 0].tolist() + [points[0, 0], None])
+ ys.extend(y_points.tolist()+ [y_points[0], None])
+
+ return [go.Scatter(x=xs, y=ys, mode="lines", name="Event", fill="toself")]
def plot_3d(self) -> List[go.Mesh3d]:
"""
@@ -396,7 +399,7 @@ def plotly_layout(self) -> Dict:
"""
Create a layout for the plotly plot.
"""
- variables = list(self.keys())
+ variables = list(sorted(self.keys()))
if len(variables) == 2:
result = {"xaxis_title": variables[0].name,
"yaxis_title": variables[1].name}
@@ -510,6 +513,7 @@ def __init__(self, events: Iterable[Event]):
variables = self.variables
for event in self.events:
event.fill_missing_variables(variables)
+ self.events = [event.__class__(sorted(event.items())) for event in self.events]
@property
def variables(self) -> Tuple[Variable, ...]:
@@ -673,13 +677,21 @@ def __eq__(self, other: ComplexEvent) -> bool:
def __copy__(self):
return self.__class__([event.copy() for event in self.events])
- def plot(self) -> Union[List[go.Scatter], List[go.Mesh3d]]:
+ def plot(self, color="#636EFA") -> Union[List[go.Scatter], List[go.Mesh3d]]:
"""
Plot the complex event.
+
+ :param color: The color to use for this event
"""
traces = []
- for event in self.events:
- traces.extend(event.plot())
+ show_legend = True
+ for index, event in enumerate(self.events):
+ event_traces = event.plot()
+ for event_trace in event_traces:
+ if len(event.keys()) == 2:
+ event_trace.update(legendgroup="Event", showlegend=show_legend, line=dict(color=color))
+ show_legend = False
+ traces.append(event_trace)
return traces
def plotly_layout(self) -> Dict:
diff --git a/test/test_events.py b/test/test_events.py
index 4b1dcb7..fc987ac 100644
--- a/test/test_events.py
+++ b/test/test_events.py
@@ -450,9 +450,9 @@ def test_plot_complex_event_2d(self):
event = Event({self.x: portion.closed(0, 1), self.y: portion.closed(0, 1)})
complement = event.complement()
limiting_event = Event({self.x: portion.closed(-1, 2), self.y: portion.closed(-1, 2)})
- result = complement.intersection(ComplexEvent([limiting_event]))
+ result = complement.intersection(limiting_event)
fig = go.Figure(result.plot(), result.plotly_layout())
- # fig.show()
+ # fig.show()
def test_plot_complex_event_3d(self):
event = Event({self.x: portion.closed(0, 1),