-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
622 lines (607 loc) · 15.9 KB
/
Copy pathindex.html
File metadata and controls
622 lines (607 loc) · 15.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NP-douce 1.2</title>
<link rel="icon" type="image/png" href="np-douce-logo.png">
<link rel="manifest" href="manifest.webmanifest">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header class="topbar">
<div class="brandLockup">
<img class="brandLogo" src="np-douce-logo.png" alt="NP-douce logo" width="86" height="86">
<div>
<h1>NP-douce 1.2</h1>
<p>Solving the world's hardest problems.</p>
</div>
</div>
<div class="badge">Version 1.2 - Offline browser app</div>
</header>
<main class="layout">
<aside class="solverRail">
<div class="railTitle">Solvers</div>
<nav class="tabs" aria-label="Solvers">
<div class="tabGroup">
<span class="tabGroupLabel">HC reductions</span>
<button class="tab active" data-panel="sat3">3-SAT</button>
<button class="tab" data-panel="vertexCover">Vertex cover</button>
<button class="tab" data-panel="clique">Clique</button>
<button class="tab" data-panel="independentSet">Independent set</button>
<button class="tab" data-panel="setCover">Set cover</button>
<button class="tab" data-panel="x3c">X3C</button>
<button class="tab" data-panel="graphColoring">Graph coloring</button>
</div>
<div class="tabGroup">
<span class="tabGroupLabel">Direct HC</span>
<button class="tab" data-panel="pairs">Hamiltonian pairs</button>
</div>
<div class="tabGroup">
<span class="tabGroupLabel">TSP</span>
<button class="tab" data-panel="matrix">TSP matrix</button>
<button class="tab" data-panel="points">TSP points</button>
<button class="tab" data-panel="manual">TSP manual</button>
</div>
</nav>
</aside>
<section class="appBody">
<div class="globalControls">
<label>HC solve node limit<input id="hcSolveNodeLimit" type="number" min="0" step="1" value="20000"></label>
<label>HC backtrack tries<input id="hcBacktrackTries" type="number" min="0" max="500" step="1" value="0"></label>
<label>TSP beta multiplier c<input id="tspBetaMultiplier" type="number" min="0" step="0.05" value="1"></label>
<label class="switchLine">Search all answers<input id="hcSearchAllAnswers" type="checkbox" checked><span class="switchTrack"></span></label>
<p class="fieldNote">Shared settings apply across tabs. TSP uses adaptive beta with the multiplier c; for gr17 matrix/manual, try c = 1.5 with HC backtrack tries = 4.</p>
</div>
<section class="workspace">
<section id="sat3" class="panel active">
<div class="panelHead">
<h2>3-SAT to Hamiltonian Cycle</h2>
<p>Uses the classic 3-SAT to Vertex Cover triangle reduction, then the direct Hamiltonian-cycle gadget with the degree-2 forced-edge precheck. The optional third number on the first line adds forced padding nodes.</p>
</div>
<label>3-SAT data</label>
<p class="benchmarkMeta">Benchmark: SATLIB uf20-91, instance uf20-01.cnf, DIMACS CNF converted to app 3-literal rows, expected SAT. Set HC backtrack tries to 2 before running this example.</p>
<textarea id="satInput" spellcheck="false"># SATLIB uf20-91, instance uf20-01.cnf
# Source: https://www.cs.ubc.ca/~hoos/SATLIB/benchm.html
# Copy used for exact clauses: https://github.com/mitchellh/go-sat/blob/master/testdata/satlib/sat-uniform-20-91/uf20-01.cnf
# Original format: DIMACS CNF, p cnf 20 91; conversion removes trailing 0 from each clause.
# Expected original answer: SAT
20 91
4 -18 19
3 18 -5
-5 -8 -15
-20 7 -16
10 -13 -7
-12 -9 17
17 19 5
-16 9 15
11 -5 -14
18 -10 13
-3 11 12
-6 -17 -8
-18 14 1
-19 -15 10
12 18 -19
-8 4 7
-8 -9 4
7 17 -15
12 -7 -14
-10 -11 8
2 -15 -11
9 6 1
-11 20 -17
9 -15 13
12 -7 -17
-18 -2 20
20 12 4
19 11 14
-16 18 -4
-1 -17 -19
-13 15 10
-12 -14 -13
12 -14 -7
-7 16 10
6 10 7
20 14 -16
-19 17 11
-7 1 -20
-5 12 15
-4 -9 -13
12 -11 -7
-5 19 -8
1 16 17
20 -14 -15
13 -4 10
14 7 10
-5 9 20
10 1 -19
-16 -15 -1
16 3 -11
-15 -10 4
4 -15 -3
-10 -16 11
-8 12 -5
14 -6 12
1 6 11
-13 -5 -1
-7 -2 12
1 -20 19
-2 -13 -8
15 18 4
-11 14 9
-6 -15 -2
5 -12 -15
-6 17 5
-13 5 -19
20 -1 14
9 -17 15
-5 19 -18
-12 8 -10
-18 14 -4
15 -9 13
9 -5 -1
10 -19 -14
20 9 4
-9 -2 19
-5 13 -17
2 -10 -18
-18 3 11
7 -9 17
-15 -6 -3
-2 3 -13
12 3 -2
-2 -3 17
20 -15 -16
-5 -17 -19
-20 -18 11
-9 1 -5
-19 9 17
12 -2 17
4 -16 -5</textarea>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="satFile" accept=".txt"></label>
<button id="runSat">Run 3-SAT reduction</button>
</div>
</section>
<section id="vertexCover" class="panel">
<div class="panelHead">
<h2>Vertex Cover to Hamiltonian Cycle</h2>
<p>First line is <code>vertices k optional_padding</code>, then one undirected edge per line. Example: <code>12 4</code> followed by edge pairs.</p>
</div>
<label>Vertex cover data</label>
<p class="benchmarkMeta">Benchmark: DIMACS COLOR myciel3.col graph, converted to Vertex Cover with k=6, expected YES; k=5 is NO.</p>
<textarea id="vcInput" spellcheck="false">11 6
1 2
1 4
1 7
1 9
2 3
2 6
2 8
3 5
3 7
3 10
4 5
4 6
4 10
5 8
5 9
6 11
7 11
8 11
9 11
10 11</textarea>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="vcFile" accept=".txt"></label>
<button id="runVc">Run vertex cover reduction</button>
</div>
</section>
<section id="clique" class="panel">
<div class="panelHead">
<h2>Clique to Hamiltonian Cycle</h2>
<p>First line is <code>vertices k optional_padding</code>, then one undirected edge per line. Example: <code>50 10</code> followed by the clique edge pairs.</p>
</div>
<label>Clique data</label>
<p class="benchmarkMeta">Benchmark: complement of DIMACS COLOR myciel3.col graph, clique threshold k=5, expected YES; k=6 is NO.</p>
<textarea id="cliqueInput" spellcheck="false">11 5
1 3
1 5
1 6
1 8
1 10
1 11
2 4
2 5
2 7
2 9
2 10
2 11
3 4
3 6
3 8
3 9
3 11
4 7
4 8
4 9
4 11
5 6
5 7
5 10
5 11
6 7
6 8
6 9
6 10
7 8
7 9
7 10
8 9
8 10
9 10</textarea>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="cliqueFile" accept=".txt"></label>
<button id="runClique">Run clique reduction</button>
</div>
</section>
<section id="independentSet" class="panel">
<div class="panelHead">
<h2>Independent Set to Hamiltonian Cycle</h2>
<p>First line is <code>vertices k optional_padding</code>, then one undirected edge per line. Example: <code>16 6</code> followed by edge pairs.</p>
</div>
<label>Independent set data</label>
<p class="benchmarkMeta">Benchmark: DIMACS COLOR myciel3.col graph, independent-set threshold k=5, expected YES; k=6 is NO.</p>
<textarea id="isInput" spellcheck="false">11 5
1 2
1 4
1 7
1 9
2 3
2 6
2 8
3 5
3 7
3 10
4 5
4 6
4 10
5 8
5 9
6 11
7 11
8 11
9 11
10 11</textarea>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="isFile" accept=".txt"></label>
<button id="runIs">Run independent set reduction</button>
</div>
</section>
<section id="setCover" class="panel">
<div class="panelHead">
<h2>Set Cover to Hamiltonian Cycle</h2>
<p>First line is <code>universe_size set_count k optional_padding</code>, then one set per line using element numbers. Example: <code>12 6 4</code> followed by six sets.</p>
</div>
<label>Set cover data</label>
<p class="benchmarkMeta">Benchmark: Beasley-style set-covering example, converted from row/column incidence to app set rows, optimum 3, expected YES for k=3.</p>
<textarea id="setCoverInput" spellcheck="false"># Set-covering incidence example from Beasley-style OR set covering literature
# Source: https://people.brunel.ac.uk/~mastjjb/jeb/orlib/scpinfo.html
# Original format: row/column incidence matrix; conversion writes each column as one set.
# Expected optimum: 3 sets; expected answer for k=3: YES
7 7 3
1 2 6 7
1 2 7
1 2 3
5 6 7
6 7
4 6
4</textarea>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="setCoverFile" accept=".txt"></label>
<button id="runSetCover">Run set cover reduction</button>
</div>
</section>
<section id="x3c" class="panel">
<div class="panelHead">
<h2>X3C to Hamiltonian Cycle</h2>
<p>First line is <code>universe_size set_count optional_padding</code>, then one 3-element set per line. Example: <code>12 6</code> followed by six 3-sets.</p>
</div>
<label>X3C data</label>
<p class="benchmarkMeta">Benchmark: canonical X3C/3-dimensional-matching teaching instance; no tiny library-format X3C file is bundled, expected YES.</p>
<textarea id="x3cInput" spellcheck="false"># Canonical X3C / 3-dimensional matching decision instance
# Source family: Karp exact cover by 3-sets, converted directly to app rows.
# Expected exact cover: S1, S2
6 4
1 2 3
4 5 6
1 4 5
2 3 6</textarea>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="x3cFile" accept=".txt"></label>
<button id="runX3c">Run X3C reduction</button>
</div>
</section>
<section id="graphColoring" class="panel">
<div class="panelHead">
<h2>Graph Coloring to Hamiltonian Cycle</h2>
<p>First line is <code>vertices edges colors optional_padding</code>, then one undirected edge per line. Example: <code>12 12 3</code> followed by a 12-cycle.</p>
</div>
<label>Graph coloring data</label>
<p class="benchmarkMeta">Benchmark-format DIMACS COLOR complete bipartite graph K3,3, 3 colors, expected YES; it survives the exact precheck and runs through HC witness search.</p>
<textarea id="graphColoringInput" spellcheck="false"># DIMACS COLOR complete bipartite graph K3,3
# Source format: DIMACS graph-coloring edge list
# Original format: p edge 6 9 plus e-lines; conversion removes p/e prefixes.
# Expected chromatic number: 2; expected answer for 3 colors: YES
6 9 3
1 4
1 5
1 6
2 4
2 5
2 6
3 4
3 5
3 6</textarea>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="graphColoringFile" accept=".txt"></label>
<button id="runGraphColoring">Run graph coloring reduction</button>
</div>
</section>
<section id="pairs" class="panel">
<div class="panelHead">
<h2>Hamiltonian Pairs</h2>
<p>One undirected edge per line, like <code>u v</code>. Listed edges get weight <code>-1</code>; all others are <code>0</code>.</p>
</div>
<label>Pairs data</label>
<p class="benchmarkMeta">Benchmark: DIMACS COLOR myciel3.col interpreted as an HC graph; locally verified Hamiltonian cycle exists.</p>
<textarea id="pairsInput" spellcheck="false">1 2
1 4
1 7
1 9
2 3
2 6
2 8
3 5
3 7
3 10
4 5
4 6
4 10
5 8
5 9
6 11
7 11
8 11
9 11
10 11</textarea>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="pairsFile" accept=".txt"></label>
<button id="runPairs">Run pairs solver</button>
</div>
</section>
<section id="matrix" class="panel">
<div class="panelHead">
<h2>TSP Weight Matrix</h2>
<p>First line is <code>n</code>, followed by an <code>n x n</code> symmetric weight matrix.</p>
</div>
<label>Matrix data</label>
<p class="benchmarkMeta">Benchmark: TSPLIB gr17, full symmetric matrix converted from lower-diagonal format, optimum tour length 2085.</p>
<textarea id="matrixInput" spellcheck="false">17
0 633 257 91 412 150 80 134 259 505 353 324 70 211 268 246 121
633 0 390 661 227 488 572 530 555 289 282 638 567 466 420 745 518
257 390 0 228 169 112 196 154 372 262 110 437 191 74 53 472 142
91 661 228 0 383 120 77 105 175 476 324 240 27 182 239 237 84
412 227 169 383 0 267 351 309 338 196 61 421 346 243 199 528 297
150 488 112 120 267 0 63 34 264 360 208 329 83 105 123 364 35
80 572 196 77 351 63 0 29 232 444 292 297 47 150 207 332 29
134 530 154 105 309 34 29 0 249 402 250 314 68 108 165 349 36
259 555 372 175 338 264 232 249 0 495 352 95 189 326 383 202 236
505 289 262 476 196 360 444 402 495 0 154 578 439 336 240 685 390
353 282 110 324 61 208 292 250 352 154 0 435 287 184 140 542 238
324 638 437 240 421 329 297 314 95 578 435 0 254 391 448 157 301
70 567 191 27 346 83 47 68 189 439 287 254 0 145 202 289 55
211 466 74 182 243 105 150 108 326 336 184 391 145 0 57 426 96
268 420 53 239 199 123 207 165 383 240 140 448 202 57 0 483 153
246 745 472 237 528 364 332 349 202 685 542 157 289 426 483 0 336
121 518 142 84 297 35 29 36 236 390 238 301 55 96 153 336 0</textarea>
<p class="fieldNote">For gr17, try c = 1.5 with HC backtrack tries = 4.</p>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="matrixFile" accept=".txt"></label>
<button id="runMatrix">Run TSP matrix</button>
</div>
</section>
<section id="points" class="panel">
<div class="panelHead">
<h2>TSP Euclidean Points</h2>
<p>First line is <code>n</code>, followed by <code>x y</code> point coordinates.</p>
</div>
<label>Points data</label>
<p class="benchmarkMeta">Benchmark: TSPLIB burma14 coordinates, converted to app Euclidean points; TSPLIB's official GEO optimum is not reused for Euclidean scoring.</p>
<textarea id="pointsInput" spellcheck="false">14
16.47 96.10
16.47 94.44
20.09 92.54
22.39 93.37
25.23 97.24
22.00 96.05
20.47 97.02
17.20 96.29
16.30 97.38
14.05 98.12
16.53 97.38
21.52 95.59
19.41 97.13
20.09 94.55</textarea>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="pointsFile" accept=".txt"></label>
<button id="runPoints">Run TSP points</button>
</div>
</section>
<section id="manual" class="panel">
<div class="panelHead">
<h2>TSP Manual Weights</h2>
<p>First line is <code>n</code>, then one upper-triangle weight per line in order: <code>(1,2), (1,3), ...</code>.</p>
</div>
<label>Manual edge data</label>
<p class="benchmarkMeta">Benchmark: TSPLIB gr17, upper-triangle manual weights derived from the same instance as the matrix tab, optimum 2085.</p>
<textarea id="manualInput" spellcheck="false">17
633
257
91
412
150
80
134
259
505
353
324
70
211
268
246
121
390
661
227
488
572
530
555
289
282
638
567
466
420
745
518
228
169
112
196
154
372
262
110
437
191
74
53
472
142
383
120
77
105
175
476
324
240
27
182
239
237
84
267
351
309
338
196
61
421
346
243
199
528
297
63
34
264
360
208
329
83
105
123
364
35
29
232
444
292
297
47
150
207
332
29
249
402
250
314
68
108
165
349
36
495
352
95
189
326
383
202
236
154
578
439
336
240
685
390
435
287
184
140
542
238
254
391
448
157
301
145
202
289
55
57
426
96
483
153
336</textarea>
<p class="fieldNote">For gr17, try c = 1.5 with HC backtrack tries = 4.</p>
<div class="controls">
<label class="fileButton">Load text file<input type="file" id="manualFile" accept=".txt"></label>
<button id="runManual">Run TSP manual</button>
</div>
</section>
<section class="outputPanel">
<div class="outputHead">
<h2>Output</h2>
<button id="clearOutput" title="Clear output">Clear</button>
</div>
<pre id="output">Ready.</pre>
</section>
</section>
</section>
</main>
<script src="app.js"></script>
<script>
if ("serviceWorker" in navigator && location.protocol !== "file:") {
navigator.serviceWorker.register("sw.js").catch(() => {});
}
</script>
</body>
</html>