4 Installation

In this section we discuss how to install and setup the MOSEK Optimizer API for .NET.

Important

Before running this MOSEK interface please make sure that you:

  • Installed MOSEK correctly. Some operating systems require extra steps. See the Installation guide for instructions and common troubleshooting tips.
  • Set up a license. See the Licensing guide for instructions.

Compatibility

The Optimizer API for .NET is compatible with the Microsoft .NET framework version 4.5 and later and with Mono v.1.2 and later.

Locating Files

The files in Optimizer API for .NET are organized as reported in Table 1.

Table 1 Relevant files for the Optimizer API for .NET.
Relative Path Description Label
<MSKHOME>/mosek/8/tools/platform/<PLATFORM>/bin Libraries <LIBDIR>
<MSKHOME>/mosek/8/tools/examples/dotnet Examples <EXDIR>
<MSKHOME>/mosek/8/tools/examples/data Additional data <MISCDIR>

where

  • <MSKHOME> is the folder in which the MOSEK package has been installed,
  • <PLATFORM> is the actual platform among those supported by the MOSEK, i.e. win32x86, win64x86.

Setting up paths

To compile a .NET program using MOSEK the correct path to mosekdotnet.dll must be provided. For example, using the Microsoft .NET compiler this is done with the command line option

csc /r:"<LIBDIR>\mosekdotnet.dll" lo1.cs

To run applications the system must be able to locate mosekdotnet.dll, either in the current directory or in the Global Assembly Cache.

4.1 Testing the Installation and Compiling Examples

This section describes how to verify that MOSEK has been installed correctly, and how to build and execute the .NET examples distributed with MOSEK.

4.1.1 Windows

Compiling and running from the command line

To compile an example, say lo1, with the Microsoft .NET compiler, open a DOS box with paths for Visual Studio set up (usually in the Start menu, the sub-menu for Visual Studio contains an entry that starts a DOS box with everything set up).

To compile the example lo1.cs distributed with MOSEK:

  • Go to the examples directory <EXDIR>.

  • To compile the code and produce an executable, type:

    csc /r:"<LIBDIR>\mosekdotnet.dll" lo1.cs
    

    or for Visual Basic:

    vbc /r:"<LIBDIR>\mosekdotnet.dll" lo1.vb
    
  • Copy mosekdotnet.dll into the directory where lo1.exe was created, and run the program with:

    lo1
    

Compiling the examples using nmake

A makefile for use with nmake, named Makefile is available in <EXDIR>. To compile all examples using this makefile use the command

make /f Makefile all

Visual Studio project

The example lo1.cs also exists as a Visual Studio 2008 project.

<EXDIR>\vs2008\MosekLo1

To use this project first copy the directory to somewhere with write permissions, e.g

C:\Documents and Settings\USERNAME

Then open the Visual Studio project file MosekLo1.csproj.

4.1.2 Mac OS and Linux

Mono is a free implementation if the .NET platform available at http://mono-project.com/. The .NET dll file is not included in the Linux distributions of MOSEK, but the dll included in the Windows distribution can be used from Mono.

To do this install MOSEK on your Mac OS or Linux platform as described in the Installation Manual. Set the environment variable

MONO_PATH

to point to mosekdotnet8_1.dll for the 64-bit Mono. You should now be able to compile and run the distributed .NET examples using Mono.

4.1.3 Using the Interface DLL

The library mosekdotnet.dll may be used from any .NET compatible language such as Visual Basic, Microsoft C# or Microsoft Managed C++. Both the examples and the library should also work with Mono on most 32-bit platforms.

The library accesses methods in the native MOSEK library (dll), which is considered unsafe from a .NET point of view. This means that use of the library in certain restricted contexts is not possible — building an ordinary application and running it from a local drive should not be a problem.

4.1.4 Interactive Use of MOSEK

It is possible to use the MOSEK .NET API interactively from .NET languages which implement a command-line interpreter, for example IronPython, available at http://ironpython.net/. This can be used to create and examine the problems and solutions from MOSEK more easily.