# 1 Technical Issues¶

How do I dump the problem to a file to attach with my support question?

Just before optimization do:

 Fusion API C++ M->writeTask("dump.task.gz"); Java M.writeTask("dump.task.gz"); .NET M.WriteTask("dump.task.gz"); Python M.writeTask("dump.task.gz") Optimizer API C MSK_writetask(task, "dump.task.gz"); Java task.writetask("dump.task.gz"); .NET task.writetask("dump.task.gz"); Python task.writetask("dump.task.gz") MATLAB Toolbox mosekopt('write(dump.task.gz)',prob) Rmosek r <- mosek_write(prob, "dump.task.gz") Command line mosek input_file -out dump.task.gz Mosek.jl Mosek.writetask(task, "dump.task.gz") Third party CVX cvx_solver_settings('write', 'dump.task.gz') CVXPY 1.0 prob.solve(solver=MOSEK, save_file="dump.task.gz") YALMIP sdpsettings('savedebug',1) followed by load('mosekdebug') mosekopt('min write(dump.task.gz)', prob, param) choose min or max depending on the problem JuMP JuMP.build(model) Mosek.writetask(internalmodel(model).task, "dump.task.gz")

I am using a third-party interface to MOSEK. How do I set solver parameters?

Here are instructions for some interfaces we are aware of:

• CVXPY. When invoking the solver, pass a dictionary mosek_params with pairs parameter: value. For example

prob.solve(solver=cvxpy.MOSEK, mosek_params={mosek.iparam.num_threads: 1})


will limit the number of threads to 1.

• YALMIP. Pass options using sdpsettings. For example

ops = sdpsettings('solver', 'mosek', 'mosek.MSK_IPAR_NUM_THREADS', 1);
optimize(constraints, objective, ops);


will limit the number of threads to 1.

• CVX. Set parameters using cvx_solver_settings. For example

cvx_solver_settings('MSK_IPAR_NUM_THREADS', 1);


will limit the number of threads to 1.

• JuMP. Set parameters when creating the solver using full or partial names from the C API. For example

model = Model(solver=MosekSolver(NUM_THREADS=1))


will limit the number of threads to 1.

• CVXOPT. Pass options through the dictionary solvers.options['mosek']. For example

cvxopt.solvers.options['mosek'] = {mosek.iparam.num_threads: 1}


will limit the number of threads to 1.

How do find my exact MOSEK version?

 Fusion API C++ mosek::fusion::Model::getVersion(); Java mosek.fusion.Model.getVersion(); .NET mosek.fusion.Model.GetVersion(); Python mosek.fusion.Model.getVersion() Optimizer API C MSK_getversion(&major, &minor, &rev); Java mosek.Env.getversion(major, minor, rev); .NET mosek.Env.getversion(out major, out minor, out rev); Python mosek.Env.getversion() MATLAB [r, res] = mosekopt('version'); res.version R ver <- mosek_version() Command line mosek -v Julia Mosek.getversion()

On Mac OS I get errors about missing libmosek64.8.1.dylib or similar files.

Most likely you forgot to run the Mac OS installation script as described in the installation manual. Go to the bin directory of your MOSEK installation and run

python install.py


In MATLAB on Windows I get Invalid MEX-file ...\mosekopt.mexw64: The specified module could not be found.

Most likely the folder with MOSEK DLLs, ...\win64x86\bin or ...\win32x86\bin, is not in the environment variable PATH and the shared libraries cannot be found. Add this folder to the environment variable PATH. You can also do it inside MATLAB using the setenv command.

MOSEK is ignoring the limit on the number of threads.

There are a few possible explanations:

• If you are using the conic optimizer, the number of threads should be set before the first optimization. After that the thread pool is reserved for the process and its size will not be affected by subsequent changes of the parameter. It will only be possible to switch between using all those threads and a single-threaded run.
• If you are using Python, it is possible that numpy, and not the MOSEK optimizer, is using many threads. Set the environment variable MKL_NUM_THREADS. For more information on limiting the thread usage in numpy see for example this thread or this one .

When using the Python interface I get a RuntimeWarning: Item size computed from the PEP 3118.

This is caused by a bug in the CTypes module in Python 2.7 and 3.x, related to Issue 10744 and Issue 10746. These issues are only registered as being related to Python 3.1+, but the ctypes code from 3.x is routinely back-ported to 2.7. The problem is that CTypes reports the size and shape of arrays correctly, but provides a wrong element formatting string: Numpy and other libraries may check this and issue a warning. The bug appears to be harmless; we know of no cases where the invalid information is used.

