Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark mode
Gurobi Optimizer Reference Manual
Light LogoDark Logo

Concepts

Features

Reference

Gurobi
Back to top

GRBBatch#

GRBBatch#

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 batch objects includeUpdate (refresh attributes from theCluster Manager),Abort (abort executionof a batch request),Retry (retryoptimization for an interrupted or failed batch),Discard (remove the batch request andall related information from the Cluster Manager), andGetJSONSolution (querysolution information 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:

You can access their values ,batch.BatchStatus orbatch.BatchID, or by usingGet. Notethat all Batch attributes are locally cached, and are only updated whenyou create a client-side batch object or when you explicitly update thiscache, which can done by callingUpdate.

GRBBatchGRBBatch(GRBEnv&env,string&batchID)#

Constructor forGRBBatch.

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.

Parameters:
  • 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.

Returns:

New batch object.

Example:
GRBBatchbatch=GRBBatch(env,batchID);
voidAbort()#

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.

Example:
// Abort this batch if it is taking too longTimeSpaninterval=DateTime.Now-start;if(interval.TotalSeconds>maxwaittime){batch.Abort();break;}
voidDiscard()#

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.

Example:
// Remove batch request from managerbatch.Discard();
stringGetJSONSolution()#

This method 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.

Returns:

The requested solution in JSON format.

Example:
// Get JSON solution as stringConsole.WriteLine("JSON solution:"+batch.GetJSONSolution());
intGet(GRB.IntAttrattr)#

Query the value of an int-valued batch attribute.

Parameters:

attr – The attribute being queried.

Returns:

The current value of the requested attribute.

stringGet(GRB.StringAttrattr)#

Query the value of a string-valued batch attribute.

Parameters:

attr – The attribute being queried.

Returns:

The current value of the requested attribute.

voidRetry()#

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.

Example:
// If the batch failed, we retry itif(batch.BatchStatus==GRB.BatchStatus.FAILED){batch.Retry();System.Threading.Thread.Sleep(2000);batch.Update();}
voidUpdate()#

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).

Example:
// Update the resident attribute cache of the Batch object// with the latest values from the cluster manager.batch.Update();
voidWriteJSONSolution(string&filename)#

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.

Parameters:

filename – Name of file where the solution should be stored (inJSON format).

Example:
// Write the full JSON solution string to a filebatch.WriteJSONSolution("batch-sol.json.gz");

Help and Feedback

On this page

[8]ページ先頭

©2009-2025 Movatter.jp