Skip to content

Commit 869a2cc

Browse files
committed
Display() added
1 parent 3055551 commit 869a2cc

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

IntroToLP.ipynb

+21-14
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 16,
66
"metadata": {},
77
"outputs": [
88
{
99
"data": {
1010
"text/html": [
11-
"Installing package Google.OrTools.................done!"
11+
"Installing package Google.OrTools..done!"
1212
]
1313
},
1414
"metadata": {},
@@ -27,7 +27,8 @@
2727
"source": [
2828
"#r \"nuget:Google.OrTools\"\n",
2929
"\n",
30-
"using Google.OrTools.LinearSolver;"
30+
"using Google.OrTools.LinearSolver;\n",
31+
"using System.Linq; "
3132
]
3233
},
3334
{
@@ -73,7 +74,7 @@
7374
},
7475
{
7576
"cell_type": "code",
76-
"execution_count": 2,
77+
"execution_count": 3,
7778
"metadata": {},
7879
"outputs": [],
7980
"source": [
@@ -82,7 +83,7 @@
8283
},
8384
{
8485
"cell_type": "code",
85-
"execution_count": 3,
86+
"execution_count": 4,
8687
"metadata": {},
8788
"outputs": [],
8889
"source": [
@@ -113,7 +114,7 @@
113114
},
114115
{
115116
"cell_type": "code",
116-
"execution_count": 4,
117+
"execution_count": 25,
117118
"metadata": {},
118119
"outputs": [],
119120
"source": [
@@ -132,26 +133,32 @@
132133
" // The objective value of the solution.\n",
133134
" Console.WriteLine(\"Optimal objective value = \" + solver.Objective().Value());\n",
134135
"\n",
135-
" // The value of each variable in the solution.\n",
136-
" foreach (var v in solver.variables())\n",
137-
" { Console.WriteLine($\"{v.Name()} : {v.SolutionValue()} \"); };\n",
136+
" //Improved solution display\n",
137+
" display(solver.variables().Select(a => new { Name = a.Name(), Value = a.SolutionValue() }));\n",
138138
"}"
139139
]
140140
},
141141
{
142142
"cell_type": "code",
143-
"execution_count": 5,
143+
"execution_count": 26,
144144
"metadata": {},
145145
"outputs": [
146146
{
147147
"name": "stdout",
148148
"output_type": "stream",
149149
"text": [
150-
"Problem solved in 398 milliseconds\n",
151-
"Optimal objective value = 31\n",
152-
"x : 15 \n",
153-
"y : 8 \n"
150+
"Problem solved in 699958 milliseconds\n",
151+
"Optimal objective value = 31\n"
154152
]
153+
},
154+
{
155+
"data": {
156+
"text/html": [
157+
"<table><thead><tr><th><i>index</i></th><th>Name</th><th>Value</th></tr></thead><tbody><tr><td>0</td><td>x</td><td>15</td></tr><tr><td>1</td><td>y</td><td>8</td></tr></tbody></table>"
158+
]
159+
},
160+
"metadata": {},
161+
"output_type": "display_data"
155162
}
156163
],
157164
"source": [

0 commit comments

Comments
 (0)