1

I have an MILP model that I try to solve with cplex python API. I need to get more than one solution. The problem is that when I get for example 50 solutions from my cplex pool, these solutions are very much similar. How can I somehow shuffle before getting these solutions and get solutions that are different than each other as much as possible without adding new constraints?

Sana.Nz
  • 81
  • 11

1 Answers1

1

You can use solution pool filters for that. Using a diversity filter you can make sure that solutions are sufficiently different. These filters however only work for binary variables.

You can find more details in the solution pool documentation and in the solution pool reference documentation. Details about the filter functions can be found in the C library reference documentation here and here.

The user manual also has an example about finding diverse solutions that uses another strategy. See CPLEX > User's Manual for CPLEX > Discrete optimization Solution pool: generating and keeping multiple solutions > Parameters of the solution pool > Example: diverse solutions through replacement parameter

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22
  • thank you Daniel. For using add_diversity_filter(self, lb, ub, expression, weights=None, name='') I don't know what to put for the arguments. For example, what is lower band refering to? or what needs to be put as the expression? I saw the example in IBM's site but it was not clear enough. – Sana.Nz Aug 11 '20 at 15:10
  • The reference documentation of the corresponding function in the C API should give you the required details, see https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/refcallablelibrary/mipapi/addsolnpooldivfilter.html. The documentation also has an explicit example for finding diverse solutions (using a simpler strategy): https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/soln_pool/35_eg_diversity.html – Daniel Junglas Aug 12 '20 at 05:37