Learn R Programming

Rmosek (version 0.9.5)

mosek_write: Write problem to a model file

Description

Outputs a model of an optimization problem in any standard modelling fileformat (e.g. lp, opf, mps, mbt, etc.), controlled by a set of options. The modelling fileformat is selected based on the extension of the modelfile.

Usage

mosek_write(problem, modelfile, opts = list())

Arguments

problem
The optimization problem. lll{ problem LIST }
modelfile
The file to write the optimization model. lll{ modelfile STRING (filepath) }
opts
The interface options. lll{ opts LIST (OPTIONAL) ..$verbose NUMERIC (OPTIONAL) ..$usesol BOOLEAN (OPTIONAL) ..$useparam BOOLEAN (OPTIONAL) }

Value

  • rThe returned result. lll{ r LIST ..$response LIST ....$code NUMERIC ....$msg STRING }
  • The result is a named list containing the response of the MOSEK Optimization Library when writing to the model file. Note that the result can be NULL if interfacing errors are encountered.

    lll{ r Result .$response Response from the MOSEK Optimization Library ..$code ID-code of response ..$msg Human-readable message }

Details

The problem should be compliant with the input specification of function mosek. Please see this function for more details.

The modelfile should be an absolute path to the model file. If the file extension is .opf, the model will be written in the Optimization Problem Format. Other formats include lp, mps and mbt.

The amount of information printed by the interface can be limited by verbose (default=10). Whether to write the initial solution, if one such exists in the problem description, is indicated by usesol which by default is FALSE. Whether to write the full list of parameter settings, some of which may have been specified by the problem description, is indicated by useparam which by default is FALSE.

ll{ problem Problem desciption modelfile Filepath to the model opts Options .$verbose Output logging verbosity .$usesol Whether to write an initial solution .$useparam Whether to write all parameter settings }

See Also

mosek mosek_read

Examples

Run this code
lo1 <- list()
 lo1$sense <- "max"
 lo1$c <- c(3,1,5,1)
 lo1$A <- Matrix(c(3,1,2,0,
                   2,1,3,1,
                   0,2,0,3), nrow=3, byrow=TRUE, sparse=TRUE)
 lo1$blc <- c(30,15,-Inf)
 lo1$buc <- c(30,Inf,25)
 lo1$blx <- c(0,0,0,0)
 lo1$bux <- c(Inf,10,Inf,Inf)
 rr <- mosek_write(lo1, "lo1.opf")
 if (is.null(rr) || !identical(rr$response$code, 0))
   stop("Failed to write model file to current working directory")

Run the code above in your browser using DataLab