Recording API Calls


Recording API Calls

The Gurobi Optimizer provides the option to record the set of Gurobi commands issued by your program and store them to a file. The commands can be played back later using the Gurobi Command-Line Tool. If you replay the commands on a machine with the same specs (operating system, core count, and instruction set) as the machine where you created the recording, your Gurobi calls will take the exact same computational paths that they took when you ran your original program.

Recording can be useful in a number of situations.

  • If you want to understand how much time is being spent in Gurobi routines, the replay will show you the total time spent in Gurobi API routines, and the total time spent in Gurobi algorithms.
  • If you want to check for leaks of Gurobi data, the replay will show you how many Gurobi models and environments were never freed by your program.
  • If you run into a question or an issue and you would like to get help from Gurobi, your recording will allow Gurobi technical support to reproduce the exact results that you are seeing without requiring you to send your entire application.

Recording is useful for testing across deployment scenarios. In particular, you can do the following:

  • A recording made on a Compute Server can be replayed on a Compute Server or locally. By default, the recording will use localhost:61000; this can be overridden by setting the GRB_COMPUTESERVER environment variable. If GRB_COMPUTESERVER is set to an empty string, the replay will occur locally.
  • A Cluster Manager recording can be replayed via a Cluster Manager, on a Compute Server, or locally. GRB_COMPUTESERVER has priority over GRB_CSMANAGER. If GRB_CSMANAGER is set to "", the replay will run locally or on the specified Compute Server.
  • A Gurobi Instant Cloud recording can be replayed on the cloud, on a Compute Server, or locally. Setting GRB_CLOUDACCESSID and GRB_CLOUDSECRETKEY will run the replay on the cloud. GRB_COMPUTESERVER has priority over GRB_CLOUDACCESSID (and GRB_CLOUDSECRETKEY). If GRB_CLOUDACCESSID is set to "", the replay will run locally or on the specified Compute server.
  • A token server recording can be replayed. The recording tries to use a token server at localhost (with the default port 41954). This can be overridden by setting the GRB_TOKENSERVER environment variable. If GRB_TOKENSERVER is set to an empty string, the replay will be done using a local license.
  • A recording that includes the WorkerPool parameter (used in the distributed MIP and distributed concurrent algorithms) can only be done by setting the GRB_WORKERPOOL environment variable.
For recordings of optimization with Compute Server or Instant Cloud, the recording will query the number of processors and cores from the remote worker and store this information in the recording file. When replaying a recording file, Gurobi uses these stored values.



Subsections