Skip to content

WaSHIMathematical Optimization Modeler in TypeScript

A TypeScript alternative to Python's PuLP. Formulate LP, MIP, Convex QP, and SMT models with intuitive infix expressions and solve in Node.js and browsers via WebAssembly (HiGHS, Z3, GLPK) with zero Python or native C++ dependencies.

WaSHI Emblem

Quick Example ​

typescript
import { Model, expr, maximize } from "@ohtaman/washi";

// 1. Create a model
const m = new Model("WoodworkingProfit");

// 2. Define decision variables with realistic bounds
const desks = m.integer("desks", { lb: 0, ub: 100 });
const chairs = m.integer("chairs", { lb: 0, ub: 100 });

// 3. Set objective function ($30/desk, $50/chair)
m.objective(maximize(expr`30 * ${desks} + 50 * ${chairs}`));

// 4. Add constraints (material and labor limits)
m.constraint(expr`${desks} + 2 * ${chairs} <= 40`, "wood_limit");
m.constraint(expr`2 * ${desks} + ${chairs} <= 50`, "labor_limit");

// 5. Solve via WebAssembly (HiGHS)
await m.solve();

if (m.hasPrimalSolution) {
  console.log(`Produce: ${desks.value} desks, ${chairs.value} chairs`);
  console.log(`Maximum Profit: $${m.objectiveValue}`);
}

Explore Documentation ​

Released under the MIT License.