linny-r 1.9.1 → 1.9.2
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 +1 -1
- package/static/scripts/linny-r-vm.js +25 -13
package/package.json
CHANGED
@@ -2567,7 +2567,7 @@ class VirtualMachine {
|
|
2567
2567
|
return Math.round(n);
|
2568
2568
|
}
|
2569
2569
|
|
2570
|
-
sig4Dig(n) {
|
2570
|
+
sig4Dig(n, tiny=false) {
|
2571
2571
|
// Return number `n` formatted so as to show 4-5 significant digits.
|
2572
2572
|
// NOTE: As `n` should be a number, a warning sign will typically
|
2573
2573
|
// indicate a bug in the software.
|
@@ -2576,8 +2576,13 @@ class VirtualMachine {
|
|
2576
2576
|
// If `n` has a special value, return its representation.
|
2577
2577
|
if(sv[0]) return sv[1];
|
2578
2578
|
const a = Math.abs(n);
|
2579
|
+
if(a === 0) return 0;
|
2579
2580
|
// Signal small differences from true 0 by a leading + or - sign.
|
2580
|
-
if(
|
2581
|
+
if(a <= this.ON_OFF_THRESHOLD) {
|
2582
|
+
// The `tiny` flag indicates: display small number in E-notation.
|
2583
|
+
if(tiny) return n.toPrecision(1);
|
2584
|
+
return n > 0 ? '+0' : '-0';
|
2585
|
+
}
|
2581
2586
|
if(a >= 9999995) return n.toPrecision(4);
|
2582
2587
|
if(Math.abs(a-Math.round(a)) < 0.0005) return Math.round(n);
|
2583
2588
|
if(a < 1) return Math.round(n*10000) / 10000;
|
@@ -4666,7 +4671,9 @@ class VirtualMachine {
|
|
4666
4671
|
}
|
4667
4672
|
if(b <= this.nr_of_time_steps && absl > VM.ON_OFF_THRESHOLD) {
|
4668
4673
|
this.logMessage(block, `${this.WARNING}(t=${b}${round}) ` +
|
4669
|
-
`${v[1].displayName} ${v[0]} slack =
|
4674
|
+
`${v[1].displayName} ${v[0]} slack = ` +
|
4675
|
+
// NOTE: TRUE denotes "show tiny values with precision".
|
4676
|
+
this.sig4Dig(slack, true));
|
4670
4677
|
if(v[1] instanceof Product) {
|
4671
4678
|
const ppc = v[1].productPositionClusters;
|
4672
4679
|
for(let ci = 0; ci < ppc.length; ci++) {
|
@@ -6582,28 +6589,32 @@ function relativeTimeStep(t, anchor, offset, dtm, x) {
|
|
6582
6589
|
// Offset relative to current time step, scaled to time unit of run.
|
6583
6590
|
return Math.floor((t + offset) * dtm);
|
6584
6591
|
}
|
6592
|
+
if(anchor === 'f') {
|
6593
|
+
// Last: offset relative to index 1 in the vector.
|
6594
|
+
return 1 + offset;
|
6595
|
+
}
|
6596
|
+
if(anchor === 'l') {
|
6597
|
+
// Last: offset relative to the last index in the vector.
|
6598
|
+
return VM.nr_of_time_steps + offset;
|
6599
|
+
}
|
6600
|
+
const cb = Math.trunc((t - 1) / MODEL.block_length);
|
6585
6601
|
if(anchor === 'c') {
|
6586
6602
|
// Relative to start of current optimization block.
|
6587
|
-
return
|
6603
|
+
return cb * MODEL.block_length + 1 + offset;
|
6588
6604
|
}
|
6589
6605
|
if(anchor === 'p') {
|
6590
6606
|
// Relative to start of previous optimization block.
|
6591
|
-
return (
|
6607
|
+
return (cb - 1) * MODEL.block_length + 1 + offset;
|
6592
6608
|
}
|
6593
6609
|
if(anchor === 'n') {
|
6594
6610
|
// Relative to start of next optimization block.
|
6595
|
-
return (
|
6596
|
-
}
|
6597
|
-
if(anchor === 'l') {
|
6598
|
-
// Last: offset relative to the last index in the vector.
|
6599
|
-
return VM.nr_of_time_steps + offset;
|
6611
|
+
return (cb + 1) * MODEL.block_length + 1 + offset;
|
6600
6612
|
}
|
6601
6613
|
if(anchor === 's') {
|
6602
6614
|
// Scaled: offset is scaled to time unit of run.
|
6603
6615
|
return Math.floor(offset * dtm);
|
6604
6616
|
}
|
6605
6617
|
// Fall-through: offset relative to the initial value index (0).
|
6606
|
-
// NOTE: this also applies to anchor f (First).
|
6607
6618
|
return offset;
|
6608
6619
|
}
|
6609
6620
|
|
@@ -7121,7 +7132,8 @@ function VMI_push_statistic(x, args) {
|
|
7121
7132
|
t2 = Math.max(0, Math.min(tmax, t2));
|
7122
7133
|
// Trace only now that time step range has been computed
|
7123
7134
|
if(DEBUGGING) {
|
7124
|
-
const trc = ['push statistic: [', stat, ': N = ', list.length, ']',
|
7135
|
+
const trc = ['push statistic: [', stat, ': N = ', list.length, ']',
|
7136
|
+
ao1, ao2, ' (t = ', t1, '-', t2, ')'];
|
7125
7137
|
console.log(trc.join(''));
|
7126
7138
|
}
|
7127
7139
|
// Establish whether statistic pertains to non-zero values only
|
@@ -7157,7 +7169,7 @@ function VMI_push_statistic(x, args) {
|
|
7157
7169
|
const
|
7158
7170
|
n = vlist.length,
|
7159
7171
|
// NOTE: count is the number of values used in the statistic
|
7160
|
-
count = (nz ? n : list.length);
|
7172
|
+
count = (nz ? n : list.length * (t2 - t1 + 1));
|
7161
7173
|
if(stat === 'N') {
|
7162
7174
|
x.push(count);
|
7163
7175
|
return;
|