Initializing help system before first use

AppInterface.update

AppInterface.update


Purpose
Sends a progress update notification for a single metric from the model to the Xpress Insight system.
Synopsis
update(self, metric: xpressinsight.Metric, value: Union[float, int, xpressinsight.ObjSense]) -> None
Arguments
metric 
The type of metric to update.
value 
The value of the metric to update.
Example
Notify Insight that the current best solution value is 51.9.
>>> insight.update(Metric.OBJVAL, 51.9)		
Automatic updating of metrics during optimization can be achieved by calling the update function from within a suitable solver callback:
>>> def on_gap_notify(prob, app):
...
...     num_sol = prob.attributes.mipsols
...     app.insight.update(xi.Metric.NUMSOLS, num_sol)
...
...     if num_sol == 0:
...         # Can only occur when mipabsgapnotifybound is used.
...         # Don't call gapnotify again.
...         return None, None, None, None
...
...     objective = prob.attributes.mipobjval
...     best_bound = prob.attributes.bestbound
...
...     if best_bound != 0 or objective != 0:
...         gap = abs(objective - best_bound) / \
...               max(abs(best_bound), abs(objective))
...     else:
...         gap = 0
...
...     app.insight.update(xi.Metric.OBJVAL, objective)
...     app.insight.update(xi.Metric.GAP, gap)
...
...     if gap > 1e-6:
...         new_rel_gap_notify_target = gap - 1e-6
...     else:
...         # Don't call gapnotify again.
...         new_rel_gap_notify_target = -1
...
...     return new_rel_gap_notify_target, None, None, None		
The above callback can then be attached via the Xpress Python API:
>>> prob = xp.problem()
...
... # TODO: Define the optimization problem
...
... # Optionally reset progress and set the objective sense
... self.insight.reset_progress()
... self.insight.update(xi.Metric.OBJSENSE, prob.attributes.objsense)
...
... prob.controls.miprelgapnotify = 1e20
... prob.addcbgapnotify(on_gap_notify, self, 0)
...
... prob.solve()		
Further information
This function allows the model to report back progress to the system where it is accessible by a client for display.
Related topics

© 2001-2020 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.