Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Strange behaviour of callback

  • 1.  Strange behaviour of callback

    Posted 07/20/10 02:56 PM

    Originally posted by: SystemAdmin


    Hi everybody,

    I am catching an incumbent in the callback, generate some cuts and add them through a cutcallback.
    I have an array which holds the cuts as ilorange.
    Only one thread is used.
    Every thing works fine inside cutcallback and return from callback. It returns from callback but program immediately stops without any message. I tried to catch any exception with no avail.

    Tried aggregator 1 time.
    MIP Presolve eliminated 225 rows and 1 columns.
    MIP Presolve modified 335 coefficients.
    Reduced MIP has 635 rows, 100 columns, and 4994 nonzeros.
    Reduced MIP has 100 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time =    0.02 sec.
    Warning: Control callbacks may disable some MIP features.
    Clique table members: 65.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: traditional branch-and-cut.
    Parallel mode: none, using 1 thread.
    Root relaxation solution time =   -0.00 sec.
     
            Nodes                                         Cuts/ 
       Node  Left     Objective  IInf  Best Integer     Best Node    ItCnt     Gap         Variable B Nod
    eID Parent  Depth
          0     0  2.23479e+075     8                                   74
          0     0  2.23479e+075     9                    Cuts: 10       98
          0     0  2.23479e+075     8                     Cuts: 2      120
    


    Any comment is highly appreciated.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Strange behaviour of callback

    Posted 07/20/10 04:01 PM

    Originally posted by: SystemAdmin


    In the incumbent callback, do you reject the incumbent? If so, see what happens if you comment out the reject method call? What happens if you leave that alone but comment out the calls to addCut in the cut callback? (I'm trying to narrow down what might be the source of the problem.)

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Strange behaviour of callback

    Posted 07/20/10 04:18 PM

    Originally posted by: SystemAdmin


    You might also try printing out the cuts to screen right before the cutcallback exits. I'm not positive, but I think that I've seen CPLEX do strange things if a callback tries to add something where all or part of it has been deleted by the end() method.

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Strange behaviour of callback

    Posted 07/20/10 07:36 PM

    Originally posted by: SystemAdmin


    Hi Paul,

    Thanks for your comment.
    Yes, if I disable cutting of rejection everything is fine but of course the solution is wrong.
    regarding the printing: I did actually print out the constraints and they look quite OK.
    Tried aggregator 1 time.
    MIP Presolve eliminated 225 rows and 1 columns.
    MIP Presolve modified 335 coefficients.
    Reduced MIP has 635 rows, 100 columns, and 4996 nonzeros.
    Reduced MIP has 100 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time =    0.02 sec.
    Warning: Control callbacks may disable some MIP features.
    Clique table members: 65.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: traditional branch-and-cut.
    Parallel mode: none, using 1 thread.
    Root relaxation solution time =   -0.00 sec.
     
            Nodes                                         Cuts/ 
       Node  Left     Objective  IInf  Best Integer     Best Node    ItCnt     Gap         Variable B Nod
    eID Parent  Depth
     
          0     0  2.23479e+075     4                                   68
    lastIndex= 0
          0     0  2.23479e+075     7                     Cuts: 6      122
    lastIndex= 0
    solution is sub-string
    y[1][7]  + y[9][1]  + y[3][4]  + y[6][3]  + y[4][8]  + y[5][6]  + y[8][5]  + y[7][9]  + -8
    y[7][1]  + y[1][9]  + y[4][3]  + y[3][6]  + y[8][4]  + y[6][5]  + y[5][8]  + y[9][7]  + -8
    sub-string rejected
    lastIndex= 0
    y[1][7]  + y[9][1]  + y[3][4]  + y[6][3]  + y[4][8]  + y[5][6]  + y[8][5]  + y[7][9]  <= 7
    here
    exit
    y[7][1]  + y[1][9]  + y[4][3]  + y[3][6]  + y[8][4]  + y[6][5]  + y[5][8]  + y[9][7]  <= 7
    here
    exit
          0     0  2.23479e+075     8                     Cuts: 4      162
    

    also no handle or object set ended in any of the callbacks.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Strange behaviour of callback

    Posted 07/21/10 08:32 AM

    Originally posted by: SystemAdmin


    > Shahin G wrote:
    > Yes, if I disable cutting of rejection everything is fine but of course the solution is wrong.

    Not sure if I'm interpreting this correctly. Do you mean that disabling either the addition of the cuts or the reject method lets the code execute (albeit with a wrong solution)? I would have thought that only one of those two would have fixed it. Or did you disable both at once? (If so, it would be better to disable them individually.)

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Strange behaviour of callback

    Posted 07/21/10 08:38 AM

    Originally posted by: SystemAdmin


    Hi Paul,

    Thanks for your message.
    I think I should write better next time.
    Yes, I tested all cases. disabling any of the callbacks or bith together help the suscessull execusion but of course the solution is not what should be.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Strange behaviour of callback

    Posted 07/21/10 03:03 PM

    Originally posted by: SystemAdmin


    Shahin,

    Well, that's quite strange. If disabling one callback but not the other resolved the bug, at least we would have some place moderately specific to look. So it's only the combination of both that causes a problem.

    If you comment out the reject method but go ahead and add the cuts, does CPLEX continue to solve the root node or does it immediately branch (or does it immediately but gracefully terminate)? Same question if you reject the incumbent but do not add the cuts. (I'm clearly groping in the dark here.)

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Strange behaviour of callback

    Posted 07/21/10 03:27 PM

    Originally posted by: SystemAdmin


    in fact the problem is a very easy problem (easy in the sense that this a kind of guided local search where the master problem, this one, generates a network structure) and the first solution is actually often integer.
    I am now communicating with Daniel, he ran the code on his linux machine and says that it works fine. But now for me only works in Debug mode when I trace the code line by line (on win7 VS2010).
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Strange behaviour of callback

    Posted 07/21/10 04:06 PM

    Originally posted by: SystemAdmin


    > Shahin G wrote:

    > I am now communicating with Daniel, he ran the code on his linux machine and says that it works fine. But now for me only works in Debug mode when I trace the code line by line (on win7 VS2010).

    Whenever that happens to me (and it is mercifully seldom), I start to suspect a timing/thread syncronization problem -- although I recall your saying this was single-threaded. Did Daniel test it with VS2010? (When in doubt, blaim Microsoft. You'll be right more often than you are wrong.)

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Strange behaviour of callback

    Posted 07/22/10 02:58 AM

    Originally posted by: SystemAdmin


    Paul, I did not yet test under Windows but will do so, of course.
    I am not yet ready to blame M$.
    I also thought about threading/timing issues first but what seems more likely to me at the moment is that one callback may (implicitly?) destroy data that the other callback still uses.
    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: Strange behaviour of callback

    Posted 07/22/10 03:09 AM

    Originally posted by: SystemAdmin


    Hi again,

    I am not 100% sure yet but I guess I could find the problem.
    if you compile using _USE_LEARNING_ flag which I have added in one of the source files then the problem arises.
    I guess at the moment you are not using this flag, right?

    If you use that flag then that piece of code makes the objective function coeffs grow up badly. then when algorithm aproaches iteration around 556 the values are so big that the solver exist without notifying anything.this is correct

    I did that and it solved the problem (I still have to be sure that )
    What wonders me is that even in this case why when I debug the code line by line in the earlier case the code finishes successfully but when I run exe crashes.
    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: Strange behaviour of callback

    Posted 07/21/10 02:08 AM

    Originally posted by: SystemAdmin


    Have to tried using a debugger or a printf() in you callback to figure out what is the last statement that is correctly executed?
    #CPLEXOptimizers
    #DecisionOptimization


  • 13.  Re: Strange behaviour of callback

    Posted 07/21/10 02:23 AM

    Originally posted by: SystemAdmin


    Hi Daniel,
    Yep, Sure. I tried many different things. But it is not clear why when returns from callback it disappears and program ends.
    #CPLEXOptimizers
    #DecisionOptimization


  • 14.  Re: Strange behaviour of callback

    Posted 07/21/10 02:26 AM

    Originally posted by: SystemAdmin


    Ah, so your callback completes succesfully and then the program terminates?
    And a debugger does not give any hint or backtrace?
    #CPLEXOptimizers
    #DecisionOptimization


  • 15.  Re: Strange behaviour of callback

    Posted 07/21/10 02:31 AM

    Originally posted by: SystemAdmin


    yes
    #CPLEXOptimizers
    #DecisionOptimization


  • 16.  Re: Strange behaviour of callback

    Posted 07/21/10 02:39 AM

    Originally posted by: SystemAdmin


    Hm, so no clue at all :-(
    Would be willing to send your code again? I could give it a quick try.
    #CPLEXOptimizers
    #DecisionOptimization


  • 17.  Re: Strange behaviour of callback

    Posted 07/21/10 03:25 AM

    Originally posted by: SystemAdmin


    sure, just let me play around it a few hours more.
    If nothing happened I get back to you. Thanks a lot :)
    #CPLEXOptimizers
    #DecisionOptimization