Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# R API - Input-Output

gurobi_read(filename, params=NULL)

  Reads a model from a file.

  Parameters:

    - filename – Name of the file to read. Note that the type of the file is encoded in the file name suffix. The filename suffix should be one of `.mps`, `.rew`, `.lp`, `.rlp`, `.dua`, `.dlp`, `.ilp`, or `.opb` (see the file formats section for details on Gurobi file formats). The files can be compressed, so additional suffixes of `.zip`, `.gz`, `.bz2`, `.7z` or `.xz` are accepted.

    - params – The params `list`, when provided, contains a list of modified Gurobi parameters. See the params argument section for more information.

  Returns:

    A `model` list variable, as described in the model section.

  Example:

        model <- gurobi_read('stein9.mps')
        result <- gurobi(model)

gurobi_write(model, filename, params=NULL)

  Writes a model to a file.

  Parameters:

    - model – The model `list` must contain a valid Gurobi model. See the model argument section for more information.

    - filename – Name of the file to write. Note that the type of the file is encoded in the file name suffix. The filename suffix should be one of `.mps`, `.rew`, `.lp`, `.rlp`, `.dua`, `.dlp`, `.ilp`, or `.opb` to indicate the desired file format (see the file formats section for details on Gurobi file formats). The files can be compressed, so additional suffixes of `.zip`, `.gz`, `.bz2`, `.7z` or `.xz` are accepted. Note that this function does not write the result of the IIS computation into an .ilp file format. See section `gurobi_iis` for more details.

    - params – The params `list`, when provided, contains a list of modified Gurobi parameters. See the params argument section for more information.

  Example:

        model            <- list()
        model$A          <- matrix(c(1,2,3,1,1,0), nrow=2, byrow=T)
        model$obj        <- c(1,1,2)
        model$modelsense <- 'max'
        model$rhs        <- c(4,1)
        model$sense      <- c('<', '>')
        gurobi_write(model, 'mymodel.mps');
        gurobi_write(model, 'mymodel.lp');
        gurobi_write(model, 'mymodel.mps.bz2');

Help and Feedback

Press `/` or click to search this documentation | Gurobi website | Gurobi community forum
Go to other Gurobi documentation | Gurobi download | Contact support