linny-r 2.0.2 → 2.0.4

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.
package/README.md CHANGED
@@ -56,7 +56,7 @@ in a cloud.
56
56
 
57
57
  In this installation guide, the path to this directory is denoted by `Linny-R`,
58
58
  so in all commands you should replace this with the actual directory path.
59
- On a Windows machine the suggested path is `C:\Users\(your user name)\Documents\Linny-R`,
59
+ On a Windows machine the suggested path is `C:\Users\(your user name)\Linny-R`,
60
60
  and on a macOS machine `/Users/(your user name)/Linny-R`.
61
61
 
62
62
  To install Linny-R in this directory, first change to the parent directory
@@ -104,20 +104,50 @@ Linny-R
104
104
 
105
105
  `Linny-R` should contain two JSON files `package.json` and `package-lock.json`
106
106
  that should **not** be removed, or you will have to re-install Linny-R.
107
+ It should also contain the launch script. On a macOS machine, this will be
108
+ the shell script `linny-r.command`, on a Windows machine the batch script
109
+ `linny-r.bat`.
110
+
111
+ All other software is contained in the `node_modules` directory. It comprises
112
+ two Node.js packages: `@xlmdom` and `linny-r`.
107
113
 
108
- The `linny-r` directory should also contain this file `README.md`,
109
- the files `server.js` and `console.js` that will be run by Node.js,
110
- and the sub-directory `static`. This `static` directory should contain three
111
- HTML files:
114
+ The `linny-r` package directory should contain this file `README.md`, the files
115
+ `server.js` and `console.js` that will be run by Node.js, and the sub-directory
116
+ `static`. This `static` directory should contain three HTML files:
112
117
 
113
118
  * `index.html` (the browser-based GUI)
114
119
  * `show-png.html` (to render SVG diagrams as PNG images)
115
- * `show-diff.html` (to display differences betwee two Linny-R models)
120
+ * `show-diff.html` (to display differences between two Linny-R models)
116
121
 
117
122
  It should also contain the style sheet `linny-r.css` required by the GUI.
118
123
 
119
124
  The sub-directories of `static` contain files that are served to the browser
120
- by the script `server.js` when it is running in Node.js.
125
+ by the script `server.js` when it is running in Node.js.
126
+
127
+ > [!IMPORTANT]
128
+ > Unless you _really_ know what you are doing, do **not** move or rename
129
+ > your Linny-R directory or change its contents. If for some reason Linny-R
130
+ > does not work, remove _all_ Linny-R software from your machine, and then
131
+ > install it anew, following the procedure described above.
132
+
133
+ #### Updating to the latest version of Linny-R
134
+
135
+ When a newer version has beeh released, Linny-R will prompt you to update
136
+ automatically. Click on the link in this prompt to see the release notes
137
+ on GitHub and find out about new features and bug fixes. When you click on
138
+ the _OK_ button, Linny-R will shut down its local server script, and then
139
+ the launch script should perform the `npm update` command and then restart
140
+ the server script. Your browser will prompt you to close its current tab,
141
+ and then Linny-R should reappear in a new browser tab or window.
142
+
143
+ > [!NOTE]
144
+ > The built-in updating function of Linny-R will _**not**_ automatically
145
+ > upgrade to a new _major_ version. To update from a version like 1.9.x to
146
+ > a version like 2.0.x, you have to open a command line interface
147
+ > (`Command Prompt` or `Terminal`), change to your Linny-R directory, and
148
+ > then type `npm install linny-r@2`. This should perform the upgrade.
149
+ > You can then launch Linny-R as usual by typing `linny-r` (Windows) or
150
+ > `./linny-r.command` (macOS).
121
151
 
122
152
  #### Installing and using an earlier version of Linny-R
123
153
 
@@ -234,7 +264,7 @@ as this is where Linny-R will look for it when it does not find one of the
234
264
  other solvers.
235
265
 
236
266
  On a macOS machine, you must then make the file `lp_solve` executable.
237
- Open Terminal and change to your Linny-R directory, and then type:
267
+ Open `Terminal` and change to your Linny-R directory, and then type:
238
268
 
239
269
  ``chmod +x lp_solve``
240
270
 
@@ -243,37 +273,36 @@ When you then type:
243
273
  ``./lp_solve -h``
