Debian Codegraph @

app/highs_webdemo_shell.html

raw symbols SCIP
1 <!doctype html>
2 <!-- compare https://github.com/emscripten-core/emscripten/blob/main/src/shell_minimal.html -->
3 <html lang="en-us">
4 <head>
5 <meta charset="utf-8">
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7 <title>HiGHS</title>
8 </head>
9 <body>
10 <div style="display: grid; grid-template-columns: 1fr 1fr">
11 <textarea id="input" style="height: 700px">
12 </textarea>
13 <textarea id="output"></textarea>
14 <button id="run">Optimize!</button>
15 </div>
16 {{{ SCRIPT }}}
17 <script type='text/javascript'>
18 main = async () => {
19 const printInTextarea = function(text) {
20 if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
21 // These replacements are necessary if you render to raw HTML
22 //text = text.replace(/&/g, "&amp;");
23 //text = text.replace(/</g, "&lt;");
24 //text = text.replace(/>/g, "&gt;");
25 //text = text.replace('\n', '<br>', 'g');
26 // console.log(text);
27 if (element) {
28 element.value += text + "\n";
29 element.scrollTop = element.scrollHeight; // focus on bottom
30 }
31 }
32
33 const highs = await HiGHS({
34 print: printInTextarea,
35 printErr: printInTextarea
36 })
37
38 const inputTextarea = document.getElementById('input');
39 inputTextarea.value = `Maximize
40 obj: x1 + 2 x2 + 3 x3 + x4
41 Subject To
42 c1: - x1 + x2 + x3 + 10 x4 <= 20
43 c2: x1 - 3 x2 + x3 <= 30
44 c3: x2 - 3.5 x4 = 0
45 Bounds
46 0 <= x1 <= 40
47 2 <= x4 <= 3
48 General
49 x4
50 End`;
51
52 const element = document.getElementById('output');
53 const clearOutput = (v) => {
54 element.value = v || '';
55 }
56
57 clearOutput('Click on "Optimize!"') // clear browser cache
58
59 const runButton = document.getElementById('run');
60 runButton.addEventListener("click", () => {
61 clearOutput()
62 const inputFilename = 'inputFile.lp'
63 highs.FS.writeFile(inputFilename, inputTextarea.value)
64 highs.callMain([inputFilename])
65 })
66
67 }
68
69 main()
70
71 </script>
72 </body>
73 </html>