Reputation: 1037
I am working on a LP written in Java and using cplex as a solver. The optimal solution takes some time to be found. It would be sufficient if I had a feasible solution that would be calculated faster or just a solution with reduced optimality.
In the CPLEX User’s Manual I have found the following two parameters:
For optimality: https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/EpOpt.html
cplex.setParam(IloCplex.Param.Simplex.Tolerances.Optimality, 1.0e-1);
For the first feasible solution:
cplex.setParam(IloCplex.Param.MIP.Limits.Solutions, 1);
I have used both of these parameters in my model but the solution of the objective function remains the same as well as the computing time.
Furthermore, I have used them in the following small LP but with no success.
package cplexTest;
import ilog.concert.*;
import ilog.cplex.*;
public class TestC {
public static void main (String[] args) {
model1();
}
public static void model1() {
try {
IloCplex cplex = new IloCplex();
cplex.setParam(IloCplex.Param.Simplex.Tolerances.Optimality, 1.0e-1);
cplex.setParam(IloCplex.Param.MIP.Limits.Solutions, 100);
//variables
IloNumVar x = cplex.numVar(0, Double.MAX_VALUE, "x");
IloNumVar y = cplex.numVar(0, Double.MAX_VALUE, "y");
//expressions
IloLinearNumExpr objective = cplex.linearNumExpr();
objective.addTerm(0.12, x);
objective.addTerm(0.15, y);
// define objective
cplex.addMinimize(objective);
//define constraints
cplex.addGe(cplex.sum(cplex.prod(60, x), cplex.prod(60, y)),300);
cplex.addGe(cplex.sum(cplex.prod(12, x), cplex.prod(6, y)),36);
cplex.addGe(cplex.sum(cplex.prod(10, x), cplex.prod(30, y)),90);
//solve
if (cplex.solve()) {
System.out.println("obj = "+cplex.getObjValue());
System.out.println("x = "+cplex.getValue(x));
System.out.println("y = "+cplex.getValue(y));
}
else {
System.out.println("Model not solved");
}
}
catch (IloException exc) {
exc.printStackTrace();
}
}
}
Upvotes: 0
Views: 337
Reputation: 16714
You probably should post the logs to get better answers, but I can make a few points.
Upvotes: 1