problem.addcbbariteration
problem.addcbbariteration(callback, data, priority)
barrier_action = callback(my_prob, my_object)
callback
|
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
data when setting up the callback with
addcbbariteration.
|
||||||||||||
barrier_action
|
Defines a return value controlling barrier:
|
||||||||||||
data
|
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.
|
# 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: prob.addcbbariteration(BarrierIterCallback, myobj, 0)
© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.