MIPNODE, MIPSOL,MIP

1,119 views
Skip to first unread message

Bob Pay

unread,
Nov 4, 2014, 2:46:37 PM11/4/14
to gur...@googlegroups.com
Hello everyone.

My questions may seem to easy to answer, but since I am a beginner programmer in GUROBI, you may forgive me and help me to have a better understanding of what is happening there.

As it is obvious from title, I am dealing with adding cut in bender decomposition within a callback function. My problem is MIP. So, I may add either lazy cut or user cut.
There are three main questions that I have for everybody that can help me and I would appreciate:

1. In general to add cut, what should my "where" argument be, MIPNODE, MIPSOL or MIP? even more than that, if you wanna give me some mapping between those concept and a simple Branch and Bound algorithm, what are the corresponding steps in a B&B algorithm for MIPNODE, MIPSOL and MIP? You agree that GUROBI manual, though very detailed and useful, is not clear enough in this part.

2. My cuts, potentially, can cut off some integer solution, so obviously I should use Lazy cut. Should I use MIPSOL for lazy cut?

3. My problem is a MIP with positive and binary variables. But when I try to obtain some solution in MIPSOL, it gives me some, apparently, in-feasible solutions. For example there are some negative or NAN values there that I have no clue what they are!! What gurobi is doing there?

Thank you in advance.

Best,
  

Jakob Sch.

unread,
Nov 4, 2014, 5:24:16 PM11/4/14
to gur...@googlegroups.com
Hi Bob,

 
1. In general to add cut, what should my "where" argument be, MIPNODE, MIPSOL or MIP? even more than that, if you wanna give me some mapping between those concept and a simple Branch and Bound algorithm, what are the corresponding steps in a B&B algorithm for MIPNODE, MIPSOL and MIP? You agree that GUROBI manual, though very detailed and useful, is not clear enough in this part.
MIP is a general status in the branch-and-bound procedure. This status is usually used just for logging purposes...
MIPSOL is obtained when a heuristic finds a new incumbent (i.e. a new feasible solution)
MIPNODE is the status when a node in the search-tree is solved

2. My cuts, potentially, can cut off some integer solution, so obviously I should use Lazy cut. Should I use MIPSOL for lazy cut?
Yes, but you might also want to check MIPNODE when all binary/integer variables are integer (i.e. you found a node in the search-tree that is integer feasible) -- I'm not sure whether this was fixed (but a while ago I had to check this case separately)
 
3. My problem is a MIP with positive and binary variables. But when I try to obtain some solution in MIPSOL, it gives me some, apparently, in-feasible solutions. For example there are some negative or NAN values there that I have no clue what they are!! What gurobi is doing there?
You might have to give the variables to the model so that the callback can properly get the values. If you can post some code, finding the error is a lot easier.

Best regards,
Jakob
 

Bob Pay

unread,
Nov 5, 2014, 8:28:08 PM11/5/14
to gur...@googlegroups.com
Jakob

Thank you so much for your help, I am modifying my code based on what you said here, and what I found out from searching, so I will work on that and then I will share it here to see what is wrong.
Best,

Bob Pay

unread,
Nov 10, 2014, 11:02:53 AM11/10/14
to gur...@googlegroups.com
I will appreciate if you help me on this:

this is part of my code that I am adding lazy constraint inside the callback function (any variable that has the MIPNODE in the beginning of the name, is just the value of that variable inside the MIPSOL and is just wrong naming):

MIPNODE_expr_tmp = model._teta[s] - (quicksum(model._Cost[(s,(i,j))] + (model._d[(s,(i,j))] * model._x_master[(i,j)]) for (i,j) in model._P[s,model._l[s]]))
 
MIPNODE_expr_tmp2 = MIPNODE_master_teta[s] - (quicksum(model._Cost[(s,(i,j))]  + model._d[(s,(i,j))] * MIPNODE_master_x_hat[(i,j)] for (i,j) in model._P[s,model._l[s]]))

            if MIPNODE_expr_tmp2 > 1E-5:
#               add lazy cut
                print("**************************lazzzzzzzzzzzzzzzzzzzzzzzzzzzy")
                model.cbLazy(MIPNODE_expr_tmp <= 0)
                model._flag = 0

Before coming to callback, I send the list of variable to callback like this:

m1._x_master = x_master
m1._teta = teta

x_master and teta are the name of variable list when I was defining them in model.

now when inside the callback, algorithm try to add a lazy constrain, an error happens that I don't know why:

************* WE ARE IN MIPSOL *****************
**************************lazzzzzzzzzzzzzzzzzzzzzzzzzzzy
Exception gurobipy.GurobiError: GurobiError() in 'gurobipy.callbackstub' ignored



On Tuesday, November 4, 2014 5:24:16 PM UTC-5, Jakob Sch. wrote:

Renan Garcia

unread,
Nov 10, 2014, 11:52:01 AM11/10/14
to gur...@googlegroups.com
Bob,

To help diagnose the issue, wrap your callback code in a try statement to catch the GurobiError exception and display the corresponding message, i.e.,

  try:
    # your callback code here
  except GurobiError as e:
    print('GurobiError: %s' % e.message)

Renan

--

---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dr Michael F

unread,
Nov 10, 2014, 5:45:10 PM11/10/14
to gur...@googlegroups.com
Bob,

As a regular user of lazy constraints, I get this error if I forget to set the "LazyConstraint" parameter to 1.  Is that your problem?

Michael

Bob Pay

unread,
Nov 10, 2014, 10:29:37 PM11/10/14
to gur...@googlegroups.com
Dear Dr. Michael F
That was the source of error. I set the parameter to one and now there is no error in callback, though the result is still wrong that I should work on that. Somehow my lazy cut is cutting the optimal solution out.

Thank you for your suggestion.

Bob Pay

unread,
Nov 10, 2014, 10:31:09 PM11/10/14
to gur...@googlegroups.com
Dear Renan
That was a great idea that would never come to my mind, Thank you to sharing that with me.

Best,
Reply all
Reply to author
Forward
0 new messages