linny-r 1.9.2 → 1.9.3
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-model.js +43 -35
package/package.json
CHANGED
@@ -3471,8 +3471,9 @@ class LinnyRModel {
|
|
3471
3471
|
let n = 0;
|
3472
3472
|
for(let i = 0; i < constraints.length; i++) {
|
3473
3473
|
const c = constraints[i];
|
3474
|
-
if(
|
3475
|
-
(c.
|
3474
|
+
if(!MODEL.ignored_entities[c.identifier] &&
|
3475
|
+
((c.to_node === p && c.soc_direction === VM.SOC_X_Y) ||
|
3476
|
+
(c.from_node === p && c.soc_direction === VM.SOC_Y_X))) n++;
|
3476
3477
|
}
|
3477
3478
|
return n;
|
3478
3479
|
},
|
@@ -3484,7 +3485,8 @@ class LinnyRModel {
|
|
3484
3485
|
for(let i = 0; i < p.inputs.length; i++) {
|
3485
3486
|
const l = p.inputs[i];
|
3486
3487
|
// NOTE: Only process --> product links can carry cost.
|
3487
|
-
if(l.
|
3488
|
+
if(!MODEL.ignored_entities[l.identifier] &&
|
3489
|
+
l.from_node instanceof Process) {
|
3488
3490
|
tuple.n++;
|
3489
3491
|
if(l.share_of_cost === 0) tuple.nosoc++;
|
3490
3492
|
const d = l.actualDelay(t);
|
@@ -3656,12 +3658,15 @@ class LinnyRModel {
|
|
3656
3658
|
const p = processes[i];
|
3657
3659
|
let cp = 0;
|
3658
3660
|
for(let j = 0; j < p.inputs.length; j++) {
|
3659
|
-
const
|
3660
|
-
if(
|
3661
|
-
|
3662
|
-
|
3663
|
-
|
3664
|
-
|
3661
|
+
const l = p.inputs[j];
|
3662
|
+
if(!MODEL.ignored_entities[l.identifier]) {
|
3663
|
+
const ucp = l.unit_cost_price;
|
3664
|
+
if(ucp === VM.UNDEFINED) {
|
3665
|
+
cp = VM.UNDEFINED;
|
3666
|
+
break;
|
3667
|
+
} else {
|
3668
|
+
cp += ucp;
|
3669
|
+
}
|
3665
3670
|
}
|
3666
3671
|
}
|
3667
3672
|
// NOTE: Also check constraints that transfer cost to `p`.
|
@@ -3682,31 +3687,33 @@ class LinnyRModel {
|
|
3682
3687
|
// NOTE: ignore SoC, as this affects the CP of the product, but
|
3683
3688
|
// NOT the CP of the process producing it.
|
3684
3689
|
for(let j = 0; j < p.outputs.length; j++) {
|
3685
|
-
const
|
3686
|
-
|
3687
|
-
|
3688
|
-
|
3689
|
-
|
3690
|
-
|
3691
|
-
|
3692
|
-
|
3693
|
-
|
3694
|
-
|
3695
|
-
|
3696
|
-
|
3697
|
-
|
3698
|
-
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
3702
|
-
|
3703
|
-
|
3704
|
-
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3690
|
+
const l = p.outputs[j];
|
3691
|
+
if(!MODEL.ignored_entities[l.identifier]) {
|
3692
|
+
const
|
3693
|
+
// NOTE: For output links always use current price.
|
3694
|
+
px = l.to_node.price,
|
3695
|
+
pr = (px.defined ? px.result(t) : 0),
|
3696
|
+
// For levels, consider delay: earlier if delay > 0.
|
3697
|
+
dt = t - l.actualDelay(t);
|
3698
|
+
if(pr < 0) {
|
3699
|
+
// Only consider negative prices.
|
3700
|
+
if(l.multiplier === VM.LM_LEVEL) {
|
3701
|
+
// Treat links with level multiplier similar to input links,
|
3702
|
+
// as this computes CP even when actual level = 0.
|
3703
|
+
// NOTE: Subtract (!) so as to ADD the cost.
|
3704
|
+
cp -= pr * l.relative_rate.result(dt);
|
3705
|
+
} else {
|
3706
|
+
// For other types, multiply price by actual flow / level
|
3707
|
+
// NOTE: actualFlow already considers delay => use t, not dt.
|
3708
|
+
const af = l.actualFlow(t);
|
3709
|
+
if(af > VM.NEAR_ZERO) {
|
3710
|
+
// Prevent division by zero.
|
3711
|
+
// NOTE: Level can be zero even if actual flow > 0!
|
3712
|
+
let al = p.nonZeroLevel(dt, l.multiplier);
|
3713
|
+
// NOTE: Scale to level only when level > 1, or fixed
|
3714
|
+
// costs for start-up or first commit will be amplified.
|
3715
|
+
if(al > VM.NEAR_ZERO) cp -= pr * af / Math.max(al, 1);
|
3716
|
+
}
|
3710
3717
|
}
|
3711
3718
|
}
|
3712
3719
|
}
|
@@ -3767,7 +3774,8 @@ class LinnyRModel {
|
|
3767
3774
|
cp_sccp = VM.COMPUTING;
|
3768
3775
|
for(let j = 0; j < p.inputs.length; j++) {
|
3769
3776
|
const l = p.inputs[j];
|
3770
|
-
if(l.
|
3777
|
+
if(!MODEL.ignored_entities[l.identifier] &&
|
3778
|
+
l.from_node instanceof Process) {
|
3771
3779
|
cp = l.from_node.costPrice(t - l.actualDelay(t));
|
3772
3780
|
if(cp === VM.UNDEFINED && l.share_of_cost > 0) {
|
3773
3781
|
// Contributing CP still unknown => break from FOR loop.
|