Loading solver…
Problem: choose integer values for two variables that maximize the objective while satisfying linear limits.
Direct port of simple_mip_program.py through the MPSolver SCIP integer backend.
x and y.import { MPSolver } from 'or-tools-wasm/mp-solver';
const solver = MPSolver.createSolver('SCIP');
if (!solver) throw new Error('SCIP backend is unavailable');
solver.setNumThreads(4);
const x = solver.addIntVariable(0, solver.infinity(), 'x');
const y = solver.addIntVariable(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();
const status = await solver.solve({ executor: 'worker' });
console.log(status, objective.value(), x.solutionValue(), y.solutionValue());