AppInterface.update
AppInterface.update |
update(self, metric: xpressinsight.Metric, value: Union[float, int, xpressinsight.ObjSense]) -> None
metric
|
The type of metric to update.
|
value
|
The value of the metric to update.
|
>>> insight.update(Metric.OBJVAL, 51.9)
>>> 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
>>> 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()
© 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.