Loading solver…
Problem: choose values for two continuous variables that maximize profit while staying inside two linear resource limits.
The simple_lp_program.py model solved with the GLPK LP backend.
x and y.import { MPSolver } from 'or-tools-wasm/mp-solver';
const solver = MPSolver.createSolver('GLPK_LP');
if (!solver) throw new Error('GLPK_LP is unavailable');
solver.setNumThreads(1);
const x = solver.addNumVariable(0, solver.infinity(), 'x');
const y = solver.addNumVariable(0, solver.infinity(), 'y');
const c0 = solver.addConstraint(-solver.infinity(), 17.5);
c0.setCoefficient(x, 1);
c0.setCoefficient(y, 7);
const c1 = solver.addConstraint(-solver.infinity(), 3.5);
c1.setCoefficient(x, 1);
const objective = solver.objective();
objective.setCoefficient(x, 1);
objective.setCoefficient(y, 10);
objective.setMaximization();
await solver.solve({ executor: 'worker' });