How to generate user cut or lazy cut

287 views
Skip to first unread message

zhic...@gmail.com

unread,
Sep 14, 2017, 1:16:35 AM9/14/17
to Pyomo Forum
Hi,
    I'm trying to use the user cut or lazy cut to solve my problem. But I find out the callback function will never be run during the solving. So I test an simple example, which is learned from sc_script example.
    I'm expecting to get at least one print out from three callback functions, but I don't. 
    Can anybody tell me what I did wrong?


=========test.py============
from pyomo.core import *
model = AbstractModel(name="Master")
model.x = Var(within=Integers, bounds=(0,2))
model.y = Var(within=Integers, bounds=(0,2))
def min_obj_rule(model):
return model.y
model.oMaster = Objective(rule=min_obj_rule,sense=minimize)

=========run.py=============
test_mdl = import_file("test.py").model
test_inst = test_mdl.create_instance()
def solve_callback(solver, test_inst ):
    print "CB-Solve"
def cut_callback(solver, test_inst ):
    print "CB-Cut"
def node_callback(solver, test_inst ):
    print "CB-Node"
opt = SolverFactory('_cplex_direct')
opt.set_callback('cut-callback', cut_callback)
opt.set_callback('node-callback', node_callback)
opt.set_callback('solve-callback', solve_callback)
results = opt.solve(test_inst , tee=True)
print results

==========results============
Warning: Control callbacks may disable some MIP features.
CPXPARAM_Read_DataCheck                          1
CPXPARAM_Read_APIEncoding                        "UTF-8"
CPXPARAM_MIP_Strategy_CallbackReducedLP          0
Found incumbent of value 0.000000 after 0.00 sec. (0.00 ticks)

Root node processing (before b&c):
  Real time             =    0.00 sec. (0.00 ticks)
Sequential b&c:
  Real time             =    0.00 sec. (0.00 ticks)
                          ------------
Total (root+branch&cut) =    0.00 sec. (0.00 ticks)

Problem: 
- Name: 
  Lower bound: None
  Upper bound: None
  Number of objectives: 1
  Number of constraints: 0
  Number of variables: 2
  Number of binary variables: 0
  Number of integer variables: 2
  Number of continuous variables: 0
  Number of nonzeros: None
  Sense: unknown
Solver: 
- Name: CPLEX 12.7.1.0
  Status: ok
  Return code: None
  Message: None
  User time: 0.0
  System time: None
  Wallclock time: None
  Termination condition: optimal
  Termination message: None
Solution: 
- number of solutions: 0
  number of solutions displayed: 0

Watson, Jean-Paul

unread,
Sep 17, 2017, 6:50:31 PM9/17/17
to pyomo...@googlegroups.com
A warning: the callback functionality in the direct interfaces that you currently see in Pyomo are at best prototypical, and really not even that - "experimental" might be the best word. We have newer and more comprehensive direct plugins in the pipeline, but they will not be ready for release for at least a few months.

That said, I'm not sure why your specific callbacks are not being invoked. I suspect it is because the instance is solved in pre-solve, given its relative difficulty.

Jpw
--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages