linny-r 1.5.0 → 1.5.1
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 +14 -6
package/package.json
CHANGED
@@ -1960,8 +1960,11 @@ class VirtualMachine {
|
|
1960
1960
|
// cash flows in the objective function (typically +/- 1)
|
1961
1961
|
this.BASE_PENALTY = 10;
|
1962
1962
|
// Peak variable penalty is added to make solver choose the *smallest*
|
1963
|
-
// value that is greater than or equal to X[t] for all t as "peak value"
|
1964
|
-
|
1963
|
+
// value that is greater than or equal to X[t] for all t as "peak value".
|
1964
|
+
// NOTE: The penalty is expressed in the currency unit, so it will be
|
1965
|
+
// divided by the cash scalar so as not to interfere with the optimal
|
1966
|
+
// solution (highest total cash flow).
|
1967
|
+
this.PEAK_VAR_PENALTY = 0.1;
|
1965
1968
|
|
1966
1969
|
// NOTE: the VM uses numbers >> +INF to denote special computation results
|
1967
1970
|
this.EXCEPTION = 1e+36; // to test for any exceptional value
|
@@ -7445,14 +7448,19 @@ function VMI_set_objective(empty) {
|
|
7445
7448
|
VM.objective[i] = VM.coefficients[i];
|
7446
7449
|
}
|
7447
7450
|
// NOTE: For peak increase to function properly, the peak variables
|
7448
|
-
// must have a small penalty in the objective
|
7451
|
+
// must have a small penalty (about 0.1 currency unit) in the objective
|
7452
|
+
// function.
|
7449
7453
|
if(VM.chunk_variables.length > 0) {
|
7450
7454
|
for(let i = 0; i < VM.chunk_variables.length; i++) {
|
7451
7455
|
const vn = VM.chunk_variables[i][0];
|
7452
7456
|
if(vn.indexOf('peak') > 0) {
|
7453
|
-
|
7454
|
-
|
7455
|
-
|
7457
|
+
const pvp = VM.PEAK_VAR_PENALTY / VM.cash_scalar;
|
7458
|
+
// NOTE: Chunk offset takes into account that indices are 0-based.
|
7459
|
+
VM.objective[VM.chunk_offset + i] = -pvp;
|
7460
|
+
// Put higher penalty on "block peak" than on "look-ahead peak"
|
7461
|
+
// to ensure that block peak will always be the smaller value
|
7462
|
+
// of the two peaks.
|
7463
|
+
if(vn.startsWith('b')) VM.objective[VM.chunk_offset + i] -= pvp;
|
7456
7464
|
}
|
7457
7465
|
}
|
7458
7466
|
}
|