# 5 Design Overview¶

## 5.1 Modeling¶

Rmosek package is an interface for specifying optimization problems directly in matrix form. It means that an optimization problem such as:

$\begin{split}\begin{array}{ll} \minimize & c^Tx \\ \st & Ax\leq b,\\ & x\in \mathcal{K} \end{array}\end{split}$

or

$\begin{split}\begin{array}{ll} \minimize & c^Tx \\ \st & Ax\leq b,\\ & Fx+g\in \mathcal{K} \end{array}\end{split}$

is specified by describing the matrices $$A$$, $$F$$, vectors $$b,c,g$$ and a list of cones $$\mathcal{K}$$ directly.

The main characteristics of this interface are:

• Simplicity: once the problem data is assembled in matrix form, it is straightforward to input it into the optimizer.

• Exploiting sparsity: data is entered in sparse format, enabling huge, sparse problems to be defined and solved efficiently.

• Efficiency: the API incurs almost no overhead between the user’s representation of the problem and MOSEK’s internal one.

Rmosek package does not aid with modeling. It is the user’s responsibility to express the problem in MOSEK’s standard form, introducing, if necessary, auxiliary variables and constraints. See Sec. 11 (Problem Formulation and Solutions) for the precise formulations of problems MOSEK solves.

## 5.2 “Hello World!” in MOSEK¶

Here we present the most basic workflow pattern when using Rmosek package.

Create a problem structure

Optimization problems using Rmosek package are specified using a problem structure that describes the numerical data of the problem. In most cases it consists of matrices of floating-point numbers.

Retrieving the solutions

When the problem is set up, the optimizer is invoked with the call to mosek. The call will return a response and a structure containing the solution to all variables. See further details in Sec. 7 (Solver Interaction Tutorials).

We refer also to Sec. 7 (Solver Interaction Tutorials) for information about more advanced mechanisms of interacting with the solver.

Source code example

Below is the most basic code sample that defines and solves a trivial optimization problem

$\begin{split}\begin{array}{ll} \minimize & x \\ \st & 2.0 \leq x \leq 3.0. \\ \end{array}\end{split}$

For simplicity the example does not contain any error or status checks.

Listing 5.1 “Hello World!” in MOSEK
##
prob$A <- Matrix(nrow=0, ncol=1) # 0 constraints, 1 variable prob$bx <- rbind(blx=2.0, bux=3.0) # Bounds on the only variable
prob$c <- c(1.0) # The objective coefficient # Optimize r <- mosek(prob) # Print answer r$sol$itr$xx