# Solver Cplex

Hi!!
Our binary programming problem has an objective function B. * x, where B is an mxn matrix and x is an mxn variable matrix.
Some of the B values will not exist in the problem to be solved.

Question: How can I assign values in B so that CPLEX understands that the corresponding variable x will be zero, that is, the non-existing value in B will not be part of the solution.?

Thanks! I’ve moved your post to the “Optimization (Mathematical)” category.

You’re looking for “SparseAxisArrays” https://www.juliaopt.org/JuMP.jl/stable/variables/#variable_sparseaxisarrays-1
For example:

``````model = Model()
B = [1 nothing; nothing 2]
@variable(model, x[m = 1:2, n = 1:2; B[m, n] !== nothing], Bin)
``````

Alternatively, you can go

``````model = Model()
@variable(model, x[m = 1:2, n = 1:2], Bin)
for m = 1:2
for n = 1:2
if B[m, n] !== nothing
fix(x[m, n], 0)
end
end
end
``````
1 Like

Hi!
I solved the problem using

``````for i = 1:size(B,1)
for j = 1:size(B,2)
if B[i,j] === missing
unset_binary(x[i,j])
JuMP.fix(x[i,j], 0; force = true)
B[i,j] = 0
end
end
end
``````