linny-r 1.7.1 → 1.7.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-gui-paper.js +25 -20
- package/static/scripts/linny-r-model.js +171 -138
- package/static/scripts/linny-r-vm.js +441 -262
package/package.json
CHANGED
@@ -1584,10 +1584,10 @@ class Paper {
|
|
1584
1584
|
if(luc && MODEL.infer_cost_prices &&
|
1585
1585
|
af > VM.MINUS_INFINITY && af < VM.PLUS_INFINITY
|
1586
1586
|
) {
|
1587
|
-
// Assume no cost price to be displayed
|
1587
|
+
// Assume no cost price to be displayed.
|
1588
1588
|
s = '';
|
1589
1589
|
let soc = 0;
|
1590
|
-
// NOTE:
|
1590
|
+
// NOTE: Flows INTO processes always carry cost.
|
1591
1591
|
if(luc.to_node instanceof Process) {
|
1592
1592
|
soc = 1;
|
1593
1593
|
prod = luc.from_node;
|
@@ -1607,7 +1607,7 @@ class Paper {
|
|
1607
1607
|
// ... unless it is a flow of a by-product having a market
|
1608
1608
|
// value (+ or -)
|
1609
1609
|
if(cp !== 0) {
|
1610
|
-
//Just in case, check for error codes (if so, display them)
|
1610
|
+
// Just in case, check for error codes (if so, display them).
|
1611
1611
|
if(cp < VM.MINUS_INFINITY) {
|
1612
1612
|
s = VM.sig4Dig(cp);
|
1613
1613
|
} else if(cp < 0) {
|
@@ -1616,53 +1616,57 @@ class Paper {
|
|
1616
1616
|
}
|
1617
1617
|
}
|
1618
1618
|
} else {
|
1619
|
+
const d = luc.actualDelay(MODEL.t);
|
1619
1620
|
if(af > 0) {
|
1620
|
-
// Positive flow => use cost price of FROM node
|
1621
|
+
// Positive flow => use cost price of FROM node.
|
1621
1622
|
if(luc.from_node instanceof Process) {
|
1622
1623
|
// For processes, this is their cost price per level
|
1623
|
-
// DIVIDED BY the relative rate of the link
|
1624
|
+
// DIVIDED BY the relative rate of the link.
|
1624
1625
|
const rr = luc.relative_rate.result(MODEL.t);
|
1625
1626
|
if(Math.abs(rr) < VM.NEAR_ZERO) {
|
1626
1627
|
cp = (rr < 0 && cp < 0 || rr > 0 && cp > 0 ?
|
1627
1628
|
VM.PLUS_INFINITY : VM.MINUS_INFINITY);
|
1628
1629
|
} else {
|
1629
|
-
cp = proc.costPrice(MODEL.t) / rr;
|
1630
|
+
cp = proc.costPrice(MODEL.t - d) / rr;
|
1630
1631
|
}
|
1631
1632
|
} else if(prod.price.defined) {
|
1632
1633
|
// For products their market price if defined...
|
1633
|
-
cp = prod.price.result(MODEL.t);
|
1634
|
+
cp = prod.price.result(MODEL.t - d);
|
1634
1635
|
} else {
|
1635
|
-
// ... otherwise their cost price
|
1636
|
-
cp = prod.costPrice(MODEL.t);
|
1636
|
+
// ... otherwise their cost price.
|
1637
|
+
cp = prod.costPrice(MODEL.t - d);
|
1637
1638
|
}
|
1638
1639
|
} else {
|
1639
|
-
// Negative flow => use cost price of TO node
|
1640
|
+
// Negative flow => use cost price of TO node.
|
1640
1641
|
if(luc.to_node instanceof Process) {
|
1642
|
+
// NOTE: Input links have no delay.
|
1641
1643
|
cp = proc.costPrice(MODEL.t);
|
1642
1644
|
} else if(prod.price.defined) {
|
1643
|
-
cp = prod.price.result(MODEL.t);
|
1645
|
+
cp = prod.price.result(MODEL.t - d);
|
1644
1646
|
} else {
|
1645
|
-
cp = prod.costPrice(MODEL.t);
|
1647
|
+
cp = prod.costPrice(MODEL.t - d);
|
1646
1648
|
}
|
1647
1649
|
}
|
1648
|
-
// NOTE:
|
1650
|
+
// NOTE: The first condition ensures that error codes will be
|
1651
|
+
// displayed.
|
1649
1652
|
if(cp <= VM.MINUS_INFINITY || cp >= VM.PLUS_INFINITY) {
|
1650
1653
|
s = VM.sig4Dig(cp);
|
1651
1654
|
} else if(Math.abs(cp) <= VM.SIG_DIF_FROM_ZERO) {
|
1652
|
-
// DO not display CP when it is "propagated" NO_COST
|
1655
|
+
// DO not display CP when it is "propagated" NO_COST.
|
1653
1656
|
s = (cp === VM.NO_COST ? '' : '0');
|
1654
1657
|
} else {
|
1655
|
-
// NOTE:
|
1658
|
+
// NOTE: Use the absolute value of the flow, as cost is not
|
1659
|
+
// affected by direction.
|
1656
1660
|
s = VM.sig4Dig(Math.abs(af) * soc * cp);
|
1657
1661
|
}
|
1658
1662
|
}
|
1659
|
-
// Only display cost price if it is meaningful
|
1663
|
+
// Only display cost price if it is meaningful.
|
1660
1664
|
if(s) {
|
1661
1665
|
font_color = 'gray';
|
1662
1666
|
bb = this.numberSize(s, 8, font_weight);
|
1663
1667
|
tw = bb.width;
|
1664
1668
|
th = bb.height;
|
1665
|
-
// NOTE:
|
1669
|
+
// NOTE: Offset cost price label relative to actual flow label.
|
1666
1670
|
epy += th + 1;
|
1667
1671
|
arrw.shape.addRect(epx, epy, tw, th, {'fill': this.palette.cost_price});
|
1668
1672
|
arrw.shape.addNumber(epx, epy, s, {'fill': font_color});
|
@@ -1671,15 +1675,16 @@ class Paper {
|
|
1671
1675
|
} // end IF l > 0 and actual flow is defined and non-zero
|
1672
1676
|
|
1673
1677
|
if(l > 0) {
|
1674
|
-
// NOTE:
|
1675
|
-
// product that has the "hide links" option selected
|
1678
|
+
// NOTE: Make the arrow shape nearly transparant when it connects
|
1679
|
+
// to a product that has the "hide links" option selected.
|
1676
1680
|
if(arrw.from_node.no_links || arrw.to_node.no_links) {
|
1677
1681
|
arrw.shape.element.setAttribute('opacity', 0.08);
|
1678
1682
|
}
|
1679
1683
|
arrw.shape.appendToDOM();
|
1680
1684
|
return true;
|
1681
1685
|
}
|
1682
|
-
// If nothing is drawn, return FALSE although this does NOT imply an
|
1686
|
+
// If nothing is drawn, return FALSE although this does NOT imply an
|
1687
|
+
// error.
|
1683
1688
|
return false;
|
1684
1689
|
}
|
1685
1690
|
|