Write problem to a model file

Share:

Description

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

Usage

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

Arguments

problem

The optimization problem.

problem LIST
modelfile

The file to write the optimization model.

modelfile STRING (filepath)
opts

The interface options.

opts LIST (OPTIONAL)
..$verbose NUMERIC (OPTIONAL)
..$usesol BOOLEAN (OPTIONAL)
..$useparam BOOLEAN (OPTIONAL)
..$getinfo BOOLEAN (OPTIONAL)
..$scofile STRING (filepath) (MANDATORY IN SCOPT)

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 or relative 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.

The option scofile is used in separable convex optimization to specify the absolute or relative path to the operator file.

problem Problem description
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
.$getinfo Whether to extract MOSEK information items
.$scofile Destination of operators from scopt

Value

r

The returned result.

r LIST
..$response LIST
....$code NUMERIC
....$msg STRING
..$iinfo/$dinfo LIST *
....$<MSK_INFO> NUMERIC *
*Starred items must be requested using an option.

The result is a named list containing the response of the MOSEK Optimization Library when writing to the model file. A response code of zero is the signal of success.

Setting option getinfo to TRUE extracts iinfo and dinfo.

r Result
.$response Response from the MOSEK Optimization Library
..$code ID-code of response
..$msg Human-readable message
.$iinfo/$dinfo MOSEK information list
..$<MSK_INFO> Value of any <MSK_INFO>

See Also

mosek mosek_read

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 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$bc <- rbind(blc = c(30,15,-Inf),
                 buc = c(30,Inf,25));
 lo1$bx <- rbind(blx = c(0,0,0,0),
                 bux = c(Inf,10,Inf,Inf));
 rr <- mosek_write(lo1, "lo1.opf")
 if (!identical(rr$response$code, 0))
   stop("Failed to write model file to current working directory")