1
votes

I need to stop CPLEX from doing that and do not know how.

  • I have a min problem and it is a MIP.
  • There is a variable x with coefficient zero in the objective.
  • All constraints are "less than or equal to"-constraints.
  • x appears only with non-negative coefficients in the constraint matrix.
  • CPLEX returns a solution where x is set to a positive value, which is strange because it does not improve the objective function value, and in the constraint matrix, x only "takes away capacity".

The model is solved multiple times in an iterative procedure. In each iteration the objective changes. Hence, I checked the model and solution of the previous iteration and found that x had a negative coefficient then and was set to positive value. I conclude that this behavior must be related to some warm start of CPLEX.

How can that be prevented?

I rather not add the variables with positive coefficients to the objective because there are many.

Here is an example in Java:

    IloCplex cplex = new IloCplex();

    /* Variables */
    IloNumVar x = cplex.intVar(0, Integer.MAX_VALUE, "x");

    /* Objectiv */
    IloLinearNumExpr objExpr = cplex.linearNumExpr();
    objExpr.addTerm(1.0, x);
    IloObjective objective = cplex.addMaximize();
    objective.setExpr(objExpr);

    /* Constraints */
    IloLinearNumExpr expr = cplex.linearNumExpr();
    expr.addTerm(1.0, x);
    cplex.addLe(expr, 2.5);

    System.out.println(cplex.getModel().toString());
    cplex.solve();
    System.out.println("x = " + cplex.getValue(x) + "\n"); // x = 2.0

    objective.clearExpr();
    IloLinearNumExpr newObjexpr = cplex.linearNumExpr();
    objective.setExpr(newObjexpr);

    System.out.println(cplex.getModel().toString());
    cplex.solve();
    System.out.println("x = " + cplex.getValue(x) + "\n"); // x = 2.0
1
If a variable is not in the objective at all, you are effectively telling CPLEX that you have no preference for what value it takes. So you may get any value that is feasible and compatible with the rest of your (optimal) solution. - TimChippingtonDerrick
@TimChippingtonDerrick of course. But, there is not reason for the solver to increase the value of that variable, unless it uses some starting solution. (Think of the simplex going from one basic feasible solution to the next.) I do not want to include the variables like x in the objective to reduce the computational effort for the solver. The accepted answer solved the problem because it does precisely that: turn of warm starts. - Christian

1 Answers

2
votes

Try

cplex.setParam(IloCplex.Param.Advance, 0);