- let itemsLength = items.length;
- this.lineCostStorage = Array(itemsLength);
- this.prevNodes = Array(itemsLength).fill(null);
- for (var i = 0; i < itemsLength; i++) {
- this.lineCostStorage[i] = Array(itemsLength).fill(null);
- }
- this.totalCostAuxStorage = Array(itemsLength).fill(null);
- let a = this.totalCostAux(items, itemsLength - 1, lineWidth);
- return a;
+ return __awaiter(this, void 0, void 0, function* () {
+ let lineWidthFixed = lineWidth * 0.75;
+ let itemsLength = items.length;
+ this.lineCostStorage = Array(itemsLength);
+ this.prevNodes = Array(itemsLength).fill(null);
+ for (var i = 0; i < itemsLength; i++) {
+ this.lineCostStorage[i] = Array(itemsLength).fill(null);
+ }
+ this.totalCostAuxStorage = Array(itemsLength).fill(null);
+ let a = Infinity;
+ for (var k = itemsLength - 2; (yield this.lineCost(items, k + 1, itemsLength - 1, lineWidthFixed)) < Infinity; k--) {
+ let tmp = yield this.totalCostAux(items, k, lineWidthFixed);
+ if (a > tmp) {
+ this.prevNodes[itemsLength - 1] = k;
+ a = tmp;
+ }
+ }
+ console.log("~~~", lineWidth);
+ console.log(items[itemsLength - 2]);
+ return a;
+ });