Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Relaxation of MIP

    Posted Sat March 16, 2019 07:48 AM

    Originally posted by: A.Omidi


    Hello everybody,

    I was trying to solve a MIP problem using Cplex and java. I want to solve the problem in a relaxed mode without changing the variables defined. I used (IloCplex.Param.Preprocessing.Relax) parameter to do it. But it does not work. 
    Could you tell me please, dose Cplex has a specific parameter to run it? 

    Thanks in advance

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Relaxation of MIP

    Posted Sat March 16, 2019 07:57 PM

    You are referring to the LP relaxation, correct? I do not believe you can get the LP relaxation by setting a parameter, but you can set the node limit (IloCplex.Param.MIP.Limits.Nodes) to zero and solve the MIP. This solves the root LP but also includes any cuts and preprocessing CPLEX does at the root, so it is not the same as solving the LP relaxation. To do this in Java, you need to add an instance of IloConversion to each integer variable, making them all continuous. After you solve the relaxed LP, you can remove all those IloConversion instances to get back your MIP.

    If solving the relaxation is something you want to do once (not necessarily as part of your program), you can have your program export the MIP model to a .sav file. Open that file in the interactive optimizer, use the "change problem" command to convert it to an LP, and then tell CPLEX to solve it.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Relaxation of MIP

    Posted Mon March 18, 2019 07:22 AM

    Originally posted by: A.Omidi


    Dear Prof. Rubin,

     

    Thanks for your useful note. It's working fine.
    I try to solve a MIP problem using lazy constraint. I'm new to use it. I'm reading Cplex user manual about that. It's mentioned that:
    *=================
    1. Begin with your mixed integer programming model (MIP).
    2. Change its problem type to a linear program (LP).
    3. Solve that LP.
    4. Identify constraints for which the dual value is 0 (zero). These are the constraints to make lazy after another change of problem type.
    *=================
    While I used you mentioned setting, the problem solved as an LP. But, I cannot get any dual values for constraints.
    Would you please say that, is there any way to fix it?
    And are there any examples to introduce using of lazy constraint in the java?

    Best regards

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Relaxation of MIP

    Posted Mon March 18, 2019 07:55 PM

    If you want the dual values, setting the node limit to zero will not work. The problem you are solving is still a MIP, and CPLEX will not give dual values for a MIP (because they may not make sense).

    On the other hand, if you add IloConversion instances for all the integer variables and then call solve, CPLEX will treat the problem as an LP. That means the getDuals() method will work, letting you get the dual solution.

    Lazy constraints can be added either to the initial model, or to a model while it is being solved (via callbacks). I'm guessing that you mean adding them to the initial model. The AdMIPex4.java example that ships with CPLEX contains a line to add lazy constraints, but I don't know if the example is all that helpful. Basically, you add lazy constraints to a model the same way you add regular constraints, except that instead of calling addLe, addGe or addEq, you first create the constraint (using le(), ge() or eq()) and then add it using addLazyConstraint (or add a bunch at once using addLazyConstraints()). So you would use something like the following to add lazy constraints one at a time:
     

    IloCplex model = new IloCplex();
    for (int c = 0; c < numberOfConstraints; c++ {
      IloRange nextConstraint = model.le(something); // or model.ge() or model.eq()
      model.addLazyConstraint(nextConstraint);
    }
    

    Important note: use le(), ge() or eq(), NOT addLe(), addGe() or addEq().


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Relaxation of MIP

    Posted Thu March 21, 2019 04:49 AM

    Originally posted by: A.Omidi


    Dear Prof. Rubin,

     

    Thanks so much to replay.
    In the CPLEX user manual, there is a tiny MIP example to illustrate lazy constraint. When I try to add the lazy constraint to the model, I have some issues. While the problem is solving relax, the dual values of constraints c1 and c2 are zero and c3 has value. It has been mentioned constraints c2 and c3 are lazy.
    According to you advice, I use below form to define lazy:
                for (int i = 0; i < row; i++) {
                    IloLinearNumExpr constraint = model.linearNumExpr();
                    for (int j = 0; j < col; j++) {
                        constraint.addTerm(a[i][j], x[j]);
                    }
                    IloRange nextConstraint = model.le(constraint, b[i]);
                    model.addLazyConstraint(nextConstraint);
                }
    After solved problem CPLEX log display: "Lazy constraints applied:  1".

    Would you please, say that if CPLEX has an automatic scheme to find lazy constraint, why we should define it in the model? And I was wondering if, you could tell me do I have a mistake to run it?

     

    Regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Relaxation of MIP

    Posted Thu March 21, 2019 04:20 PM

    I think that line of output just means that one of your lazy constraints was applied. The others sat in the pool but were not used because they did not cut off any LP solutions.


    #CPLEXOptimizers
    #DecisionOptimization