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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linny-r",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "Executable graphical language with WYSIWYG editor for MILP models",
5
5
  "main": "server.js",
6
6
  "scripts": {
@@ -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((c.to_node === p && c.soc_direction === VM.SOC_X_Y) ||
3475
- (c.from_node === p && c.soc_direction === VM.SOC_Y_X)) n++;
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.from_node instanceof Process) {
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 ucp = p.inputs[j].unit_cost_price;
3660
- if(ucp === VM.UNDEFINED) {
3661
- cp = VM.UNDEFINED;
3662
- break;
3663
- } else {
3664
- cp += ucp;
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
- l = p.outputs[j],
3687
- // NOTE: For output links always use current price.
3688
- px = l.to_node.price,
3689
- pr = (px.defined ? px.result(t) : 0),
3690
- // For levels, consider delay: earlier if delay > 0.
3691
- dt = t - l.actualDelay(t);
3692
- if(pr < 0) {
3693
- // Only consider negative prices.
3694
- if(l.multiplier === VM.LM_LEVEL) {
3695
- // Treat links with level multiplier similar to input links,
3696
- // as this computes CP even when actual level = 0.
3697
- // NOTE: Subtract (!) so as to ADD the cost.
3698
- cp -= pr * l.relative_rate.result(dt);
3699
- } else {
3700
- // For other types, multiply price by actual flow / level
3701
- // NOTE: actualFlow already considers delay => use t, not dt.
3702
- const af = l.actualFlow(t);
3703
- if(af > VM.NEAR_ZERO) {
3704
- // Prevent division by zero.
3705
- // NOTE: Level can be zero even if actual flow > 0!
3706
- let al = p.nonZeroLevel(dt, l.multiplier);
3707
- // NOTE: Scale to level only when level > 1, or fixed
3708
- // costs for start-up or first commit will be amplified.
3709
- if(al > VM.NEAR_ZERO) cp -= pr * af / Math.max(al, 1);
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.from_node instanceof Process) {
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.