244
274
 
245
275
  a window may appear that warns you that the software may be malicious.
246
- To allow running LP_solve, you must then go to Security & Privacy (via
247
- System Preferences) and there click the Open Anyway button in the General
248
- pane to confirm that you wish to use LP_solve. Then return to Terminal
276
+ To allow running LP_solve, you must then go to _Security & Privacy_ (via
277
+ _System Preferences_) and there click the _Open Anyway_ button in the _General_
278
+ pane to confirm that you wish to use LP_solve. Then return to `Terminal`
249
279
  and once more type `./lp_solve -h`. The response should then be a listing
250
280
  of all the command line options of LP_solve. If you reach this stage,
251
281
  Linny-R will be able to run LP_solve.
252
282
 
253
283
  ## Running Linny-R
254
284
 
255
- Open the Command Line Interface (CLI) of your computer, change to your
256
- Linny-R directory and type:
285
+ On a Windows machine, open `Command Prompt`, change to your Linny-R
286
+ directory and type:
257
287
 
258
- ``node node_modules/linny-r/server launch``
288
+ ``linny-r``
259
289
 
260
- This response should be something similar to:
290
+ On a macOS machine, open `Terminal`, change to your Linny-R directory
291
+ and type:
261
292
 
262
- <pre>
263
- Node.js server for Linny-R version 2.0.0
264
- Node.js version: v22.2.0
265
- ... etc.
266
- </pre>
293
+ ``./linny-r.command``
267
294
 
295
+ This should run the launch script for Linny-R, which will start the
296
+ local server script that connects your browser with the solver.
268
297
  Meanwhile, your default web browser should have opened a tab for the local
269
298
  server URL, which by default will be http://127.0.0.1:5050.
270
299
  The Linny-R GUI should show in your browser window, while in the CLI you
271
300
  should see a long series of server log messages like:
272
301
 
273
302
  <pre>
274
- [2023-11-19 22:55:17] Static file: /index.html
275
- [2023-11-19 22:55:17] Static file: /scripts/iro.min.js
276
- [2023-11-19 22:55:17] Static file: /images/open.png
303
+ [2024-06-11 22:55:17] Static file: /index.html
304
+ [2024-06-11 22:55:17] Static file: /scripts/iro.min.js
305
+ [2024-06-11 22:55:17] Static file: /images/open.png
277
306
  ... etc.
278
307
  </pre>
279
308
 
@@ -281,7 +310,7 @@ should see a long series of server log messages like:
281
310
  > Do **not** close the CLI. If you do, the Linny-R GUI may still be
282
311
  > visible in your browser, but you will be warned that it cannot connect
283
312
  > to the server (at 127.0.0.1:5050). This means that you have to restart
284
- > Linny-R from a new CLI.
313
+ > Linny-R as described above.
285
314
 
286
315
  After loading into the browser, Linny-R will try to connect to the solver.
287
316
  If successful, a notification (blue background) will appear on the status
@@ -313,36 +342,18 @@ confirming that you want to leave, and then closing your browser (tab).
313
342
  If you do not shut down the server from the browser, you can also stop the
314
343
  server by repeatedly pressing ``Ctrl+C`` in the CLI.
315
344
 
316
- ## Command line options
317
-
318
- Optionally, you can add more arguments to the `node` command:
319
-
320
- <pre>
321
- dpi=[number] to overrule the default resolution (300 dpi) for Inkscape
322
- launch to automatically launch Linny-R in your default browser
323
- port=[number] to overrule the default port number (5050)
324
- solver=[name] to overrule the default sequence (Gurobi, MOSEK, CPLEX, SCIP, LP_solve)
325
- workspace=[path] to overrule the default path for the user directory
326
- </pre>
327
-
328
345
  ## Click-start for Linny-R
329
346
 
330
- The first time you start Linny-R after a fresh install or an update,
331
- you will have to open the Command Line Interface (CLI) of your computer,
332
- change to your Linny-R directory and type:
347
+ When `npm` installs the Linny-R package, it creates a script file in your
348
+ Linny-R directory that launches Linny-R. On a macOS machine, this will be
349
+ the shell script `linny-r.command`, on a Windows machine the batch script
350
+ `linny-r.bat`. When you create a desktop shortcut to this script, this will
351
+ allow you to click-start Linny-R.
333
352
 
