# Solver Cplex

**URL:** <https://discourse.julialang.org/t/solver-cplex/38915>\
**Category:** Optimization (Mathematical)\
**Created:** [May 6, 2020, 10:38pm UTC](https://discourse.julialang.org/t/solver-cplex/38915 "2020-05-06T22:38:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lausilvag](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lausilvag/32/9778_2.png) [@lausilvag](https://discourse.julialang.org/u/lausilvag)\
**Post date:** [May 6, 2020, 10:38pm UTC](https://discourse.julialang.org/t/solver-cplex/38915/1 "2020-05-06T22:38:02Z")

</div>

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! 🙂

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 7, 2020, 12:53am UTC](https://discourse.julialang.org/t/solver-cplex/38915/2 "2020-05-07T00:53:09Z")

</div>

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

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

```julia
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

```julia
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

```

---

<div class="post-metadata">

**Author:** ![lausilvag](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lausilvag/32/9778_2.png) [@lausilvag](https://discourse.julialang.org/u/lausilvag)\
**Post date:** [May 7, 2020, 4:12pm UTC](https://discourse.julialang.org/t/solver-cplex/38915/3 "2020-05-07T16:12:29Z")

</div>

Hi!  
I solved the problem using

```julia
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

```

thank you for your help!
