Algebraic Modeling (expr)
Write infix formulas (expr`30 * ${x} + 50 * ${y} <= 40`), vector dot products (dot), and summations (sum) while binding ${...} directly as typed Var references.
Expressions
A TypeScript alternative to Python's PuLP and Julia's JuMP. Formulate LP, MIP, Convex QP, and SMT models with intuitive infix expressions and solve client-side via WebAssembly (HiGHS, Z3, GLPK) with zero Python or native C++ dependencies.
import { Model, expr, maximize } from "@ohtaman/washi";
// 1. Create a model
const m = new Model("WoodworkingProfit");
// 2. Define decision variables
const desks = m.integer("desks", { lb: 0 });
const chairs = m.integer("chairs", { lb: 0 });
// 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();
console.log(`Produce: ${desks.value} desks, ${chairs.value} chairs`);
console.log(`Maximum Profit: $${m.objectiveValue}`);