linny-r 1.4.2 → 1.4.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.
Files changed (50) hide show
  1. package/README.md +162 -74
  2. package/package.json +1 -1
  3. package/server.js +145 -49
  4. package/static/images/check-off-not-same-changed.png +0 -0
  5. package/static/images/check-off-not-same-not-changed.png +0 -0
  6. package/static/images/check-off-same-changed.png +0 -0
  7. package/static/images/check-off-same-not-changed.png +0 -0
  8. package/static/images/check-on-not-same-changed.png +0 -0
  9. package/static/images/check-on-not-same-not-changed.png +0 -0
  10. package/static/images/check-on-same-changed.png +0 -0
  11. package/static/images/check-on-same-not-changed.png +0 -0
  12. package/static/images/eq-not-same-changed.png +0 -0
  13. package/static/images/eq-not-same-not-changed.png +0 -0
  14. package/static/images/eq-same-changed.png +0 -0
  15. package/static/images/eq-same-not-changed.png +0 -0
  16. package/static/images/ne-not-same-changed.png +0 -0
  17. package/static/images/ne-not-same-not-changed.png +0 -0
  18. package/static/images/ne-same-changed.png +0 -0
  19. package/static/images/ne-same-not-changed.png +0 -0
  20. package/static/images/octaeder.svg +993 -0
  21. package/static/images/sort-asc-lead.png +0 -0
  22. package/static/images/sort-asc.png +0 -0
  23. package/static/images/sort-desc-lead.png +0 -0
  24. package/static/images/sort-desc.png +0 -0
  25. package/static/images/sort-not.png +0 -0
  26. package/static/index.html +72 -647
  27. package/static/linny-r.css +199 -417
  28. package/static/scripts/linny-r-gui-actor-manager.js +340 -0
  29. package/static/scripts/linny-r-gui-chart-manager.js +944 -0
  30. package/static/scripts/linny-r-gui-constraint-editor.js +681 -0
  31. package/static/scripts/linny-r-gui-controller.js +4005 -0
  32. package/static/scripts/linny-r-gui-dataset-manager.js +1176 -0
  33. package/static/scripts/linny-r-gui-documentation-manager.js +739 -0
  34. package/static/scripts/linny-r-gui-equation-manager.js +307 -0
  35. package/static/scripts/linny-r-gui-experiment-manager.js +1944 -0
  36. package/static/scripts/linny-r-gui-expression-editor.js +449 -0
  37. package/static/scripts/linny-r-gui-file-manager.js +392 -0
  38. package/static/scripts/linny-r-gui-finder.js +727 -0
  39. package/static/scripts/linny-r-gui-model-autosaver.js +230 -0
  40. package/static/scripts/linny-r-gui-monitor.js +448 -0
  41. package/static/scripts/linny-r-gui-paper.js +2789 -0
  42. package/static/scripts/linny-r-gui-receiver.js +323 -0
  43. package/static/scripts/linny-r-gui-repository-browser.js +819 -0
  44. package/static/scripts/linny-r-gui-scale-unit-manager.js +244 -0
  45. package/static/scripts/linny-r-gui-sensitivity-analysis.js +778 -0
  46. package/static/scripts/linny-r-gui-undo-redo.js +560 -0
  47. package/static/scripts/linny-r-model.js +27 -11
  48. package/static/scripts/linny-r-utils.js +17 -2
  49. package/static/scripts/linny-r-vm.js +31 -12
  50. package/static/scripts/linny-r-gui.js +0 -16761
@@ -186,9 +186,14 @@ function uniformDecimals(data) {
186
186
  }
187
187
  }
188
188
 
189
+ function capitalized(s) {
190
+ // Returns string `s` with its first letter capitalized.
191
+ return s.charAt(0).toUpperCase() + s.slice(1);
192
+ }
193
+
189
194
  function ellipsedText(text, n=50, m=10) {
190
- // Returns `text` with ellipsis " ... " between its first `n` and last `m`
191
- // characters
195
+ // Returns `text` with ellipsis " ... " between its first `n` and
196
+ // last `m` characters.
192
197
  if(text.length <= n + m + 3) return text;
193
198
  return text.slice(0, n) + ' \u2026 ' + text.slice(text.length - m);
194
199
  }
@@ -478,6 +483,16 @@ function matchingNumber(m, s) {
478
483
  return (n == m ? n : false);
479
484
  }
480
485
 
