problem.addcbbariteration
| problem.addcbbariteration | 
  Purpose
 
  Declares a barrier iteration callback function, called after each iteration during the interior point algorithm, with the ability to access the current barrier solution/slack/duals or reduced cost values, and to ask barrier to stop. This callback function will be called in addition to any callbacks already added by addcbbariteration.
 
  Synopsis
 
 problem.addcbbariteration (f_bariteration, object, priority)
 barrier_action = f_bariteration (my_prob, my_object)
 
 
  Arguments
 
| 
     f_bariteration 
     | 
     The callback function itself. This takes two arguments,
     my_prob and
     my_object, and returns an integer return value. This function is called at every barrier iteration.
     | ||||||||||||
| 
     my_prob 
     | 
     The problem passed to the callback function,
     fubi.
     | ||||||||||||
| 
     my_object 
     | 
     The user-defined object passed as
     object when setting up the callback with
     addcbbariteration.
     | ||||||||||||
| 
     barrier_action 
     | 
     Defines a return value controlling barrier:
     
 | ||||||||||||
| 
     object 
     | 
     A user-defined object to be passed to the callback function,
     f_bariteration.
     | ||||||||||||
| 
     priority 
     | 
     An integer that determines the order in which callbacks of this type will be invoked. The callback added with a higher priority will be called before a callback with a lower priority. Set to 0 if not required.
     | 
  Example
 
 This simple example demonstrates how the solution might be retrieved for each barrier iteration.
 
# Barrier iteration callback
def BarrierIterCallback (my_prob, my_object):
    current_iteration = my_prob.attributes.bariter
    PrimalObj = my_prob.attributes.barprimalobj
    DualObj   = my_prob.attributes.bardualobj
    Gap = DualObj - PrimalObj
    PrimalInf        = my_prob.attributes.barprimalinf
    DualInf          = my_prob.attributes.bardualinf
    ComplementaryGap = my_prob.attributes.barcgap
    # decide if stop or continue
    barrier_action = 0
    if (current_iteration >= 50 or
        Gap <= 0.1 * max (abs (PrimalObj), abs (DualObj))):
        barrier_action = 2
    return barrier_action
# To set callback:
xprob.addcbbariteration (BarrierIterCallback, myobj, 0)
  Further information
 
 1. Only the following functions are expected to be called from the callback:
 problem.getlpsol and the attribute/control value retrieving and setting routines.
 
 2. Please note that these values refer to the scaled and presolved problem used by barrier, and may differ from the ones calculated from the postsolved solution returned by
 problem.getlpsol.
 
  Related topics
 
 
