Concepts
Features
Reference
Gurobi batch object. Batch optimization is a feature available with theGurobi Cluster Manager. It allows a client program to build anoptimization model, submit it to a Compute Server cluster (through aCluster Manager), and later check on the status of the model andretrieve its solution. For more information, please refer to theBatch Optimization section.
Commonly used methods on the batch object includeupdate (refresh attributes from theCluster Manager),abort (abort executionof a batch request),retry (retryoptimization for an interrupted or failed batch request),discard (remove the batch request andall related information from the Cluster Manager), andgetJSONSolution (query solutioninformation for the batch request).
These methods are built on top of calls to the Cluster Manager REST API.They are meant to simplify such calls, but note that you always have theoption of calling the REST API directly.
Batch objects have four attributes:
BatchID: Unique ID for the batch request.
BatchStatus: Last batch status. Status values aredescribed in theBatch Status Code section.
BatchErrorCode: Last error code.
BatchErrorMessage: Last error message.
You can access their values by usingget.Note that all Batch attributes are locally cached, and are only updatedwhen you create a client-side batch object or when you explicitly updatethis cache, which can done by callingupdate.
While the Java garbage collector will eventually collect an unusedGRBBatch object, the vast majority of the memory associated with amodel is stored outside of the Java heap. As a result, the garbagecollector can’t see this memory usage, and thus it can’t take thisquantity into account when deciding whether collection is necessary. Werecommend that you callGRBBatch.dispose when you are donewith the batch.
Given aBatchID, as returned byoptimizeBatch, and a Gurobi environment thatcan connect to the appropriate Cluster Manager (i.e., one whereparametersCSManager,UserName, andServerPassword have been setappropriately), this function returns aGRBBatch object. With it, you can querythe current status of the associated batch request and, once the batchrequest has been processed, you can query its solution. Please refer totheBatch Optimization section for detailsand examples.
env – The environment in which the new batch object should becreated.
batchID – ID of the batch request for which you want to accessstatus and other information.
New batch object.
// Create Batch-objectGRBBatchbatch=newGRBBatch(env,batchid);
This method instructs the Cluster Manager to abort the processing ofthis batch request, changing its status to ABORTED. Please refer to theBatch Status Codes section for furtherdetails.
// Request to abort the batchbatch.abort();
This method instructs the Cluster Manager to remove all informationrelated to the batch request in question, including the stored solutionif available. Further queries for the associated batch request will failwith error codeDATA_NOT_AVAILABLE. Use thisfunction with care, as the removed information can not be recoveredlater on.
// Request to erase input and output data related to this batchbatch.discard();
Free all resources associated with this Batch object. After this methodis called, this Batch object must no longer be used.
// Dispose resourcesbatch.dispose();
This function retrieves the solution of a completed batch request from aCluster Manager. The solution is returned as aJSON solutionstring. For this call to succeed, the status of the batchrequest must be COMPLETED. Note further that the result file storedCluster Manager side must be gzip-compressed and exactly one result fileshould be associated with this batch; for batches submittedprogrammatically through the API both will be the case. Please refer totheBatch Status Codes section for furtherdetails.
The requested solution in JSON format.
// print JSON solution into stringSystem.out.println("JSON solution:"+batch.getJSONSolution());
Query the value of an int-valued batch attribute.
attr – The attribute being queried.
The current value of the requested attribute.
Query the value of a string-valued batch attribute.
attr – The attribute being queried.
The current value of the requested attribute.
This method instructs the Cluster Manager to retry optimization of afailed or aborted batch request, changing its status to SUBMITTED.Please refer to theBatch Status Codessection for further details.
// Retry the batch jobbatch.retry();
All Batch attribute values are cached locally, so queries return thevalue received during the last communication with the Cluster Manager.This method refreshes the values of all attributes with the valuescurrently available in the Cluster Manager (which involves networkcommunication).
// Update local attributesbatch.update();
This method returns the stored solution of a completed batch requestfrom a Cluster Manager. The solution is returned in a gzip-compressedJSON file. The file name you provide must end with a .json.gz extension.The JSON format is described in theJSON solution format section. Note that for this call to succeed, the status ofthe batch request must be COMPLETED. Note further that the result filestored Cluster Manager side must be gzip-compressed and exactly oneresult file should be associated with this batch; for batches submittedprogrammatically through the API both will be the case. Please refer totheBatch Status Codes section for furtherdetails.
filename – Name of file where the solution should be stored (inJSON format).
// save solution into a filebatch.writeJSONSolution("batch-sol.json.gz");
Help and Feedback