334
- ``node node_modules/linny-r/server launch``
353
+ How you can create a shortcut icon for Linny-R on your desktop depends on
354
+ the type of computer you use.
335
355
 
336
- This will not only start Linny-R, but also create a script file in your
337
- Linny-R directory that will allow you to start Linny-R by clicking its
338
- icon on your machine. On a macOS machine, this fill will be the shell
339
- script `linny-r.command`, on a Windows machine the batch script
340
- `linny-r.bat`.
341
-
342
- To facilitate start-up, you can create a shortcut icon for Linny-R on your
343
- desktop.
344
-
345
- On a Windows machine, open the _File Explorer_, select your Linny-R folder,
356
+ On a Windows machine, open the `File Explorer`, select your Linny-R folder,
346
357
  right-click on the batch file `linny-r.bat`, and select the _Create shortcut_
347
358
  option. Then right-click on the shortcut file to edit its properties, and
348
359
  click the _Change Icon_ button. The dialog that then appears will allow
@@ -350,22 +361,35 @@ you to go to the sub-folder `node_modules\linny-r\static\images`, where
350
361
  you should select the file `linny-r.ico`. Finally, rename the shortcut to
351
362
  `Linny-R` and move or copy it to your desktop.
352
363
 
353
- On a macOS machine, open Terminal and change to your Linny-R directory,
364
+ On a macOS machine, open `Terminal` and change to your Linny-R directory,
354
365
  and then type:
355
366
 
356
367
  ``chmod +x linny-r.command``
357
368
 
358
- to make the script file executable. To set the icon, use Finder to open
369
+ to make the script file executable. To set the icon, use `Finder` to open
359
370
  the folder that contains the file `linny-r.command`, click on its icon
360
371
  (which still is plain) and open the _Info dialog_ by pressing ``Cmd+I``.
361
- Then open your Linny-R folder in Finder, change to the sub-folder
372
+ Then open your Linny-R folder in `Finder`, change to the sub-folder
362
373
  `node_modules/linny-r/static/images`, and from there drag/drop the file
363
374
  `linny-r.icns` on the icon shown in the top left corner of the _Info dialog_.
364
375
 
376
+ ## Command line options
377
+
378
+ You can customize Linny-R by adding more arguments to the `node` command
379
+ in the launch script:
380
+
381
+ <pre>
382
+ dpi=[number] to overrule the default resolution (300 dpi) for Inkscape
383
+ launch to automatically launch Linny-R in your default browser
384
+ port=[number] to overrule the default port number (5050)
385
+ solver=[name] to overrule the default sequence (Gurobi, MOSEK, CPLEX, SCIP, LP_solve)
386
+ workspace=[path] to overrule the default path for the user directory
387
+ </pre>
388
+
365
389
  > [!NOTE]
366
390
  > When configuring Linny-R for a network environment where individual users
367
- > each have their personal work space (e.g., a virtual drive U:), you must
368
- > edit this script file, adding the argument `workspace=path/to/workspace`
391
+ > each have their personal work space (e.g., a virtual drive U:), you **must**
392
+ > edit the launch script file, adding the argument `workspace=path/to/workspace`
369
393
  > to the `node` command. This will instruct Linny-R to create the `user`
370
394
  > directory in this workspace directory instead of the Linny-R directory.
371
395
 
@@ -380,6 +404,8 @@ The sub-directories of this directory `user` are used by Linny-R to store files.
380
404
  a path has been specified
381
405
  * `diagrams` will be used to render Scalable Vector Graphics (SVG) files as
382
406
  Portable Network Graphics (PNG) using Inkscape (if installed)
407
+ * `models` will contain models that you saved by Shift-clicking on the
408
+ _Save_ button, or using the keyboard shortcut Ctrl-Shift-S
383
409
  * `modules` will contain models stored in the `local host` _repository_
384
410
  * `reports` will contain text files with time series data and statistics in
385
411
  tab-separated format that can be imported or copy/pasted into Excel
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linny-r",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Executable graphical language with WYSIWYG editor for MILP models",
5
5
  "main": "server.js",
