7.1 Environment and task

All interaction with Optimizer API for .NET proceeds through one of two entry points: the MOSEK tasks and, to a lesser degree the MOSEK environment .

7.1.1 Task

The MOSEK task Task provides a representation of one optimization problem. It is the main interface through which all optimization is performed. Many tasks can be created and disposed of in one process.

A typical scenario for working with a task is shown below:

/* Create an optimization task */
using (mosek.Task task = new mosek.Task()) {  
  // ...
  // ... optimization ...
  // ...
}

If a task is created outside of a context that ensures automatic garbage collection then it can be disposed of manually using Task.Dispose.

7.1.2 Environment

The MOSEK environment Env coordinates access to MOSEK from the current process. It provides various general functionalities, in particular those related to license management, linear algebra, parallel optimization and certain other auxiliary functions. All tasks are explicitly or implicitly attached to some environment. It is recommended to have at most one environment per process.

Creating an environment is optional and only recommended for those users who will require some of the features it provides. Most users will NOT need their own environment and can skip this object. In this case MOSEK will internally create a global environment transparently for the user. This environment will not be accessible for the user.

A typical scenario for working with MOSEK through an explicit environment is shown below:

/* Create an environment */
using (mosek.Env env = new mosek.Env()) {  

    /* Create one or more optimization tasks with this env */
    using (mosek.Task task = new mosek.Task(env)) {  
        // ...
        // ... optimization ...
        // ...
    }

}

If an environment is created outside of a context that ensures automatic garbage collection then it can be disposed of manually using Env.Dispose.