Using CPLEX populate method with JuMP


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:

using JuMP
using CPLEX

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


    @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))


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


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?

Hi there @MLainee,

@jd-foster wrote a nice tutorial about this: Finding multiple feasible solutions | JuMP. Let me know if you still have questions after reading it.


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.

1 Like