linny-r 1.6.5 → 1.6.7

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linny-r",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
4
4
  "description": "Executable graphical language with WYSIWYG editor for MILP models",
5
5
  "main": "server.js",
6
6
  "scripts": {
@@ -305,14 +305,15 @@ class ActorManager {
305
305
  // Set its round flags
306
306
  a.round_flags = ali[2];
307
307
  // Double-check: parse expression if weight has been changed.
308
- if(a.weight.text != ali[3]) {
309
- xp.expr = monoSpacedVariables(ali[3]);
308
+ const awx = monoSpacedVariables(ali[3]);
309
+ if(a.weight.text != awx) {
310
+ xp.expr = awx;
310
311
  xp.compile();
311
312
  if(xp.error) {
312
313
  UI.warningInvalidWeightExpression(a, xp.error);
313
314
  ok = false;
314
315
  } else {
315
- a.weight.update(ali[3]);
316
+ a.weight.update(xp);
316
317
  }
317
318
  }
318
319
  // Update import/export status
@@ -332,6 +332,9 @@ class GUIExperimentManager extends ExperimentManager {
332
332
  document.getElementById('xp-reset-btn').classList.add('off');
333
333
  }
334
334
  this.updateParameters();
335
+ // NOTE: When UpdateDialog is called after an entity has been renamed,
336
+ // its variable list should be updated.
337
+ this.updateViewerVariable();
335
338
  }
336
339
 
337
340
  updateParameters() {
@@ -515,6 +518,10 @@ class GUIExperimentManager extends ExperimentManager {
515
518
  addDistinct(vn, vl);
516
519
  }
517
520
  vl.sort((a, b) => UI.compareFullNames(a, b));
521
+ // NOTE: When the selected variable entity has been renamed, its
522
+ // name will not be in the list (and its old name cannot be inferred)
523
+ // so then clear it.
524
+ if(vl.indexOf(x.selected_variable) < 0) x.selected_variable = '';
518
525
  for(let i = 0; i < vl.length; i++) {
519
526
  const vn = vl[i];
520
527
  // NOTE: FireFox selector dropdown areas have a pale gray
@@ -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('0');
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 the
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 time step t
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];