6
6
  "scripts": {
package/server.js CHANGED
@@ -255,22 +255,24 @@ function clearNewerVersion() {
255
255
  }
256
256
 
257
257
  // HTML page to show when the server is shut down by the user.
258
- // NOTE: on a macOS machine, this is slightly more work
259
- const OS_TEXT = {close: '', reopen: ''};
260
- if(PLATFORM === 'darwin') {
261
- OS_TEXT.close =
262
- `<p>You can close the <em>Terminal</em> window that shows
263
- <tt>[Process Terminated]</tt> at the bottom.
264
- </p>`;
265
- OS_TEXT.reopen =
266
- `open <em>Terminal</em> again, change to your Linny-R directory by typing:
258
+ // Parts of the text are platform-specific.
259
+ const
260
+ macOS = (PLATFORM === 'darwin'),
261
+ close = (macOS ?
262
+ `<p>You can now close the <em>Terminal</em> window that shows
263
+ <tt>[Process Terminated]</tt> at the bottom.</p>` :
264
+ `<p>The <em>Command Prompt</em> window where the server was
265
+ running will be closed automatically.</p>`),
266
+ cli = (macOS ? 'Terminal' : 'Command Prompt'),
267
+ ext = (macOS ? '.command' : ''),
268
+ chmod = (!macOS ? '' : `
269
+ <p>If launch fails, you may still need to make the script executable.</p>
270
+ <p>
271
+ You can do this by typing <code>chmod +x linny-r.command</code>
272
+ at the command prompt.
267
273
  </p>
268
- <p><code>cd ${WORKING_DIRECTORY}</code></p>
269
- <p>`;
270
- } else {
271
- OS_TEXT.reopen = 'switch to your <em>Command Prompt</em> window ';
272
- }
273
- const SHUTDOWN_MESSAGE = `<!DOCTYPE html>
274
+ <p>Then retype <code>linny-r.command</code> to launch Linny-R.</p>`),
275
+ SHUTDOWN_MESSAGE = `<!DOCTYPE html>
274
276
  <html lang="en-US">
275
277
  <head>
276
278
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
@@ -290,16 +292,18 @@ const SHUTDOWN_MESSAGE = `<!DOCTYPE html>
290
292
  </style>
291
293
  </head>
292
294
  <body>
293
- <h3>Linny-R server (127.0.0.1) is shutting down</h3>${OS_TEXT.close}
294
- <p>To restart Linny-R, ${OS_TEXT.reopen} and then at the prompt type:</p>
295
- <p><code>node node_modules${path.sep}linny-r${path.sep}server</code></p>
295
+ <h3>Linny-R server (127.0.0.1) is shutting down</h3>${close}
296
296
  <p>
297
- Then switch back to this window, and click this
298
- <button type="button"
299
- onclick="window.location.href = 'http://127.0.0.1:${SETTINGS.port}';">
300
- Restart
301
- </button> button.
297
+ To restart Linny-R, open <em>${cli}</em> again, change to
298
+ your Linny-R directory by typing:
302
299
  </p>
300
+ <p><code>cd ${WORKING_DIRECTORY}</code></p>
301
+ <p>and then type:</p>
302
+ <p><code>linny-r${ext}</code></p>
303
+ <p>
304
+ This should launch Linny-R in a new browser window or tab, so you
305
+ can close this one.
306
+ </p>${chmod}
303
307
  </body>
304
308
  </html>`;
305
309
 
@@ -9006,13 +9006,15 @@ function VMI_add_bound_line_constraint(args) {
9006
9006
  vy = VM.variables[viy - 1],
9007
9007
  objy= vy[1],
9008
9008
  uby = args[5].result(VM.t),
9009
- bl = args[6],
9009
+ bl = args[6];
9010
+ // Set bound line point coordinates for current run and time step.
9011
+ bl.setDynamicPoints(VM.t);
9012
+ // Then use the actualized points.
9013
+ const
9010
9014
  n = bl.points.length,
9011
9015
  x = new Array(n),
9012
9016
  y = new Array(n),
9013
9017
  w = new Array(n);
9014
- // Set bound line point coordinates for current run and time step.
9015
- bl.setDynamicPoints(VM.t);
9016
9018
  if(DEBUGGING) {
9017
9019
  console.log('add_bound_line_constraint:', bl.displayName);
9018
9020
  }