Decision Optimization

 View Only
  • 1.  Fixing variables inside callback using reduced costs

    Posted Wed May 13, 2020 03:04 AM
    I'm solving a problem using branch and cut and I would like to fix variables using the reduced cost of the node relaxation. Apparently it's not possible (when I try to do that I get error 1017). Is there other way to make this work? If not, is there a way to just check the reduced costs inside the callback?

    ------------------------------
    Victor Hugo Rodrigues do Nascimento
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Fixing variables inside callback using reduced costs

    Posted Wed May 13, 2020 03:57 AM
    How exactly are you trying to fix the variables? What functions do you call? In which callback?

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: Fixing variables inside callback using reduced costs

    Posted Wed May 13, 2020 03:25 PM
    Edited by System Fri January 20, 2023 04:42 PM
    I'm extending IloCplex::UserCutCallbackI. My idea is to get the reduce cost of each variable x and fix x = 0 if the reduced cost is greater than the gap. I've added a Ilocplex reference called cplex to my callback class, and then tried to get the reduced cost using cplex.getReducedCost(x). Doing that threw a 1017 ( Not available for mixed-integer programs) error. Even though my program is integer, I would like to get the reduced costs of the relaxation.

    ------------------------------
    Victor Hugo Rodrigues do Nascimento
    ------------------------------



  • 4.  RE: Fixing variables inside callback using reduced costs

    Posted Thu May 14, 2020 01:57 AM
    There are several things wrong with your approach:
    1. It is not allowed to access/modify the IloCplex instance from within a callback. This will at best raise exceptions but will more likely result in undefined behavior.
    2. What you plan to do is not possible in C++ Concert: the reduced costs of the current nodelp are not available in C++. This sort of low-level access to solution information is only available to callable library applications (there you can get a reference to the node LP and then query the desired information on that instance). If you want to do this in C++ Concert then your only option is to
      1. Create a deep copy of your model
      2. In the callback find the current bound tightenings and apply them to the deep copy of the model
      3. Solve the deep copy of the model as an LP
      4. Get the reduced costs from the solution of that deep copy and fix variables according to this
    Note that CPLEX itself performs variable fixings based on reduced cost. So maybe what you are doing is already done by CPLEX?

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 5.  RE: Fixing variables inside callback using reduced costs

    Posted Thu May 14, 2020 09:07 AM
    Edited by System Fri January 20, 2023 04:19 PM

    The reason we intend to have access to variable fixation by reduced cost is that the problem we are working on is defined over a directed graph and whenever an arc variable is fixed to zero its corresponding arc can be removed from the graph.
    Prior to attempting variable fixing by reduced cost, we apply our own pre-solve module for the problem. Our idea is then to combine our own module with reduced cost variable fixation to set up a larger and more effective pre-solve module for the problem.
    Accordingly, if reduced cost fixation performs well, and the graph becomes significantly sparser, we would then go back to our own pre-solve module and iterate.

    Is there any way we could have access to the actual variables that are fixed to zero by CPLEX reduced cost fixation?

    ------------------------------
    Victor Hugo Rodrigues do Nascimento
    ------------------------------



  • 6.  RE: Fixing variables inside callback using reduced costs

    Posted Mon May 25, 2020 01:25 AM
    Unfortunately, you cannot get the reason why a variable was fixed. But you can get the variables that are fixed by either querying the (local) bounds of the variables (using the callback's getLB() and getUB() functions) or by querying the feasibility status of the variable (using the callback's getFeasibility() function).

    ------------------------------
    Daniel Junglas
    ------------------------------