Topic
10 replies Latest Post - ‏2013-02-10T18:45:02Z by bqt
bqt
bqt
25 Posts
ACCEPTED ANSWER

Pinned topic Which callback I should do ?

‏2013-01-09T22:29:59Z |
Hi all,

I am trying to use CPLEX to solve a problem with the separation technique. After solving LP relaxation at a node, I will find some cuts (constraints) to add into the current model, I would like to add these cuts into the current model. What is callback i should to implement ?

Now I am using LazyConstraintCallBack, but it cannot present my expectation. Could you please give me some advices ?

Thanks a lot,
Trung
Updated on 2013-02-10T18:45:02Z at 2013-02-10T18:45:02Z by bqt
  • SystemAdmin
    SystemAdmin
    7929 Posts
    ACCEPTED ANSWER

    Re: Which callback I should do ?

    ‏2013-01-10T07:55:03Z  in response to bqt
    Please refer to the user manual to learn about the difference between lazy constraints and user cuts.
    The lazy constraint callback is only invoked when CPLEX finds an integral feasible solution. In contrast the user cut callback is invoked at every node, so this might be the one you want to use.
    • bqt
      bqt
      25 Posts
      ACCEPTED ANSWER

      Re: Which callback I should do ?

      ‏2013-01-10T08:42:58Z  in response to SystemAdmin
      Thanks you for your reply.

      I found that "The constraints added in a UserCutCallbackI must be real cuts in the sense that omitting them does not affect the feasible region of the model under consideration". It means that I cannot post more constraints that affect the feasible region. I would like to post constraints that affect strongly feasible solution at each node (after PL relaxation is just solved), could you please give me some advices ?

      Thank you so much,

      Trung
      • SystemAdmin
        SystemAdmin
        7929 Posts
        ACCEPTED ANSWER

        Re: Which callback I should do ?

        ‏2013-01-10T10:28:12Z  in response to bqt
        Note that "feasible region" means the integer feasible solution here.
        It is fine to post cuts that cut off only fractional solutions.
        If at each node you want to add constraints that (may) cut off integer feasible solutions then the lazy constraint callback is the wrong callback to use (since it is invoked only for integer feasible nodes/solutions).
        You could use a branch callback and add your constraints to the newly created nodes. The branch callback allows you to create nodes with any number of constraints.
        • bqt
          bqt
          25 Posts
          ACCEPTED ANSWER

          Re: Which callback I should do ?

          ‏2013-01-10T14:10:39Z  in response to SystemAdmin
          Thanks for your reply, I will try it now.
  • geffer
    geffer
    28 Posts
    ACCEPTED ANSWER

    Re: Which callback I should do ?

    ‏2013-01-13T13:27:00Z  in response to bqt
    It depends on what would want and property of constraint

    1 If I know the constraint at modeling time, and it has a reasonable chance of being binding, it goes into the model as a normal constraint.

    2. If I know the constraint at modeling time, but it is unlikely to be binding, it goes into the model as a lazy constraint. This usually occurs when the constraint is part of a large collection of constraints, such as subtour elimination constraints.

    3. If the constraint its unknown at modeling time, I ads it in a callback.

    Ps: Paul's blog has clearly clarified the difference between user cur and lazy constraints.
    • bqt
      bqt
      25 Posts
      ACCEPTED ANSWER

      Re: Which callback I should do ?

      ‏2013-02-10T17:47:22Z  in response to geffer
      Hi,

      I would like to add sub-tour elimination constraints (SECs) into current LP subproblem. I know that we cannot post them as normal constraints because there are exponential number of SECs.

      In Cplex 12.2, we can use IloCplex::CutCallbackI to add SECs into current LP subproblem ( it is possible to add SECs into LP subproblem as local or global cuts).

      Now I am using Cplex 12.4, IloCplex::CutCallbackI is no longer available. There is only a solution of using loCplex::BranchCallbackI to create a child node within SECs ? And how to post SECs as global cuts or local cuts (Cplex 12.2 can do it with CutCallbackl) ?

      Thanks
      • SystemAdmin
        SystemAdmin
        7929 Posts
        ACCEPTED ANSWER

        Re: Which callback I should do ?

        ‏2013-02-10T17:54:00Z  in response to bqt
        You can use either IloUserCutCallbackI or IloLazyConstraintCallbackI.
        Please refer to the user manual to read about the difference between user cuts and lazy constraints.
        UserCutCallback and LazyConstraintCallback give you better control about when to add constraints than the old CutCallback did.
        • bqt
          bqt
          25 Posts
          ACCEPTED ANSWER

          Re: Which callback I should do ?

          ‏2013-02-10T18:12:41Z  in response to SystemAdmin
          I have been consulted the manual (http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r4/index.jsp)

          In Cplex 12.4, "The constraints added in a UserCutCallbackI must be real cuts in the sense that omitting them does not affect the feasible region of the model under consideration.". In my experiences, sub-tour elimination constraints (SECs) affect strongly the feasible region of the model and posting SECs within UserCutCallbackl may result in incorrected solutions.

          So, what is a solution to my problem ?

          Thanks,
          • SystemAdmin
            SystemAdmin
            7929 Posts
            ACCEPTED ANSWER

            Re: Which callback I should do ?

            ‏2013-02-10T18:25:50Z  in response to bqt
            In that case use a LazyConstraintCallbackI.
            This callback will be invoked for each integral solution found.
            If that is not often enough for you, then you can also use a LazyConstraintCallbackI and a UserCutCallbackI that both implement the same separation procedure (it is an error to use only a UserCutCallbackI in your case).
            • bqt
              bqt
              25 Posts
              ACCEPTED ANSWER

              Re: Which callback I should do ?

              ‏2013-02-10T18:45:02Z  in response to SystemAdmin
              Thank you so much for your solution. I will try it right now.