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 SAT integer backend.
x and y.import { MPSolver } from 'or-tools-wasm/mp-solver';
const solver = MPSolver.createSolver('SAT');
if (!solver) throw new Error('SAT 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 workers = 4;
await solver.solveWithProto({ executor: 'worker', solverSpecificParameters: `num_workers: ${workers}` });
console.log(x.solutionValue(), y.solutionValue());