javascript-lp-solver 1.0.0 → 1.0.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.
@@ -14,7 +14,11 @@ export declare class BranchMinHeap {
14
14
  private heap;
15
15
  private size;
16
16
  private seqCounter;
17
+ private pool;
18
+ private poolSize;
17
19
  constructor(initialCapacity?: number);
20
+ private allocEntry;
21
+ private freeEntry;
18
22
  get length(): number;
19
23
  isEmpty(): boolean;
20
24
  clear(): void;
@@ -11,6 +11,42 @@
11
11
  */
12
12
  import type Tableau from "./tableau";
13
13
  import type { VariableValue } from "./types";
14
+ /**
15
+ * Pseudo-cost tracker for intelligent variable selection in branch-and-bound.
16
+ *
17
+ * Tracks the historical change in objective function when branching on each
18
+ * integer variable. Uses this history to predict which variable will have
19
+ * the most impact on the objective, reducing the size of the B&B tree.
20
+ *
21
+ * Based on: "Branching rules revisited" by Achterberg, Koch, Martin (2005)
22
+ */
23
+ export interface PseudoCosts {
24
+ down: Map<number, {
25
+ sum: number;
26
+ count: number;
27
+ }>;
28
+ up: Map<number, {
29
+ sum: number;
30
+ count: number;
31
+ }>;
32
+ defaultCost: number;
33
+ }
34
+ export declare function createPseudoCosts(): PseudoCosts;
35
+ /**
36
+ * Update pseudo-costs after a branching decision.
37
+ * Call this after solving a child node to record the objective change.
38
+ */
39
+ export declare function updatePseudoCost(pc: PseudoCosts, varIndex: number, direction: "up" | "down", fractionality: number, objectiveChange: number): void;
40
+ /**
41
+ * Get the pseudo-cost for a variable in a given direction.
42
+ */
43
+ export declare function getPseudoCost(pc: PseudoCosts, varIndex: number, direction: "up" | "down"): number;
44
+ /**
45
+ * Select branching variable using pseudo-cost branching.
46
+ * Uses the product scoring rule: score = f_down * pc_down * f_up * pc_up
47
+ * This balances the improvement from both branches.
48
+ */
49
+ export declare function getPseudoCostBranchingVar(tableau: Tableau, pc: PseudoCosts): VariableValue;
14
50
  /**
15
51
  * Count how many integer variables currently have integral values.
16
52
  */
@@ -11,6 +11,22 @@
11
11
  */
12
12
  import type Tableau from "./tableau";
13
13
  export declare function simplex(this: Tableau): Tableau;
14
+ /**
15
+ * Dual simplex algorithm for warm-starting after adding constraints.
16
+ *
17
+ * Use when: The current solution is dual feasible (reduced costs valid) but
18
+ * may be primal infeasible (some RHS values negative). This is common after
19
+ * adding bound constraints in branch-and-cut.
20
+ *
21
+ * Algorithm:
22
+ * 1. Find a basic variable with negative value (leaving variable)
23
+ * 2. Find entering variable using dual ratio test
24
+ * 3. Pivot to restore primal feasibility
25
+ * 4. Repeat until all basic variables are non-negative
26
+ *
27
+ * @returns Number of iterations, or -1 if dual infeasible
28
+ */
29
+ export declare function dualSimplex(this: Tableau): number;
14
30
  export declare function phase1(this: Tableau): number;
15
31
  export declare function phase2(this: Tableau): number;
16
32
  export declare function pivot(this: Tableau, pivotRowIndex: number, pivotColumnIndex: number): void;
@@ -39,6 +39,12 @@ export default class Tableau {
39
39
  simplex(): this;
40
40
  phase1(): number;
41
41
  phase2(): number;
42
+ /**
43
+ * Dual simplex for warm-starting after adding bound constraints.
44
+ * Use when solution is dual feasible but may be primal infeasible.
45
+ * @returns Number of iterations, or -1 if dual infeasible
46
+ */
47
+ dualSimplex(): number;
42
48
  pivot(pivotRowIndex: number, pivotColumnIndex: number): void;
43
49
  checkForCycles(varIndexes: Array<[number, number]>): number[];
44
50
  countIntegerValues(): number;
@@ -20,6 +20,10 @@ export interface BranchCut {
20
20
  export interface Branch {
21
21
  relaxedEvaluation: number;
22
22
  cuts: BranchCut[];
23
+ branchVarIndex?: number;
24
+ branchDirection?: "up" | "down";
25
+ branchFractionality?: number;
26
+ parentEvaluation?: number;
23
27
  }
24
28
  export interface OptionalObjective {
25
29
  priority: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "javascript-lp-solver",
3
3
  "description": "Easy to use, JSON oriented Linear Programming and Mixed Int. Programming Solver",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "private": false,
6
6
  "authors": [
7
7
  "Justin W. Wolcott <justin.w.wolcott@gmail.com>"