486
+ function matchingNumberInList(ml, s) {
487
+ // Traverses list `ml` and returns the first matching number, or FALSE
488
+ // if no match is found.
489
+ for(let i = 0; i < ml.length; i++) {
490
+ const n = matchingNumber(ml[i], s);
491
+ if(n !== false) return n;
492
+ }
493
+ return false;
494
+ }
495
+
481
496
  function compareWithTailNumbers(s1, s2) {
482
497
  // Returns 0 on equal, an integer < 0 if `s1` comes before `s2`, and
483
498
  // an integer > 0 if `s2` comes before `s1`.
@@ -454,18 +454,24 @@ class Expression {
454
454
  this.stack.pop();
455
455
  // Check whether either number is an error code
456
456
  let check = Math.min(dyad[0], dyad[1]);
457
- if(check < VM.MINUS_INFINITY) {
458
- // If so, leave the severest error on top of the stack
457
+ if(check < VM.MINUS_INFINITY &&
458
+ // Exception: "array index out of bounds" error may also be
459
+ // ignored by using the | operator.
460
+ !(no_check && check === VM.ARRAY_INDEX)) {
461
+ // If error, leave the severest error on top of the stack
459
462
  this.retop(check);
460
463
  this.trace(VM.errorMessage(check) + ' in dyad: ' + dyad.toString());
461
464
  return false;
462
465
  }
463
- // Likewise check for "undefined", "not computed", and "still computing"
466
+ // Now check for "undefined", "not computed", and "still computing".
464
467
  check = dyad[0];
465
468
  if(no_check) {
466
- // for VMI_replace_undefined, ignore that A is "undefined" unless
467
- // B is also "undefined"
468
- if(check === VM.UNDEFINED) check = dyad[1];
469
+ // For VMI_replace_undefined, ignore that A is "undefined" or even
470
+ // "array index out of bounds" unless B is also "undefined".
471
+ if(check === VM.UNDEFINED || check === VM.ARRAY_INDEX) {
472
+ dyad[0] = VM.UNDEFINED; // Treat "out of bounds" as "undefined".
473
+ check = dyad[1];
474
+ }
469
475
  } else {
470
476
  check = Math.max(check, dyad[1]);
471
477
  }
@@ -474,7 +480,7 @@ class Expression {
474
480
  this.trace(VM.errorMessage(check) + ' in dyad: ' + dyad.toString());
475
481
  return false;
476
482
  }
477
- // No problem(s)? Then return the dyad
483
+ // No problem(s)? Then return the dyad.
478
484
  return dyad;
479
485
  }
480
486
 
@@ -2070,6 +2076,16 @@ class VirtualMachine {
2070
2076
  P: this.process_attr,
2071
2077
  Q: this.product_attr
2072
2078
  };
2079
+ this.entity_attribute_names = {};
2080
+ for(let i = 0; i < this.entity_letters.length; i++) {
2081
+ const
2082
+ el = this.entity_letters.charAt(i),
2083
+ ac = this.attribute_codes[el];
2084
+ this.entity_attribute_names[el] = [];
2085
+ for(let j = 0; j < ac.length; j++) {
2086
+ this.entity_attribute_names[el].push(ac[j]);
2087
+ }
2088
+ }
2073
2089
  // Level-based attributes are computed only AFTER optimization
2074
2090
  this.level_based_attr = ['L', 'CP', 'HCP', 'CF', 'CI', 'CO', 'F', 'A'];
2075
2091
  this.object_types = ['Process', 'Product', 'Cluster', 'Link', 'Constraint',
@@ -5983,6 +5999,12 @@ function VMI_push_dataset_modifier(x, args) {
5983
5999
  // defines the expression to use. If not, `obj` will be the dataset
5984
6000
  // vector (so same as when "use data" is set).
5985
6001
  obj = ds.activeModifierExpression;
6002
+ if(wcnr === false && obj instanceof Expression && MODEL.running_experiment) {
6003
+ // If experiment run defines the modifier selector, the active
6004
+ // combination may provide a context for #.
6005
+ wcnr = matchingNumberInList(MODEL.running_experiment.activeCombination,
6006
+ obj.attribute);
6007
+ }
5986
6008
  }
5987
6009
  if(!obj) {
5988
6010
  console.log('ANOMALY: no object. obj, wcnr, args, x', obj, wcnr, args, x);
@@ -6011,7 +6033,6 @@ function VMI_push_dataset_modifier(x, args) {
6011
6033
  VM.out_of_bounds_array = ds.displayName;
6012
6034
  VM.out_of_bounds_msg = `Index ${index} not in array dataset ` +
6013
6035
  `${ds.displayName}, which has length ${obj.length}`;
6014
- console.log(VM.out_of_bounds_msg);
6015
6036
  }
6016
6037
  }
6017
6038
  // Fall through: no change to `v` => dataset default value is pushed.
@@ -6020,8 +6041,6 @@ function VMI_push_dataset_modifier(x, args) {
6020
6041
  // NOTE: Readjust `t` when `obj` is an expression for an *array-type*
6021
6042
  // dataset modifier.
6022
6043
  if(obj.object instanceof Dataset && obj.object.array) t++;
6023
- // Pass modifier selector (if specified; may be FALSE) so that result
6024
- // will be recomputed with this selector as context for #.
6025
6044
  v = obj.result(t, wcnr);
6026
6045
  }
6027
6046
  // Trace only now that time step t has been computed.
@@ -6296,7 +6315,7 @@ function VMI_push_statistic(x, args) {
6296
6315
  function VMI_replace_undefined(x, empty) {
6297
6316
  // Replaces one of the two top numbers on the stack by the other if the one
6298
6317
  // is undefined
6299
- const d = x.pop(true); // true denotes that "undefined" should be ignored as issue
6318
+ const d = x.pop(true); // TRUE denotes that "undefined" should be ignored as issue
6300
6319
  if(d !== false) {
6301
6320
  if(DEBUGGING) console.log('REPLACE UNDEFINED (' + d.join(', ') + ')');
6302
6321
  x.retop(d[0] === VM.UNDEFINED ? d[1] : d[0]);
@@ -7696,7 +7715,7 @@ const
7696
7715
 
7697
7716
  OPERATORS = DYADIC_OPERATORS.concat(MONADIC_OPERATORS),
7698
7717
  OPERATOR_CODES = DYADIC_CODES.concat(MONADIC_CODES),
7699
- PRIORITIES = [1, 2, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9,
7718
+ PRIORITIES = [1, 2, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 10,
7700
7719
  9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],
7701
7720
  ACTUAL_SYMBOLS = CONSTANT_SYMBOLS.concat(OPERATORS),
7702
7721
  SYMBOL_CODES = CONSTANT_CODES.concat(OPERATOR_CODES);