Movatterモバイル変換


[0]ホーム

URL:


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

Concepts

Features

Reference

Gurobi
Back to top

Input-Output#

intGRBreadmodel(GRBenv*env,constchar*filename,GRBmodel**modelP)#

Read a model from a file.

Return value:

A non-zero return value indicates that a problem occurred while reading the model. Refer to theError Codes tablefor a list of possible return values. Details on the error can be obtainedby callingGRBgeterrormsg.

Arguments:
  • env – The environment in which to load the new model. This shouldcome from a previous call toGRBloadenv.

  • filename – The path to the file to be read. Note that the type ofthe file is encoded in the file name suffix. Valid suffixes are.mps,.rew,.lp,.rlp,.dua,.dlp,.ilp, or.opb. The files can be compressed, so additionalsuffixes of.zip,.gz,.bz2,.7z or.xz are accepted.

  • modelP – The location in which the pointer to the model should beplaced.

Example:
GRBmodel*model;error=GRBreadmodel(env,"/tmp/model.mps.bz2",&model);
intGRBread(GRBmodel*model,constchar*filename)#

This method is the general entry point for importing data from a fileinto a model. It can be used to read basis files for continuous models,start vectors for MIP models, variable hintsfor MIP models, branching priorities for MIP models, or parameter settings.The type of data read is determined by the filesuffix. File formats are described in theFile Format section.

Note that reading a file doesnot process all pending modelmodifications. These modifications can be processed by callingGRBupdatemodel.

Note also that this isnot the method to use if you want to read anew model from a file. For that, use theGRBreadmodelroutine.

Return value:

A non-zero return value indicates that a problem occurred while reading the file. Refer to theError Codes tablefor a list of possible return values. Details on the error can be obtainedby callingGRBgeterrormsg.

Arguments:
  • model – The model that will receive the information read from thefile.

  • filename – The path to the file to be read. The suffix on the filemust be either.mst or.sol for a MIP start file,.hnt for aMIP hint file,.ord for a priority order file,.bas for a basisfile,.attr for a collection of attribute settings, or.prmfor a parameter file. The suffix may optionally befollowed by.zip,.gz,.bz2,.7z or.xz.

Example:
error=GRBread(model,"/tmp/model.mst.bz2");
intGRBwrite(GRBmodel*model,constchar*filename)#

This routine is the general entry point for writing optimization data toa file. It can be used to write optimization models, solution vectors,basis vectors, start vectors, or parameter settings. The type of datawritten is determined by the file suffix. File formats are described intheFile Format section.

Note that writing a model to a file will process all pending modelmodifications. This is also true when writing other model informationsuch as solutions, bases, etc.

Note also that when you write a Gurobi parameter file (PRM), bothinteger or double parameters not at their default value will be saved,but no string parameter will be saved into the file.

Finally, note that whenIgnoreNames=1, the namesof variables and constraints are replaced with default names whenwriting a file.

Return value:

A non-zero return value indicates that a problem occurred while writing the file. Refer to theError Codes tablefor a list of possible return values. Details on the error can be obtainedby callingGRBgeterrormsg.

Arguments:
  • model – The model containing the data to be written.

  • filename – The name of the file to be written. The file type isencoded in the file name suffix. Valid suffixes are.mps,.rew,.lp, or.rlp for writing the model itself,.dua or.dlpfor writing the dualized model (only pure LP),.ilp for writing justthe IIS associated with an infeasible model (seeGRBcomputeIISfor further information),.sol for writing the solution selected bytheSolutionNumber parameter,.mst for writing astart vector,.hnt for writing a hint file,.bas for writing anLP basis,.prm for writing modified parameter settings,.attrfor writing model attributes, or.json for writing solutioninformation in JSON format. If your system has compression utilitiesinstalled (e.g.,7z orzip for Windows, andgzip,bzip2,orunzip for Linux or macOS), then the files can be compressed, soadditional suffixes of.zip,.gz,.bz2,.7z or.xz are accepted.

Example:
error=GRBwrite(model,"/tmp/model.rlp.gz");

Help and Feedback

On this page

[8]ページ先頭

©2009-2025 Movatter.jp