Set i = Set("i").HasElementsUntil(2); // { 0, 1 }
Set j = Set("j").HasElementsUntil(3); // { 0, 1, 2 }
VarD2 x = Variable("x").HasIndices(i, j).IsBinary();
Objective maxCount = maximize | sum(over(i, j), x[i, j]);
MathModel model = MathModel.New().WithObjective(maxCount).HasNoConstraints();
Cplex solver = new();
var resSolution = await solver.Solve(model);
MathModelSolution solution = resSolution.Unwrap(); // normally, check if it is 'IsOk' before unwrapping!
VarD2 y = Variable("y").HasIndices(i, j).IsBinary(); // irrelevant to the model
var maybeXSoln = solution.VarIndicesAndValuesOf(x);
Assert.True(maybeXSoln.IsSome);
Dictionary<(int, int), double> xSoln = maybeXSoln.Unwrap(); // a map from indices of x to the values in the solution
Assert.Equal(1, xSoln[(0, 0)]);
Assert.Equal(1, xSoln[(0, 1)]);
Assert.Equal(1, xSoln[(0, 2)]);
Assert.Equal(1, xSoln[(1, 0)]);
Assert.Equal(1, xSoln[(1, 1)]);
Assert.Equal(1, xSoln[(1, 2)]);
Assert.False(xSoln.ContainsKey((1, 3))); // x(1, 3) is not a part of the model and solution
var maybeYSoln = solution.VarIndicesAndValuesOf(y); // y is not a part of this solution
Assert.True(maybeYSoln.IsNone); // "maybeYSoln.Unwrap()" would've thrown!