Hi Cplex community,
I am trying to learn to retrieve the Farkas certificates in Cplex, but I have not managed to do it.
I created this simple toy model, but when I call the .dualFarkas method the arrayValues (the array in which I am planning to store the Farkas certificates), elements are null. I am attaching this same model as .mod file to this message.
Am I missing something?
I read that I should turn presolve off and that I needed to choose the dual simplex algorithm, but it is still not working.
Thanks in advance.
dvar float+ x1;
maximize 2*x1;
subject to
{
ct1: -x1<=-5;
ct2: x1<=2;
}
main
{
thisOplModel.generate();
var modelDef = thisOplModel.modelDefinition;
var modelData = thisOplModel.dataElements;
var cplex1 = new IloCplex();
var model = new IloOplModel(modelDef,cplex1);
model.addDataSource(modelData);
model.generate();
//set the optimisation method to dual simplex
cplex1.LPMethod = 2;
//Turn off presolve because we need to solve the problem in order to realise the infeasability and
//to get Farkas certificate. If we leave it on, it will prevent us from trying to solve the problem
cplex1.preind = 0;
cplex1.solve();
var nRows = cplex1.getNrows();
writeln("number of rows = " + nRows);
var arrayConstraints = new Array(nRows);
var arrayValues = new Array(nRows);
writeln("cplex status = " + cplex1.status);
cplex1.dualFarkas(arrayConstraints, arrayValues);
writeln(arrayValues[1]);
}
------------------------------
Juan Esteban Calle Salazar
------------------------------
#DecisionOptimization