linny-r 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +312 -0
  3. package/console.js +973 -0
  4. package/package.json +32 -0
  5. package/server.js +1547 -0
  6. package/static/fonts/FantasqueSansMono-Bold.ttf +0 -0
  7. package/static/fonts/FantasqueSansMono-BoldItalic.ttf +0 -0
  8. package/static/fonts/FantasqueSansMono-Italic.ttf +0 -0
  9. package/static/fonts/FantasqueSansMono-Regular.ttf +0 -0
  10. package/static/fonts/Hack-Bold.ttf +0 -0
  11. package/static/fonts/Hack-BoldItalic.ttf +0 -0
  12. package/static/fonts/Hack-Italic.ttf +0 -0
  13. package/static/fonts/Hack-Regular.ttf +0 -0
  14. package/static/fonts/Lato-Bold.ttf +0 -0
  15. package/static/fonts/Lato-BoldItalic.ttf +0 -0
  16. package/static/fonts/Lato-Italic.ttf +0 -0
  17. package/static/fonts/Lato-Regular.ttf +0 -0
  18. package/static/fonts/mplus-1m-bold.ttf +0 -0
  19. package/static/fonts/mplus-1m-light.ttf +0 -0
  20. package/static/fonts/mplus-1m-medium.ttf +0 -0
  21. package/static/fonts/mplus-1m-regular.ttf +0 -0
  22. package/static/fonts/mplus-1m-thin.ttf +0 -0
  23. package/static/images/access.png +0 -0
  24. package/static/images/actor.png +0 -0
  25. package/static/images/actors.png +0 -0
  26. package/static/images/add-selector.png +0 -0
  27. package/static/images/add.png +0 -0
  28. package/static/images/back.png +0 -0
  29. package/static/images/black-box.png +0 -0
  30. package/static/images/by-sa.svg +74 -0
  31. package/static/images/cancel.png +0 -0
  32. package/static/images/chart.png +0 -0
  33. package/static/images/check-disab.png +0 -0
  34. package/static/images/check-off.png +0 -0
  35. package/static/images/check-on.png +0 -0
  36. package/static/images/check-x.png +0 -0
  37. package/static/images/clone.png +0 -0
  38. package/static/images/close.png +0 -0
  39. package/static/images/cluster.png +0 -0
  40. package/static/images/compare.png +0 -0
  41. package/static/images/compress.png +0 -0
  42. package/static/images/constraint.png +0 -0
  43. package/static/images/copy.png +0 -0
  44. package/static/images/data-to-clpbrd.png +0 -0
  45. package/static/images/dataset.png +0 -0
  46. package/static/images/delete.png +0 -0
  47. package/static/images/diagram.png +0 -0
  48. package/static/images/down.png +0 -0
  49. package/static/images/edit-chart.png +0 -0
  50. package/static/images/edit.png +0 -0
  51. package/static/images/eq.png +0 -0
  52. package/static/images/equation.png +0 -0
  53. package/static/images/experiment.png +0 -0
  54. package/static/images/favicon.ico +0 -0
  55. package/static/images/fewer-dec.png +0 -0
  56. package/static/images/filter.png +0 -0
  57. package/static/images/find.png +0 -0
  58. package/static/images/forward.png +0 -0
  59. package/static/images/host-logo.png +0 -0
  60. package/static/images/icon.png +0 -0
  61. package/static/images/icon.svg +23 -0
  62. package/static/images/ignore.png +0 -0
  63. package/static/images/include.png +0 -0
  64. package/static/images/info-to-clpbrd.png +0 -0
  65. package/static/images/info.png +0 -0
  66. package/static/images/is-black-box.png +0 -0
  67. package/static/images/lbl.png +0 -0
  68. package/static/images/lift.png +0 -0
  69. package/static/images/link.png +0 -0
  70. package/static/images/linny-r.icns +0 -0
  71. package/static/images/linny-r.ico +0 -0
  72. package/static/images/linny-r.png +0 -0
  73. package/static/images/linny-r.svg +21 -0
  74. package/static/images/logo.png +0 -0
  75. package/static/images/model-info.png +0 -0
  76. package/static/images/module.png +0 -0
  77. package/static/images/monitor.png +0 -0
  78. package/static/images/more-dec.png +0 -0
  79. package/static/images/ne.png +0 -0
  80. package/static/images/new.png +0 -0
  81. package/static/images/note.png +0 -0
  82. package/static/images/ok.png +0 -0
  83. package/static/images/open.png +0 -0
  84. package/static/images/outcome.png +0 -0
  85. package/static/images/parent.png +0 -0
  86. package/static/images/paste.png +0 -0
  87. package/static/images/pause.png +0 -0
  88. package/static/images/print-chart.png +0 -0
  89. package/static/images/print.png +0 -0
  90. package/static/images/process.png +0 -0
  91. package/static/images/product.png +0 -0
  92. package/static/images/pwlf.png +0 -0
  93. package/static/images/receiver.png +0 -0
  94. package/static/images/redo.png +0 -0
  95. package/static/images/remove.png +0 -0
  96. package/static/images/rename.png +0 -0
  97. package/static/images/repo-logo.png +0 -0
  98. package/static/images/repository.png +0 -0
  99. package/static/images/reset.png +0 -0
  100. package/static/images/resize.png +0 -0
  101. package/static/images/restore.png +0 -0
  102. package/static/images/save-chart.png +0 -0
  103. package/static/images/save-data.png +0 -0
  104. package/static/images/save-diagram.png +0 -0
  105. package/static/images/save.png +0 -0
  106. package/static/images/sensitivity.png +0 -0
  107. package/static/images/settings.png +0 -0
  108. package/static/images/solve.png +0 -0
  109. package/static/images/solver-logo.png +0 -0
  110. package/static/images/stats-to-clpbrd.png +0 -0
  111. package/static/images/stats.png +0 -0
  112. package/static/images/stop.png +0 -0
  113. package/static/images/store.png +0 -0
  114. package/static/images/stretch.png +0 -0
  115. package/static/images/table-to-clpbrd.png +0 -0
  116. package/static/images/table.png +0 -0
  117. package/static/images/tree.png +0 -0
  118. package/static/images/tudelft.png +0 -0
  119. package/static/images/ubl.png +0 -0
  120. package/static/images/undo.png +0 -0
  121. package/static/images/up.png +0 -0
  122. package/static/images/zoom-in.png +0 -0
  123. package/static/images/zoom-out.png +0 -0
  124. package/static/index.html +3088 -0
  125. package/static/linny-r.css +4722 -0
  126. package/static/scripts/iro.min.js +7 -0
  127. package/static/scripts/linny-r-config.js +105 -0
  128. package/static/scripts/linny-r-ctrl.js +1199 -0
  129. package/static/scripts/linny-r-gui.js +14814 -0
  130. package/static/scripts/linny-r-milp.js +286 -0
  131. package/static/scripts/linny-r-model.js +10405 -0
  132. package/static/scripts/linny-r-utils.js +687 -0
  133. package/static/scripts/linny-r-vm.js +7079 -0
  134. package/static/show-diff.html +84 -0
  135. package/static/show-png.html +113 -0
  136. package/static/sounds/error.wav +0 -0
  137. package/static/sounds/notification.wav +0 -0
  138. package/static/sounds/warning.wav +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Delft University of Technology
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,312 @@
1
+ <img src="https://sysmod.tbm.tudelft.nl/linny-r/images/logo.png" height="55px" alt="Linny-R">
2
+
3
+ <p>Linny-R is an executable graphical specification language for mixed integer
4
+ <a href="https://en.wikipedia.org/wiki/Linear_programming" target="_blank">linear programming</a> (MILP) problems, especially
5
+ <a href="https://en.wikipedia.org/wiki/Unit_commitment_problem_in_electrical_power_production" target="_blank">unit commitment problems</a> (UCP) and
6
+ <a href="https://en.wikipedia.org/wiki/Generation_expansion_planning" target="_blank">generation expansion planning</a> (GEP).</p>
7
+
8
+ The graphical language and WYSIWYG model editor are developed by **Pieter Bots** at Delft University of Technology.
9
+
10
+ Originally implemented in Delphi Pascal, Linny-R is now developed in HTML+CSS+JavaScript
11
+ so as to be platform-independent and 100% transparent open source (under the MIT license).
12
+ The software comprises a server that runs on Node.js, and a graphical user interface (GUI) that runs in any modern browser.
13
+
14
+ You can play with the most recent release of Linny-R on
15
+ <a href="https://sysmod.tbm.tudelft.nl/linny-r" target="_blank">this server hosted at TU Delft</a>.
16
+ Note that this server imposes restrictions on solver time and the total number of blocks it will solve per run.
17
+ If you install Linny-R on your own machine, no such restrictions apply.
18
+
19
+ Documentation for Linny-R is still scant, but it is growing. You can contribute yourself (in "wiki fashion")
20
+ via the official documentation site https://linny-r.info.
21
+
22
+ ### Installing Node.js
23
+
24
+ Linny-R is developed as a JavaScript package, and requires that **Node.js** is installed on your computer.
25
+ Node.js can be downloaded from https://nodejs.org.
26
+ Make sure that you choose the correct installer for your computer.
27
+ Linny-R is developed using the *current* release. Presently (September 2022) this is 18.9.0.
28
+
29
+ Run the installer and accept the default settings.
30
+ There is **no** need to install the optional Tools for Native Modules.
31
+
32
+ Open the Command Line Interface (CLI) of your computer.
33
+ On macOS, this will be `Terminal`, on Windows `Command Prompt`.
34
+ Verify the installation by typing:
35
+
36
+ ``node --version``
37
+
38
+ The response should be the version number of Node.js, for example: v18.9.0.
39
+
40
+ ### Installing Linny-R
41
+ It is advisable to install Linny-R in a directory on your computer, not in a cloud.
42
+ In this installation guide, this directory is called `Linny-R`.
43
+ At the command line, change to the Linny-R directory (if you are not there already) and type:
44
+
45
+ ``npm install linny-r``
46
+
47
+ The Linny-R directory should now contain a new sub-directory `node_modules`,
48
+ and two JSON files `package.json` and `package-lock.json` that should **not** be removed,
49
+ or you will have to re-install Linny-R.
50
+
51
+ When configuring Linny-R for a network environment where individual users each have their personal work space (e.g., a virtual drive U:),
52
+ you can instruct Linny-R to create the `user` directory in this work space by adding the argument `workspace=[path]` to the `node` command.
53
+
54
+ The directory should contain this file `README.md`,
55
+ the files `server.js` and `console.js` that will be run by Node.js,
56
+ and the sub-directory `static`.
57
+ After installation has been completed, it will have two more subdirectories `user` and `node_modules`,
58
+ and a script file to facilitate (single click) launch: on a macOS machine the shell script `linny-r.command`,
59
+ on a Windows machine the batch script `linny-r.bat`.
60
+
61
+ The `static` directory should contain three HTML files:
62
+
63
+ * `index.html` (the browser-based GUI)
64
+ * `show-png.html` (to render SVG diagrams as PNG images)
65
+ * `show-diff.html` (to display differences betwee two Linny-R models)
66
+
67
+ It should also contain the style sheet `linny-r.css` required by the GUI.
68
+
69
+ The subdirectories of `static` contain files that are served to the browser by the script `server.js` when it is running in Node.js.
70
+
71
+ After installation has completed, the `Linny-R` directory should have this directory tree structure:
72
+
73
+ <pre>
74
+ Linny-R
75
+ |
76
+ +- static
77
+ | |
78
+ | + fonts
79
+ | |
80
+ | +- images
81
+ | |
82
+ | +- scripts
83
+ | |
84
+ | +- sounds
85
+ |
86
+ +- user
87
+ |
88
+ +-callback
89
+ |
90
+ +-channel
91
+ |
92
+ +-diagrams
93
+ |
94
+ +-modules
95
+ |
96
+ +-solver
97
+ </pre>
98
+
99
+ The sub-directories of the `user` directory are used by Linny-R to store files.
100
+
101
+ * `channel` and `callback` will be used to interact with Linny-R via its *Receiver*
102
+ * `diagrams` will be used to render Scalable Vector Graphics (SVG) files as Portable Network Graphics (PNG) using Inkscape (if installed)
103
+ * `modules` will contain models stored in the `local host` *repository*
104
+ * `solver` will contain the files that are exchanged with the Mixed Integer Linear Programming (MILP) solver
105
+ (the names of the files that will appear in this directory may vary, depending on the MILP-solver you use)
106
+
107
+ ### Configuring the MILP solver
108
+
109
+ Linny-R presently supports two MILP solvers: Gurobi and LP_solve.
110
+ Gurobi is *considerably* more powerful than the open source LP_solve solver that has powered Linny-R since 2009,
111
+ but it requires a license.
112
+ Academic licenses can be obtained by students and staff of eligible institutions.
113
+
114
+ #### Installing Gurobi
115
+
116
+ More information on how to obtain a license, and instructions for installing
117
+ Gurobi on your computer can be obtained via this URL:
118
+ https://www.gurobi.com/academia/academic-program-and-licenses/
119
+
120
+ When running a model, Linny-R will try to execute the command line application `gurobi_cl`.
121
+ It will look for this application in the directory specified in the environment variable PATH on your computer.
122
+
123
+ When installing Gurobi, please accept the default file locations that are proposed by the installer.
124
+ Then do **not** move Gurobi files to some other directory, as this is bound to cause problems.
125
+
126
+ #### Installing LP_solve
127
+
128
+ The LP_solve software is open source and can be downloaded via this URL:
129
+ https://sourceforge.net/projects/lpsolve
130
+
131
+ To facilitate installation, the executable files for Windows and macOS can be downloaded from the Linny-R website at Delft University of Technology:
132
+ https://sysmod.tbm.tudelft.nl/linny-r/lp_solve
133
+
134
+ There you will find links to download LP_solve applications that have been compiled for different platforms.
135
+ If you do not know which platform to choose, run Linny-R as described below, and the platform will be listed in its output.
136
+ If no matching LP_solve version is listed, you can try to compile the software from its source.
137
+ How to do this is explained on the page "Installing LP_solve on a Mac" on the Linny-R documentation site:
138
+ https://linny-r.info
139
+
140
+ When you have downloaded the file (just `lp_solve` for macOS, `lp_solve.exe` for Windows),
141
+ you must copy or move this file to the main Linny-R directory,
142
+ as this is where Linny-R will look for it when it does not find Gurobi.
143
+
144
+ On a macOS machine, you must then make the file `lp_solve` executable.
145
+ Open Terminal and change to your Linny-R directory, and then type:
146
+
147
+ ``chmod +x lp_solve``
148
+
149
+ When you then type:
150
+
151
+ ``./lp_solve -h``
152
+
153
+ a window may appear that warns you that the software may be malicious.
154
+ To allow running LP_solve, you must then go to Security & Privacy (via System Preferences)
155
+ and there click the Open Anyway button in the General pane to confirm that you wish to use LP_solve.
156
+ Then return to Terminal and once more type `./lp_solve -h`.
157
+ The response should then be a listing of all the command line options of LP_solve.
158
+ If you reach this stage, Linny-R will be able to run LP_solve.
159
+
160
+
161
+ ### Running Linny-R
162
+
163
+ Open the Command Line Interface (CLI) of your computer.
164
+ On macOS, this will be `Terminal`, on Windows `Command Prompt`.
165
+
166
+ At the CLI prompt, change to the main Linny-R directory that contains the file `server.js`.
167
+ Then type:
168
+
169
+ ``node server``
170
+
171
+ The response should be something similar to:
172
+
173
+ <pre>
174
+ Node.js server for Linny-R version 1.0
175
+ Node.js version: v18.9.0
176
+ </pre>
177
+
178
+ followed by some data on your Linny-R configuration. The last line will be something like:
179
+
180
+ <pre>
181
+ Listening at: http://127.0.0.1:5050
182
+ </pre>
183
+
184
+ Open your web browser and navigate to the given URL, which by default will be http://127.0.0.1:5050.
185
+ The Linny-R GUI should then appear in your browser window,
186
+ while in the CLI you should see a long series of server log messages like:
187
+
188
+ <pre>
189
+ Static file: /index.html
190
+ Static file: /scripts/iro.min.js
191
+ Static file: /images/open.png
192
+ ... etc.
193
+ </pre>
194
+
195
+ After loading into the browser, Linny-R will try to connect to the solver.
196
+ If successful, a notification (blue background) will appear on the status bar at the bottom of the window,
197
+ stating the name of the solver.
198
+
199
+ You can then test the GUI by creating a simple model.
200
+ Make one that has at least one process that outputs a product,
201
+ and this product must have a price or a set lower bound, otherwise the model will have no objective function.
202
+ Then click on the *Solve* button at the bottom of the left-hand tool bar.
203
+ The Linny-R icon in the upper left corner should start rotating, while the status bar at the bottom should display:
204
+
205
+ <pre>
206
+ Solving block 1 of 1
207
+ </pre>
208
+
209
+ For a small test model, this message should appear only very briefly,
210
+ and then the diagram will be updated to reflect the obtained solution.
211
+ Meanwhile, in the CLI, you should see a server log message like:
212
+
213
+ <pre>
214
+ Solve block 1 a
215
+ </pre>
216
+
217
+ #### Command line options
218
+
219
+ Optionally, you can add more arguments to the `node` command:
220
+
221
+ <pre>
222
+ launch to automatically launch Linny-R in your default browser
223
+ port=[number] to overrule the default port number (5050)
224
+ solver=[name] to overrule the default sequence (Gurobi, LP_solve)
225
+ workspace=[path] to overrule the default path for the user directory
226
+ dpi=[number] to overrule the default resolution (300 dpi) for Inkscape
227
+ </pre>
228
+
229
+ ### Installing Inkscape
230
+
231
+ Linny-R creates its diagrams and charts as SVG images.
232
+ When you download a diagram, it will be saved as a .svg file.
233
+ These files can be viewed and edited using Inkscape, an open source vector graphics editor.
234
+
235
+ As it may be tedious to first save a diagram as SVG and then render it manually as a bitmap image,
236
+ Linny-R features a *Render diagram as bitmap* button on the top toolbar, and on the bottom toolbar of the *Chart manager*.
237
+ When you click it, Linny-R will send the image as SVG to the server.
238
+ The server script will save the SVG in the `user/diagrams` sub-directory,
239
+ and then try to execute an Inkscape command that will convert this SVG to a PNG image file in the same directory.
240
+ The file name will be `diagram-(date and time).png`.
241
+ Meanwhile, the browser will have opened a new tab that will be "waiting" for this PNG image to become available.
242
+ If rendering was successful, the image will appear in this browser tab;
243
+ if rendering failed, the original SVG image will be shown.
244
+
245
+ To install Inkscape, please look here: https://inkscape.org/release
246
+
247
+ Linny-R will automatically detect whether Inkscape is installed by searching for it in the environment variable PATH on your computer.
248
+ On a macOS computer, Linny-R will look for Inkscape in /Applications/Inkscape.app/Contents/MacOS.
249
+
250
+ **NOTE:** The current installation wizard for Inkscape (version 1.2) does **not** add the application to the PATH variable,
251
+ so you need to do this yourself.
252
+
253
+ ### Click-start for Linny-R
254
+
255
+ To facilitate start-up, you can create a shortcut icon on your desktop.
256
+
257
+ On a Windows machine, change to your Linny-R folder, right-click on the batch file `linny-r.bat`,
258
+ and select the *Create shortcut* option.
259
+ Then right-click on the shortcut file to edit its properties, and click the *Change Icon* button.
260
+ The dialog that then appears will allow you to go to the sub-folder `static\images`,
261
+ where you should select the file `linny-r.ico`.
262
+ Finally, rename the shortcut to `Linny-R` and move or copy it to your desktop.
263
+
264
+ On a macOS machine, open Terminal and change to your Linny-R directory, and then type:
265
+
266
+ ``chmod +x linny-r.command``
267
+
268
+ to make the script file executable.
269
+ To set the icon, click on the icon of `linny-r.command` (which still is plain) and open the Info dialog by pressing ``Cmd+I``.
270
+ Then open your Linny-R folder in the Finder, change to the sub-folder `static/images`,
271
+ and from there drag/drop the file `linny-r.icns` on the icon shown in the top left corner of the Info dialog.
272
+
273
+
274
+ ### Normal use after installation
275
+
276
+ If you have not configured a "click-start" icon as described above,
277
+ you must start a modeling session with Linny-R by opening a CLI box,
278
+ then change to the Linny-R directory, type `node server`,
279
+ open your browser, and then navigate to http://127.0.0.1:5050
280
+
281
+ To shut down the server, click on the local host icon in the upper right corner of the Linny-R GUI in your browser.
282
+ Alternatively, you can stop the server by repeatedly pressing ``Ctrl+C`` in the CLI box.
283
+
284
+ Pressing ``Ctrl+C`` in the Terminal window on a macOS machine may not stop the process.
285
+ In that case, you can stop Node.js by stopping the Terminal.
286
+
287
+
288
+ ### Using Linny-R console
289
+
290
+ The console-only version of Linny-R allows you to run a Linny-R model without a web browser.
291
+ This may be useful when you want run models from a script (shell script, Python, ...).
292
+ If you open a CLI box, change to the main Linny-R directory, and then type:
293
+
294
+ ``node console``
295
+
296
+ you will see the command line options that allow you to run models in various ways.
297
+
298
+ **NOTE: The console-only version is still in development, and does not provide all functions yet.**
299
+
300
+ ### Troubleshooting problems
301
+
302
+ If during any of the steps above you encounter problems, please try to diagnose them and resolve them yourself.
303
+ You can find a lot of useful information on the Linny-R documentatio website: https://linny-r.info
304
+
305
+ To diagnose a problem, always look in the CLI box where Node.js is running,
306
+ as informative server-side error messages will appear there.
307
+
308
+ Then also look at the console window of your browser.
309
+ Most browsers offer a Web Developer Tools option via their application menu.
310
+ This will allow you to view the browser console, which will display JavaScript errors in red font.
311
+
312
+ If you've tried hard, but failed, you can try to contact Pieter Bots at ``p.w.g.bots@tudelft.nl``