Try our new documentation site (beta).
Filter Content By
Version
Text Search
${sidebar_list_label} - Back
Filter by Language
custom.py
# # Copyright 2018, Gurobi Optimization, LLC # # Interactive shell customization example # # Define a set of customizations for the Gurobi shell. # Type 'from custom import *' to import them into your shell. # from gurobipy import * # custom read command --- change directory as appropriate def myread(name): return read('/home/jones/models/' + name) # simple termination callback def mycallback(model, where): if where == GRB.Callback.MIP: time = model.cbGet(GRB.Callback.RUNTIME) best = model.cbGet(GRB.Callback.MIP_OBJBST) if time > 10 and best < GRB.INFINITY: model.terminate() # custom optimize() function that uses callback def myopt(model): model.optimize(mycallback)
![](/wp-content/plugins/hd_documentations/content/images/documentation-ampl-guide.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-cloud.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-example-tour.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-quick-start.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-reference-manuals.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-remote-services.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/quickstart-os-linux.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/quickstart-os-mac-osx.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/quickstart-os-windows.webp?x70725)