Originally posted by: Jernej1
Daniel,
thank you very much for such an extensive effort.
I am really baffled by this as I was sure the models are isomorphic. I tested both SageMath/C++ generators on smaller instances and made sure the same variables are being used while the model is built. And everything works out well for small models and the isomorphism is also very much apparent there (speaking of problems with 4 and 8 variables).
At this point I can only assume there is a weird bug somewhere in how the SageMath model is being written in the LP file or perhaps I am generating the problem wrong in C++. Since it is simple to understand I will post it here and hopefully someone can confirm that it works as desired.
The problem is a variant of the binary covering code problem. You are given the set of all binary strings of length 10 and you want to find a subset S of strings so that every other binary string differs in at most one coordinate from some element in S. This is what the first 1024 constraints are for.
For the second set of constraints, you are given a list of x_0,x_1,...,x_{2^K} integers for example 42,9,9,13,8,13,13,12.
The condition dictates that for any binary K-string F the number of elements of S that have F as a prefix is precisely x_F, where I am treating F as both a string and the respective integer representation here. These are the remaining 8 conditions in the attached LP file. The C++ program that generates this problem in CPLEX is
#define N 10
#define K 3
#define CONF_SIZE ( 1<<K )
IloEnv env;
/* This function returns 0 if it could not prove that the given
* configuration is infeasible, nonzero otherwise
*/
static unsigned isInfeasible(const unsigned d[CONF_SIZE]) {
unsigned i,j;
int status;
try {
IloModel model(env);
IloNumVarArray var(env);
IloRangeArray con(env);
IloCplex cplex(model);
for (i = 0; i < (1U<<N) ; i++) {
var.add( IloBoolVar(env));
}
/* Covering conditions */
for (i = 0; i < (1U << N) ; i++) {
IloExpr expr(env);
expr = var[i];
for (j = 0; j < N; j++) {
expr += var[i ^ (1<<j)];
}
con.add( expr >= 1 );
}
/* Conditions related to the specific configuration */
for (i = 0; i < CONF_SIZE; i++) {
IloExpr expr(env);
for (j = 0; j < (1U << (N-K) ); j++) {
expr += var[ (j << K) | i ];
}
con.add( expr == d[i] );
}
model.add(con);
cplex.solve();
if ( cplex.getStatus() == IloAlgorithm::Infeasible ) {
return 1;
}
} catch(IloException& e) {
std::cerr << "Concert exception caught: " << e << std::endl;
}
catch(...) {
std::cerr << "Unknown exception caught" << std::endl;
}
return 0;
}
Can you confirm that the following indeed matches the description of the model?
Thank you again for your assistance!
#CPLEXOptimizers#DecisionOptimization