The Python API or Python Fusion API will not accept a numpy array, only a list.

The Python interfaces accept numpy arrays. The problem here is most likely that the numpy array is of wrong type, usually int instead of float where MOSEK expects floating-point data. Use dtype=float when constructing the array, if necessary.

Can the C API be used from Fortran?

MOSEK has no official support for FORTRAN, but if the FORTRAN compiler supports C calling convention it should be possible use to the C API. The appropriate FORTRAN compiler documentation will have to tell you how to do it.

Can MOSEK run on virtualized server such as VmWare server?

Yes, MOSEK runs fine on a virtualized server. However, particularly when solving large problems, MOSEK can exploit all the resources of computer and hence using a virtualized server may cost performance. If performance is important it is recommended to test whether MOSEK runs as fast on the virtualized server as on a native server for the relevant applications.

How do I write an MPS file using GAMS and MOSEK?

GAMS can write native MPS files but they do not include any nonlinear information so they are not useful for nonlinear problems. However, it is possible to MPS files using MOSEK as follows. Create a file name mosek.opt that has the content

MSK_SPAR_DATA_FILE_NAME somename.mps


and then execute the command gams mygamsprogram. MOSEK should now write the file somename.mps.

Does MOSEK work with MinGW?

Yes. MOSEK includes libraries that are compatible with MinGW and MinGW-w64. Applications built with MinGW should link with mosek7_0.lib and libmosek64_7_0.a on the platforms win32x86 and win64x86 respectively. The native import library (.lib) will not work on 64bit Windows.

Does MOSEK support Cygwin?

No. Cygwin is not supported. An alternative to using Cygwin is the use of MinGW toolchain that is supported by MOSEK.

# 2 Modeling Issues¶

MOSEK is not solving my quadratic optimization problem fast enough. What should I do?

Can MOSEK solve nonconvex problems?

MOSEK cannot solve continuous non-convex optimization problems, and if non-convexity is detected, the solver will terminate. MOSEK may not always be able to detect non-convexity, but we strongly recommend not to apply MOSEK to non-convex problems.

Can MOSEK handle SOS (or SOS2) sets in mixed integer optimization?

MOSEK has no special support for SOS1 or SOS2 (special ordered sets). Note that SOS1 can easily be implemented with linear constraints of the form $$x_1 + x_2 + \ldots \leq 1$$

Why does MOSEK not report a dual solution when I have solved a mixed integer problem?

In general, the dual problem corresponding to a mixed-integer problem is not well-defined. In some cases the desired dual solution is the one obtained by fixing all integer variables at their optimal solution values and re-solving the problem with the continuous optimizer.

Can I get the solution MOSEK produce in every iteration of the optimizer?

No. Since MOSEK performs a lot of transformations on the problem before starting to solve it, the intermediate solution values may make little sense in the context of the user-specified problem. These solution values are not made available.

Can the MOSEK interior-point optimizers be hot-started?

No, since there are no known generally reliable ways to hot-start interior-point methods. This is an open research topic.

Why do not I get a good speedup when using multiple threads?

There are many reasons why a good speedup cannot be achieved when using more threads. Some of them are:

• Not all operations can be parallelized, as for instance the presolve phase.
• There is an overhead associated with using multiple threads because coordinating the multiple threads requires some management operations which cost some of the computational performance. This is particular visible if more threads than the number of cores is employed.
• Assume you are parallelizing the inner product of two long vectors using two threads. Now each thread will have to move data from main memory to CPU. Since the amount data that can be moved from main memory and to the CPUs is limited then data movement easily becomes the bottleneck. This will limit the potential speedup.
• For many operations such as matrix multiplication then the sequential version runs relatively faster the larger the matrices are. Now if matrix multiplication is parallelized then one big matrix multiplication is replaced by several small ones leading to a loss of efficiency compared to the sequential one. Hence, a linear speedup is not archived.
• Some recent CPUs may boost the clock frequency if the CPU is not loaded too heavily. This is likely to be the case if only one thread is employed. See Intel’s explanation for details. This will of course offset some of the benefits of using multiple threads.

To summarize obtaining a linear speedup when using multiple threads is nearly impossible. In fact in many cases it is not possible to obtain any speedup if the job to be parallelized is small.

Why does MOSEK not produce the same solution for a problem across different runs?

This is because using different number of threads, different operating system etc. can lead to arithmetic operations being executed in different order, leading to different rounding errors and in consequence a different solution. For instance, the associative law $$(a+b)+c = a+(b+c)$$ does not always hold in floating-point arithmetic, so the order in which the computations are performed affects the result. These differences should be miniscule, otherwise it may be a sign that the problem is ill-posed.

