linny-r 1.6.6 → 1.6.8
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/package.json
CHANGED
@@ -443,6 +443,7 @@ class GUIController extends Controller {
|
|
443
443
|
// Keep track of time since last message displayed on the infoline.
|
444
444
|
this.time_last_message = new Date('01 Jan 2001 00:00:00 GMT');
|
445
445
|
this.message_display_time = 3000;
|
446
|
+
this.last_message_type = '';
|
446
447
|
|
447
448
|
// Initialize "main" modals, i.e., those that relate to the controller,
|
448
449
|
// not to other dialog objects.
|
@@ -2572,28 +2573,32 @@ class GUIController extends Controller {
|
|
2572
2573
|
// Displays message on infoline unless no type (= plain text) and some
|
2573
2574
|
// info, warning or error message is already displayed
|
2574
2575
|
super.setMessage(msg, type);
|
2576
|
+
const types = ['notification', 'warning', 'error'];
|
2575
2577
|
let d = new Date(),
|
2576
2578
|
t = d.getTime(),
|
2577
|
-
dt = t - this.time_last_message
|
2579
|
+
dt = t - this.time_last_message,
|
2580
|
+
mti = types.indexOf(type),
|
2581
|
+
lmti = types.indexOf(this.last_message_type);
|
2578
2582
|
if(type) {
|
2579
|
-
//
|
2580
|
-
this.time_last_message = t;
|
2581
|
-
dt = this.message_display_time;
|
2582
|
-
SOUNDS[type].play().catch(() => {
|
2583
|
-
console.log('NOTICE: Sounds will only play after first user action');
|
2584
|
-
});
|
2583
|
+
// Only log "real" messages.
|
2585
2584
|
const
|
2586
2585
|
now = [d.getHours(), d.getMinutes().toString().padStart(2, '0'),
|
2587
2586
|
d.getSeconds().toString().padStart(2, '0')].join(':'),
|
2588
2587
|
im = {time: now, text: msg, status: type};
|
2589
2588
|
DOCUMENTATION_MANAGER.addMessage(im);
|
2590
|
-
// When receiver is active, add message to its log
|
2589
|
+
// When receiver is active, add message to its log.
|
2591
2590
|
if(RECEIVER.active) RECEIVER.log(`[${now}] ${msg}`);
|
2592
2591
|
}
|
2593
|
-
// Display text only if previous message has "timed out" or was
|
2594
|
-
|
2592
|
+
// Display text only if previous message has "timed out" or was less
|
2593
|
+
// urgent than this one.
|
2594
|
+
if(mti > lmti || dt >= this.message_display_time) {
|
2595
|
+
this.time_last_message = t;
|
2596
|
+
this.last_message_type = type;
|
2597
|
+
if(type) SOUNDS[type].play().catch(() => {
|
2598
|
+
console.log('NOTICE: Sounds will only play after first user action');
|
2599
|
+
});
|
2595
2600
|
const il = document.getElementById('info-line');
|
2596
|
-
il.classList.remove(
|
2601
|
+
il.classList.remove(...types);
|
2597
2602
|
il.classList.add(type);
|
2598
2603
|
il.innerHTML = msg;
|
2599
2604
|
}
|
@@ -295,7 +295,7 @@ module.exports = class MILPSolver {
|
|
295
295
|
vnr = parseInt(v.substring(1));
|
296
296
|
// Add zeros for unreported variables until column number matches.
|
297
297
|
while(col < vnr) {
|
298
|
-
x_values.push(
|
298
|
+
x_values.push(0);
|
299
299
|
col++;
|
300
300
|
}
|
301
301
|
x_values.push(x_dict[v]);
|
@@ -397,7 +397,7 @@ module.exports = class MILPSolver {
|
|
397
397
|
// Fill dictionary with variable name: value entries
|
398
398
|
while(i < output.length) {
|
399
399
|
const m = output[i].match(/^.*name="(X[^"]+)".*value="([^"]+)"/);
|
400
|
-
if(m !== null) x_dict[m[1]] = m[2];
|
400
|
+
if(m !== null) x_dict[m[1]] = parseFloat(m[2]);
|
401
401
|
i++;
|
402
402
|
}
|
403
403
|
// Fill the solution vector, adding 0 for missing columns
|
@@ -453,7 +453,7 @@ module.exports = class MILPSolver {
|
|
453
453
|
// Fill dictionary with variable name: value entries
|
454
454
|
while(i < output.length) {
|
455
455
|
const v = output[i].split(/\s+/);
|
456
|
-
x_dict[v[0]] = v[1];
|
456
|
+
x_dict[v[0]] = parseFloat(v[1]);
|
457
457
|
i++;
|
458
458
|
}
|
459
459
|
// Fill the solution vector, adding 0 for missing columns
|
@@ -485,7 +485,7 @@ module.exports = class MILPSolver {
|
|
485
485
|
// Fill dictionary with variable name: value entries
|
486
486
|
while(i < output.length) {
|
487
487
|
const v = output[i].split(/\s+/);
|
488
|
-
x_dict[v[0]] = v[1];
|
488
|
+
x_dict[v[0]] = parseFloat(v[1]);
|
489
489
|
i++;
|
490
490
|
}
|
491
491
|
// Fill the solution vector, adding 0 for missing columns
|
@@ -5,8 +5,8 @@ The Linny-R language and tool have been developed by Pieter Bots at Delft
|
|
5
5
|
University of Technology, starting in 2009. The project to develop a browser-
|
6
6
|
based version started in 2017. See https://linny-r.org for more information.
|
7
7
|
|
8
|
-
This JavaScript file (linny-r-classes.js) defines the object classes used in
|
9
|
-
Linny-R project.
|
8
|
+
This JavaScript file (linny-r-classes.js) defines the object classes used in
|
9
|
+
the Linny-R project.
|
10
10
|
*/
|
11
11
|
|
12
12
|
/*
|
@@ -7468,7 +7468,8 @@ class Node extends NodeBox {
|
|
7468
7468
|
}
|
7469
7469
|
|
7470
7470
|
actualLevel(t) {
|
7471
|
-
// Returns the production level c.q. stock level for this node in
|
7471
|
+
// Returns the production level c.q. stock level for this node in
|
7472
|
+
// time step t.
|
7472
7473
|
if(t < 0) return this.initial_level.result(1);
|
7473
7474
|
if(t < this.level.length) return this.level[t];
|
7474
7475
|
return VM.UNDEFINED;
|
@@ -7476,7 +7477,7 @@ class Node extends NodeBox {
|
|
7476
7477
|
|
7477
7478
|
nonZeroLevel(t) {
|
7478
7479
|
// Returns the level or 0 when level is negligible relative to the
|
7479
|
-
// bounds on the node
|
7480
|
+
// bounds on the node.
|
7480
7481
|
if(t < 0) return this.initial_level.result(1);
|
7481
7482
|
if(t < this.level.length) {
|
7482
7483
|
const l = this.level[t];
|