problem.addcbgapnotify
problem.addcbgapnotify(callback, data, priority)
(RelGapNotify, AbsGapNotify, AbsGapNotifyObj, AbsGapNotifyBound) = callback(my_prob, my_object)
callback
|
The callback function.
|
data
|
A user-defined object that will be passed into the callback
callback.
|
priority
|
An integer that determines the order in which multiple gap notification callbacks will be invoked. The callback added with the higher priority will be called before a callback with a lower priority. Set to
0 if not required.
|
my_prob
|
The current problem.
|
my_object
|
The user-defined object passed as
data when setting up the callback with
addcbgapnotify.
|
RelGapNotify
|
The value the
miprelgapnotify control will be set to after this callback. May be modified within the callback in order to set a new notification target. Can be
None.
|
AbsGapNotify
|
The value the
mipabsgapnotify control will be set to after this callback. May be modified within the callback in order to set a new notification target. Can be
None.
|
AbsGapNotifyObj
|
The value the
mipabsgapnotifyobj control will be set to after this callback. May be modified within the callback in order to set a new notification target. Can be
None.
|
AbsGapNotifyBound
|
The value the
mipabsgapnotifybound control will be set to after this callback. May be modified within the callback in order to set a new notification target. Can be
None.
|
def gapnotify(prob, object): obj = prob.attributes.mipobjval bound = prob.attributes.bestbound # If no solutions were found, just return a tuple of None's if prob.attributes.mipsols == 0: return None, None, None, None if obj != 0 and bound != 0: relgap = abs((obj - bound) / max(abs(obj), abs(bound))) else: relgap = 0 newRelGapNotifyTarget = -1 if relgap <= 0.1: print('Gap reached 10%') newRelGapNotifyTarget = 0.1 if relgap <= 0.01: print('Gap reached 1%') newRelGapNotifyTarget = -1 # Don't call gapnotify again # return a quadruple with new values, or # None for those that should not be set return (newRelGapNotifyTarget, None, None, None) prob.controls.miprelgapnotify = 0.1 prob.addcbgapnotify(gapnotify, None, 0) prob.mipoptimize('')
© 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.