However, MOSEK should be run-to-run deterministic under the following conditions:

• exactly the same problem is being solved,
• it is run on the same machine,
• exactly the same parameter settings are used,
• no time limits are specified.

Typical causes of apparent non-determinism include:

• the tasks are not 100% identical, for example constraints or variables appear in different order,
• data entered into the task is not always the same. For example some numerical routines in numpy, such as singular value decomposition, are not fully deterministic.
• different number of threads is used.

Is the simplex optimizer in MOSEK parallelized?

The simplex optimizers in MOSEK are not parallelized and hence cannot exploit multiple threads. The iterations in the simplex algorithm very serial in nature, and each iteration performs so little work that they cannot efficiently be parallelized. To our knowledge, high-performance large scale parallel simplex is currently unavailable.

Is the mixed integer optimizer parallelized in MOSEK?

Yes, the branch-and-bound algorithm is parallelized. Moreover, each relaxation can be solved in parallel using either the concurrent optimizer or the parallelized interior-point optimizer.

How do I model absolute value?

You can model the constraint

$t\geq | x |$

with

$t\geq x,\ t\geq -x.$

If you need to model the exact equality $$t=|x|$$ then integer variables are required - this constraint is not convex.

My license file says VER=8.0. Can I use version 8.1?

Yes. Only the major version number matters.

After you put the license file in the right place restart Matlab. It caches the license.

If you want to perform a moderate amount of optimizations, but they are spread over many machines, then you are more likely to use a floating license. If you are only going to run MOSEK on one machine, but you want unlimited number of simultaneous optimizations, then you are more likely to use a server license.

With one floating license token, one process can use MOSEK at a time.

Does the licensing software make some sort of a network connection to MOSEK to validate the license?

No. Never. All the license system needs is in the license file.

When I change hostid, can I first test the new license while still using the old one?

Of course. We understand that a switch requires some amount of testing, while the old license is still being used. When you are happy that the new setup works, you must disable the old license server.

The lmutil and lmgrd will not start on Linux: No such file or directory.

If you run a command from the licensing system and get this error:

user@hostname:~/path_to_mosek\$ ./lmutil
./lmutil: No such file or directory


then most likely the Standard Base (LSB) package version 3 or newer is not installed on your system. On Ubuntu the latest version of LSB can be installed with the command apt-get install lsb.

Can a MOSEK license be used under Citrix?

This is not a case that we test for, but MOSEK employs a floating license scheme by default and that works under Citrix.

Is it possible to reserve a number licenses to particular group of users or hosts?

Yes it is. To reserve a certain number license features for a particular user or IP address, you must create an additional options file and use the RESERVE option. For details see FLEXnet license administration guide. For example, to reserve one PTS token for user username make an options file res.opt with content

RESERVE 1 PTS USER username


VENDOR MOSEKLM OPTIONS=res.opt


Is it possible to use MOSEK with a floating license on a machine detached from the LAN(WAN)?

Yes. It is possible to use the lmborrow functionality. See the FLEXnet license administration guide.

How many license token servers should I have?

All MOSEK licenses are floating. That means if you install one license on one computer the computer can act as a token server for itself. In reality it will often be easier and more economical to use few shared token servers rather than one per MOSEK installation. Each token server would require at least one license, and often this would mean that each license is free most of the time. A best practice is to employ one or two token servers for each site, where 2 token servers are employed if licenses for development and production should be kept separate.

The token server will not start under Ubuntu.

Flexlm needs the directory /usr/tmp to exists and have write access by the user running lmgrd.

Is it possible to host a token server on Amazon Cloud?

It is definitely possible, although some specific steps must be performed. Please see the licensing guide for details.

# 4 Miscellanea¶

• The user manuals for all interfaces are available online at http://www.mosek.com/documentation .
• PDF manuals are also contained in the distribution (directory docs).
• All example files are contained in the distribution package.
• Each manual contains a detailed API reference as the last few sections.

How do I cite MOSEK in an academic publication?

The preferred way to cite MOSEK is to use a BibTex entry as

@manual{mosek,
author = "MOSEK ApS",
title = "XXX",
year = 2017,
url = "YYY"
}


where YYY is the link to the relevant manual of the specific API used, and XXX is the title of the manual main page. For instance, citing the MATLAB toolbox would result in

@manual{mosek,
author = "MOSEK ApS",
title = "The MOSEK optimization toolbox for MATLAB manual. Version 8.1.",
year = 2017,
url = "http://docs.mosek.com/8.1/toolbox/index.html"
}


The same applies for all other material we provide on the web site.