# Using CPLEX populate method with JuMP

**URL:** <https://discourse.julialang.org/t/using-cplex-populate-method-with-jump/79973>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, cplex\
**Created:** [April 25, 2022, 7:43am UTC](https://discourse.julialang.org/t/using-cplex-populate-method-with-jump/79973 "2022-04-25T07:43:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MLainee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlainee/32/35684_2.png) [@MLainee](https://discourse.julialang.org/u/MLainee)\
**Post date:** [April 25, 2022, 7:43am UTC](https://discourse.julialang.org/t/using-cplex-populate-method-with-jump/79973/1 "2022-04-25T07:43:54Z")

</div>

Greetings,

I am currently using the CPLEX optimizer with the help of the JuMP package. In order to generate constraints for my model, I am currently using a function of the following type:

```julia
using JuMP
using CPLEX

function GenerateSolution(n)
    M = Model(CPLEX.Optimizer)

    @variable(M,y[1:n],Bin)

    @constraint(M, SampleConstraint[i in 1:n , j in i+1:n] , y[i]+y[j]>=1

    @objective(M, Min, sum(y[i] for i in 1:n))

    optimize!(M)

    y_star = JuMP.getvalue.(M[:y])

    return(y_star)
end

```

To speed up the constraint creation process, I would like for my function to be able to call upon the populate method of the CPLEX optimizer, in order to get multiple feasible solutions to create new constraints with.  
Is it at all possible to do so, and if not, are there alternative ways to obtain multiple solutions to a given model?

---

<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:** [April 25, 2022, 7:58am UTC](https://discourse.julialang.org/t/using-cplex-populate-method-with-jump/79973/2 "2022-04-25T07:58:45Z")

</div>

Hi there @MLainee,

@jd-foster wrote a nice tutorial about this: [Finding multiple feasible solutions | JuMP](https://jump.dev/tutorials/2021/11/02/tutorial-multi-jdf/). Let me know if you still have questions after reading it.

---

<div class="post-metadata">

**Author:** ![MLainee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlainee/32/35684_2.png) [@MLainee](https://discourse.julialang.org/u/MLainee)\
**Post date:** [April 25, 2022, 11:12am UTC](https://discourse.julialang.org/t/using-cplex-populate-method-with-jump/79973/3 "2022-04-25T11:12:22Z")

</div>

Thank you very much for that link, it was indeed exactly what I was looking for!  
And just in case people make the same mistake I did, the call to “optimize!” still has to be made before using the populate method, as it will raise the “CPLEX Error 3003: Not a mixed-integer problem.” if you do not do so.
