Loading solver…
Problem: solve a small integer linear model through MathOpt using the GSCIP backend.
GSCIP is SCIP exposed through the MathOpt frontend.
x and y.x a higher value than y.import { MathOpt } from 'or-tools-wasm/mathopt';
const model = MathOpt.Model('gscip_simple_mip');
const x = model.addIntegerVariable({ lowerBound: 0, upperBound: 10, name: 'x' });
const y = model.addIntegerVariable({ lowerBound: 0, upperBound: 10, name: 'y' });
model.addLinearConstraint({ upperBound: 4, terms: [
{ variable: x, coefficient: 1 },
{ variable: y, coefficient: 1 },
]});
model.addLinearConstraint({
upperBound: 2,
terms: [{ variable: x, coefficient: 1 }],
});
model.maximize([
{ variable: x, coefficient: 1 },
{ variable: y, coefficient: 2 },
]);
const result = await MathOpt.solve(model, {
executor: 'worker',
solverType: MathOpt.SolverType.GSCIP,
threads: 4,
});
console.log(result.objectiveValue, result.variableValuesById);