13. API reference


This chapter lists all functionality in the MOSEK Python API.

13.1. API Functionality

Functions in the interface grouped by functionality.

13.1.1. Reading and writing data files.

Reading and writing data files.

mosek.Task.readbranchpriorities
Reads branching priority data from a file.

mosek.Task.readdata
Reads problem data from a file.

mosek.Task.readparamfile
Reads a parameter file.

mosek.Task.readsolution
Reads a solution from a file.

mosek.Task.readsummary
Prints information about last file read.

mosek.Task.writebranchpriorities
Writes branching priority data to a file.

mosek.Task.writeparamfile
Writes all the parameters to a parameter file.

mosek.Task.writesolution
Write a solution to a file.

13.1.2. Solutions.

Obtain or define a solution.

mosek.Task.deletesolution
Undefines a solution and frees the memory it uses.

mosek.Task.getdualobj
Obtains the dual objective value.

mosek.Task.getprimalobj
Obtains the primal objective value.

mosek.Task.getreducedcosts
Obtains the difference of slx-sux for a sequence of variables.

mosek.Task.getsolution
Obtains the complete solution.

mosek.Task.getsolutioni
Obtains the solution for a single constraint or variable.

mosek.Task.getsolutioninf
Obtains information about a solution.

mosek.Task.getsolutionslice
Obtains a slice of the solution.

mosek.Task.getsolutionstatus
Obtains information about the problem and solution statuses.

mosek.Task.getsolutionstatuskeyslice
Obtains a slice of the solution status keys.

mosek.Task.makesolutionstatusunknown
Sets the solution status to unknown.

mosek.Task.putsolution
Inserts a solution.

mosek.Task.putsolutioni
Sets the primal and dual solution information for a single constraint or variable.

mosek.Task.readsolution
Reads a solution from a file.

mosek.Task.solutiondef
Checks whether a solution is defined.

mosek.Task.solutionsummary
Prints a short summary of a solution.

mosek.Task.undefsolution
Undefines a solution.

mosek.Task.writedata
Writes problem data to a file.

13.1.3. Memory allocation and deallocation.

Memory allocation and deallocation.

mosek.Task.checkmemtask
Checks the memory allocated by the task.

mosek.Task.getmemusagetask
Obtains information about the amount of memory used by a task.

13.1.4. Changing problem specification.

Input or change problem specification

mosek.Task.append
Appends a number of variables or constraints to the optimization task.

mosek.Task.appendcone
Appends a new cone constraint to the problem.

mosek.Task.appendcons
Appends one or more constraints and specifies bounds and A coefficients.

mosek.Task.appendvars
Appends one or more variables and specifies bounds on variables, c coefficients and A coefficients.

mosek.Task.chgbound
Changes the bounds for one constraint or variable.

mosek.Task.clonetask
Creates a clone of an existing task.

mosek.Task.commitchanges
Commits all cached problem changes.

mosek.Task.inputdata
Input the linear part of an optimization task in one function call.

mosek.Task.putaij
Changes a single value in the linear coefficient matrix.

mosek.Task.putaijlist
Changes one or more coefficients in A.

mosek.Task.putavec
Replaces all elements in one row or column of A.

mosek.Task.putaveclist
Replaces all elements in one or more rows or columns in A by new values.

mosek.Task.putbound
Changes the bound for either one constraint or one variable.

mosek.Task.putboundlist
Changes the bounds of constraints or variables.

mosek.Task.putboundslice
Modifies bounds.

mosek.Task.putcfix
Replaces the fixed term in the objective.

mosek.Task.putcj
Modifies one linear coefficient in the objective.

mosek.Task.putclist
Modifies a part of c.

mosek.Task.putcone
Replaces a conic constraint.

mosek.Task.putobjsense
Sets the objective sense.

mosek.Task.putqcon
Replaces all quadratic terms in constraints.

mosek.Task.putqconk
Replaces all quadratic terms in a single constraint.

mosek.Task.putqobj
Replaces all quadratic terms in the objective.

mosek.Task.putqobjij
Replaces one of the coefficients in the quadratic term in the objective.

mosek.Task.putvartype
Sets the variable type of one variable.

mosek.Task.putvartypelist
Sets the variable type for one or more variables.

13.1.5. Delete problem elements (variables,constraints,cones).

Functionality for deleting problem elements such as variables, constraints or cones.

mosek.Task.remove
The function removes a number of constraints or variables.

mosek.Task.removecone
Removes a conic constraint from the problem.

13.1.6. Add problem elements (variables,constraints,cones).

Functionality for adding problem elements such as variables, constraints or cones.

mosek.Task.append
Appends a number of variables or constraints to the optimization task.

mosek.Task.appendcone
Appends a new cone constraint to the problem.

13.1.7. Inspect problem specification.

Functionality for inspecting the problem specification (A,Q, bounds, objective e.t.c).

mosek.Task.getaij
Obtains a single coefficient in A.

mosek.Task.getaslice
Obtains a sequence of rows or columns from A.

mosek.Task.getaslicetrip
Obtains a sequence of rows or columns from A in triplet format.

mosek.Task.getavec
Obtains one row or column of A.

mosek.Task.getavecnumnz
Obtains the number of non-zero elements in one row or column of A.

mosek.Task.getbound
Obtains bound information for one constraint or variable.

mosek.Task.getboundslice
Obtains bounds information for a sequence of variables or constraints.

mosek.Task.getc
Obtains all objective coefficients c.

mosek.Task.getcfix
Obtains the fixed term in the objective.

mosek.Task.getcone
Obtains a conic constraint.

mosek.Task.getconeinfo
Obtains information about a conic constraint.

mosek.Task.getcslice
Obtains a part of c.

mosek.Task.getnumanz
Obtains the number of non-zeros in A.

mosek.Task.getnumcon
Obtains the number of constraints.

mosek.Task.getnumcone
Obtains the number of cones.

mosek.Task.getnumconemem
Obtains the number of members in a cone.

mosek.Task.getnumintvar
Obtains the number of integer constrained variables.

mosek.Task.getnumqconnz
Obtains the number of non-zero quadratic terms in a constraint.

mosek.Task.getnumqobjnz
Obtains the number of non-zero quadratic terms in the objective.

mosek.Task.getnumvar
Obtains the number of variables.

mosek.Task.getobjsense
Gets the objective sense.

mosek.Task.getprobtype
Obtains the problem type.

mosek.Task.getqconk
Obtains all the quadratic terms in a constraint.

mosek.Task.getqobj
Obtains all the quadratic terms in the objective.

mosek.Task.getqobjij
Obtains one coefficient from the quadratic term of the objective

mosek.Task.getvartype
Gets the variable type of one variable.

mosek.Task.getvartypelist
Obtains the variable type for one or more variables.

13.1.8. Conic constraints.

Functionality related to conic terms in the problem.

mosek.Task.appendcone
Appends a new cone constraint to the problem.

mosek.Task.getcone
Obtains a conic constraint.

mosek.Task.getconeinfo
Obtains information about a conic constraint.

mosek.Task.getnumcone
Obtains the number of cones.

mosek.Task.putcone
Replaces a conic constraint.

mosek.Task.removecone
Removes a conic constraint from the problem.

13.1.9. Bounds.

Functionality related to changing or inspecting bounds on variables or constraints.

mosek.Task.chgbound
Changes the bounds for one constraint or variable.

mosek.Task.getbound
Obtains bound information for one constraint or variable.

mosek.Task.getboundslice
Obtains bounds information for a sequence of variables or constraints.

mosek.Task.putbound
Changes the bound for either one constraint or one variable.

mosek.Task.putboundlist
Changes the bounds of constraints or variables.

mosek.Task.putboundslice
Modifies bounds.

13.1.10. Output stream functions.

Output stream functions.

mosek.Env.echointro
Prints an intro to message stream.

mosek.Env.linkfiletoenvstream
Directs all output from a stream to a file.

mosek.Task.linkfiletotaskstream
Directs all output from a task stream to a file.

mosek.Task.printdata
Prints a part of the problem data to a stream.

mosek.Task.printparam
Prints the current parameter settings.

mosek.Task.readsummary
Prints information about last file read.

mosek.Task.solutionsummary
Prints a short summary of a solution.

13.1.11. Objective function.

Change or inspect objective function.

mosek.Task.getc
Obtains all objective coefficients c.

mosek.Task.getcfix
Obtains the fixed term in the objective.

mosek.Task.getcslice
Obtains a part of c.

mosek.Task.getdualobj
Obtains the dual objective value.

mosek.Task.getnumqobjnz
Obtains the number of non-zero quadratic terms in the objective.

mosek.Task.getobjname
Obtains the name assigned to the objective function.

mosek.Task.getobjsense
Gets the objective sense.

mosek.Task.getprimalobj
Obtains the primal objective value.

mosek.Task.getqobj
Obtains all the quadratic terms in the objective.

mosek.Task.getqobjij
Obtains one coefficient from the quadratic term of the objective

mosek.Task.putcfix
Replaces the fixed term in the objective.

mosek.Task.putcj
Modifies one linear coefficient in the objective.

mosek.Task.putclist
Modifies a part of c.

mosek.Task.putobjsense
Sets the objective sense.

mosek.Task.putqobj
Replaces all quadratic terms in the objective.

mosek.Task.putqobjij
Replaces one of the coefficients in the quadratic term in the objective.

13.1.12. Inspect statistics from the optimizer.

Inspect statistics from the optimizer.

mosek.Task.appendstat
Appends a record the statistics file.

mosek.Task.getdouinf
Obtains a double information item.

mosek.Task.getintinf
Obtains an integer information item.

mosek.Task.startstat
Starts the statistics file.

mosek.Task.stopstat
Stops the statistics file.

13.1.13. Parameters (set/get).

Setting and inspecting solver parameters.

mosek.Task.getdouparam
Obtains a double parameter.

mosek.Task.getintparam
Obtains an integer parameter.

mosek.Task.getnumparam
Obtains the number of parameters of a given type.

mosek.Task.getstrparam
Obtains the value of a string parameter.

mosek.Env.getsymbcondim
Obtains dimensional information for the defined symbolic constants.

mosek.Task.isdouparname
Checks a double parameter name.

mosek.Task.isintparname
Checks an integer parameter name.

mosek.Task.isstrparname
Checks a string parameter name.

mosek.Task.putdouparam
Sets a double parameter.

mosek.Task.putintparam
Sets an integer parameter.

mosek.Task.putnadouparam
Sets a double parameter.

mosek.Task.putnaintparam
Sets an integer parameter.

mosek.Task.putnastrparam
Sets a string parameter.

mosek.Task.putparam
Modifies the value of parameter.

mosek.Task.putstrparam
Sets a string parameter.

mosek.Task.setdefaults
Resets all parameters values.

13.1.14. Naming.

Functionality related to naming.

mosek.Task.getconname
Obtains a name of a constraint.

mosek.Task.getmaxnamelen
Obtains the maximum length of any objective, constraint, variable or cone name.

mosek.Task.getname
Obtains the name of a cone, a variable or a constraint.

mosek.Task.getnameindex
Checks whether a name has been assigned and returns the index corresponding to the name.

mosek.Task.getobjname
Obtains the name assigned to the objective function.

mosek.Task.gettaskname
Obtains the task name.

mosek.Task.getvarname
Obtains a name of a variable.

mosek.Task.putname
Assigns the name name to a problem item such as a constraint.

mosek.Task.putobjname
Assigns a new name to the objective.

mosek.Task.puttaskname
Assigns a new name to the task.

13.1.15. Preallocating space for problem data.

Functionality related to preallocating space for problem data.

mosek.Task.getmaxnumanz
Obtains number of preallocated non-zeros for A.

mosek.Task.getmaxnumcon
Obtains the number of preallocated constraints in the optimization task.

mosek.Task.getmaxnumcone
Obtains the number of preallocated cones in the optimization task.

mosek.Task.getmaxnumqnz
Obtains the number of preallocated non-zeros for Q (both objective and constraints).

mosek.Task.getmaxnumvar
Obtains the maximum number variables allowed.

mosek.Task.putmaxnumanz
The function changes the size of the preallocated storage for linear coefficients.

mosek.Task.putmaxnumcon
Sets the number of preallocated constraints in the optimization task.

mosek.Task.putmaxnumcone
Sets the number of preallocated conic constraints in the optimization task.

mosek.Task.putmaxnumqnz
Changes the size of the preallocated storage for Q.

mosek.Task.putmaxnumvar
Sets the number of preallocated variables in the optimization task.

13.1.16. Integer variables.

Functionality related to integer variables.

mosek.Task.getnumintvar
Obtains the number of integer constrained variables.

mosek.Task.getvarbranchdir
Obtains the branching direction for a variable.

mosek.Task.getvarbranchpri
Obtains the branching priority for a variable.

mosek.Task.getvartype
Gets the variable type of one variable.

mosek.Task.getvartypelist
Obtains the variable type for one or more variables.

mosek.Task.putvarbranchorder
Assigns a branching priority and direction to a variable.

mosek.Task.putvartype
Sets the variable type of one variable.

mosek.Task.putvartypelist
Sets the variable type for one or more variables.

13.1.17. Quadratic terms.

Functionality related to quadratic terms.

mosek.Task.getqconk
Obtains all the quadratic terms in a constraint.

mosek.Task.getqobj
Obtains all the quadratic terms in the objective.

mosek.Task.getqobjij
Obtains one coefficient from the quadratic term of the objective

mosek.Task.putqcon
Replaces all quadratic terms in constraints.

mosek.Task.putqconk
Replaces all quadratic terms in a single constraint.

mosek.Task.putqobj
Replaces all quadratic terms in the objective.

mosek.Task.putqobjij
Replaces one of the coefficients in the quadratic term in the objective.

13.1.18. Diagnosing infeasibility.

Functions for diagnosing infeasibility.

mosek.Task.getinfeasiblesubproblem
Obtains an infeasible sub problem.

mosek.Task.relaxprimal
Creates a problem that finds the minimal change to the bounds that makes an infeasible problem feasible.

13.1.19. Optimization.

Functions for optimization.

mosek.Task.checkdata
Checks data of the task.

mosek.Task.optimize
Optimizes the problem.

mosek.Task.optimizeconcurrent
Optimize a given task with several optimizers concurrently.

mosek.Task.optimizetrm
Optimizes the problem.

13.1.20. Sensitivity analysis.

Functions for sensitivity analysis.

mosek.Task.dualsensitivity
Performs sensitivity analysis on objective coefficients.

mosek.Task.primalsensitivity
Perform sensitivity analysis on bounds.

mosek.Task.sensitivityreport
Creates a sensitivity report.

13.1.21. Testing data validity.

Functions for testing data validity.

mosek.Task.checkconvexity
Checks if a quadratic optimization problem is convex.

13.1.22. Solving with the basis.

Functions for solving linear systems with the basis matrix.

mosek.Task.initbasissolve
Prepare a task for use with the Task.solvewithbasis function.

mosek.Task.solvewithbasis
Solve a linear equation system involving a basis matrix.

13.1.23. Initialization of environment.

Creation and initialization of environment.

mosek.Env.initenv
Initialize a MOSEK environment.

mosek.Env.putlicensedefaults
Set defaults used by the license manager.

13.1.24. Change A.

Change elements in the coefficient (A) matrix.

mosek.Task.appendcons
Appends one or more constraints and specifies bounds and A coefficients.

mosek.Task.appendvars
Appends one or more variables and specifies bounds on variables, c coefficients and A coefficients.

mosek.Task.commitchanges
Commits all cached problem changes.

mosek.Task.putaij
Changes a single value in the linear coefficient matrix.

mosek.Task.putaijlist
Changes one or more coefficients in A.

mosek.Task.putavec
Replaces all elements in one row or column of A.

mosek.Task.putaveclist
Replaces all elements in one or more rows or columns in A by new values.

13.2. Class mosek.ArrayLengthException

Derived from:

__builtin__.Exception

Description:

This exception is raised is an input or output array was shorter than required.

13.3. Class mosek.Env

Description:

A Mosek Environment

13.3.1. Constructors

  • mosek.Env

    Syntax: 

    Env ()
    
    Description:Create a MOSEK environment object.
  • mosek.Env

    Syntax: 

    Env (str dbgfile)
    
    Description:Create a MOSEK environment object.

    Arguments: 

    dbgfile
    A file which will be used to log memory debugging information from MOSEK

13.3.2. Attributes

  • mosek.CtrlC CtrlC (write only) Control-c call-back object.
  • mosek.Exit Exit (write only) Exit handler call-back object.

13.3.3. Methods

  • mosek.Env.echointro

    Syntax:

     

    echointro (int longver)
    
    Arguments:

     

    longver (input)
    If non-zero, then the intro is slightly longer.
    Description:
    Prints an intro to message stream.
  • mosek.Env.getsymbcondim

    Syntax:

     

    getsymbcondim (
        List|None num,
        List|None maxlen)
    
    Arguments:

     

    num (output)
    Number of symbolic constants defined by MOSEK.
    maxlen (output)
    Maximum length of the name of any symbolic constants.
    Description:
    Obtains the number of symbolic constants defined by MOSEK and the maximum length of the name of any symbolic constant.
  • mosek.Env.getversion

    Syntax:

     

    getversion (
        List|None major,
        List|None minor,
        List|None build,
        List|None revision)
    
    Arguments:

     

    major (output)
    Major version number. Modified only if a non-null pointer.
    minor (output)
    Minor version number. Modified only if a non-null pointer.
    build (output)
    Build number. Modified only if a non-null pointer.
    revision (output)
    Revision number. Modified only if a non-null pointer.
    Description:
    Obtains MOSEK version information.
  • mosek.Env.initenv

    Syntax:

     

    initenv ()
    
    Description:
    This function initializes the MOSEK environment. Among other things the license server will be contacted. Error messages from the license manager can be captured by linking to the environment message stream before calling this function.
  • mosek.Env.isinfinity

    Syntax:

     

    isinfinity (double value)
    
    Arguments:

     

    value
    Description:
    Return true if value considered infinity by MOSEK
  • mosek.Env.linkfiletoenvstream

    Syntax:

     

    linkfiletoenvstream (
        mosek.streamtype whichstream,
        str filename,
        int append)
    
    Arguments:

     

    whichstream (input)
    Index of the stream.
    filename (input)
    Sends all output from the stream defined by whichstream to the file given by filename.
    append (input)
    If this argument is non-zero, the output is appended to the file.
    Description:
    Directs all output from a stream to a file.
  • mosek.Env.putcpudefaults

    Syntax:

     

    putcpudefaults (
        mosek.cputype cputype,
        int sizel1,
        int sizel2)
    
    Arguments:

     

    cputype (input)
    The CPU ID.
    sizel1 (input)
    Size of the L1 cache.
    sizel2 (input)
    Size of the L2 cache.
    Description:
    Sets default CPU type and cache sizes. This function should be called before Env.initenv.
  • mosek.Env.putdllpath

    Syntax:

     

    putdllpath (str dllpath)
    
    Arguments:

     

    dllpath (input)
    A path to where the MOSEK dynamic link/shared libraries are located. If dllpath is NULL, then MOSEK assumes that the operating system can locate the libraries.
    Description:
    Sets the path to the DLL/shared libraries that MOSEK are loading. If needed, then it should normally be called before Env.initenv.
  • mosek.Env.putkeepdlls

    Syntax:

     

    putkeepdlls (int keepdlls)
    
    Arguments:

     

    keepdlls (input)
    Controls whether explicitly loaded DLLs should be kept.
    Description:
    Controls whether explicitly loaded DLLs should be kept when they no longer are in use.
  • mosek.Env.putlicensedefaults

    Syntax:

     

    putlicensedefaults (
        str licensefile,
        array(int) licensebuf,
        int licwait,
        int licdebug)
    
    Arguments:

     

    licensefile (input)
    Either NULL or the path to a valid MOSEK license file.
    licensebuf (input)
    This is the license string authorizing the use of MOSEK in the runtime version of MOSEK. Therefore, most frequently this string is a NULL pointer.
    licwait (input)
    If this argument is non-zero, then MOSEK will wait for a license if no license is available. Moreover, licwait-1 is used as the default value for mosek.iparam.license_pause_time.
    licdebug (input)
    If this argument is non-zero, then MOSEK will print debug info regarding the license checkout.
    Description:
    Sets default values for the license manager. This function should be called before Env.initenv.
  • mosek.Env.set_Stream

    Syntax:

     

    set_Stream (mosek.streamtype whichstream)
    
    Arguments:

     

    whichstream
    Index of the stream.
    Description:
    Attach a stream call-back handler.

13.4. Class mosek.Error

Derived from:

mosek.Exception

Description:

This is an exception class representing MOSEK errors.

13.4.1. Constructors

  • mosek.Error

    Syntax: 

    Error (mosek.rescode code)
    
    Description:Construct an error from a MOSEK error code.

    Arguments: 

    code
    The MOSEK response code to create the exception from.
  • mosek.Error

    Syntax: 

    Error (
        mosek.rescode code,
        str msg)
    
    Description:Construct an error from a MOSEK error code and a message.

    Arguments: 

    code
    The MOSEK response code to create the exception from.
    msg
    A message describing the error situation.

13.5. Class mosek.Exception

Derived from:

__builtin__.Exception

Description:

This is the base class for exceptions based on MOSEK response codes.

13.5.1. Constructors

  • mosek.Exception

    Syntax: 

    Exception (mosek.rescode code)
    
    Description:Construct an exception from a MOSEK error code.

    Arguments: 

    code
    The MOSEK response code to create the exception from.

13.6. Class mosek.Task

Description:

A Mosek Optimization task

13.6.1. Constructors

  • mosek.Task

    Syntax: 

    Task (
        int maxnumcon,
        int maxnumvar)
    
    Description:Create a new MOSEK task and reserve space for constraints and variables. Please note that it is perfectly legal to specify 0 constraint or 0 variables: The values may be specified later with Task.putmaxnumcon and Task.putmaxnumvar. Even without doing so, the task will automatically resize when exceeding the maximum, but if this happens often, there will be some overhead when resizing.

    Arguments: 

    maxnumcon
    Initially reserve space for this many constraints.
    maxnumvar
    Initially reserve space for this many variables.

13.6.2. Attributes

  • mosek.ErrorHandler ErrorHandler (write only) Error handler call-back object
  • mosek.Nonlinear Nonlinear (write only) Nonlinear sparsity and value computation call-back object.
  • mosek.Progress Progress (write only) Progress call-back object

13.6.3. Methods

  • mosek.Task.append

    Syntax:

     

    append (
        mosek.accmode accmode,
        int num)
    
    Arguments:

     

    accmode (input)
    Defines if operations are performed row-wise (constraint-oriented) or column-wise (variable-oriented).
    num (input)
    Number of constraints or variables which should be appended.
    Description:
    Appends a number of constraints or variables to the model. Appended constraints will be declared free and appended variables will be fixed at the level zero. Please note that MOSEK will automatically expand the problem dimension to accommodate the additional constraints and variables.
    See also:

     

    Task.remove

    The function removes a number of constraints or variables.

  • mosek.Task.appendcone

    Syntax:

     

    appendcone (
        mosek.conetype conetype,
        double conepar,
        array(int) submem)
    
    Arguments:

     

    conetype (input)
    Specifies the type of the cone.
    conepar (input)
    This argument is currently not used. Can be set to 0.0.
    submem (input)
    Variable subscripts of the members in the cone.
    Description:

    Appends a new conic constraint to the problem. Hence, add a constraint

    \begin{displaymath}\nonumber{}x^{t}\in{}\mathcal{C}\end{displaymath}

    to the problem where [[MathCmd 51]] is a convex cone. [[MathCmd 517]] is a subset of the variables which will be specified by the argument submem. Please note that the sets of variables appearing in different conic constraints must be disjoint.

    For an explained code example see section 5.4.

  • mosek.Task.appendcons

    Syntax:

     

    appendcons (
        array(int) aptrb,
        array(int) aptre,
        array(int) asub,
        array(double) aval,
        array(int) bkc,
        array(double) blc,
        array(double) buc)
    
    Arguments:

     

    aptrb (input)
    See (13.6.2).
    aptre (input)
    See (13.6.2).
    asub (input)
    Variable subscripts of the new A coefficients. See (13.6.2).
    aval (input)
    A coefficients of the new constraints. See (13.6.2).
    bkc (input)
    Bound keys for constraints to be appended. See (13.6.1).
    blc (input)
    Lower bounds on constraints to be appended. See (13.6.1).
    buc (input)
    Upper bounds on constraints to be appended. See (13.6.1).
    Description:

    The function appends one or more constraints to the optimization task. The bounds and A are modified as follows

    \begin{math}\nonumber{}\begin{array}{lcll}\nonumber{}l_{{\mathtt{numcon+k}}}^{c} & = & \mathtt{blc[k]}, & \mathtt{k}=0,\ldots ,\mathtt{num}-1,\\\nonumber{}u_{{\mathtt{numcon+k}}}^{c} & = & \mathtt{buc[k]}, & \mathtt{k}=0,\ldots ,\mathtt{num}-1,\end{array}\end{math} (13.6.1)

    and

    \begin{math}\nonumber{}\begin{array}{lclll}\nonumber{}a_{{\mathtt{numcon+k,\mathtt{asub[l]}}}} & = & \mathtt{aval[l]}, & k=0,\ldots ,\mathtt{num}-1, & l=\mathtt{aptrb[k]},\ldots ,\mathtt{aptre[k]-1}.\end{array}\end{math} (13.6.2)
    See also:

     

    Task.putmaxnumcon

    Sets the number of preallocated constraints in the optimization task.

  • mosek.Task.appendstat

    Syntax:

     

    appendstat ()
    
    Description:
    Appends a record to the statistics file.
  • mosek.Task.appendvars

    Syntax:

     

    appendvars (
        array(double) cval,
        array(int) aptrb,
        array(int) aptre,
        array(int) asub,
        array(double) aval,
        array(int) bkx,
        array(double) blx,
        array(double) bux)
    
    Arguments:

     

    cval (input)
    Values of c for the variables to be appended. See (13.6.3).
    aptrb (input)
    See (13.6.4).
    aptre (input)
    See (13.6.4).
    asub (input)
    Constraint subscripts of the A coefficients to be added. See (13.6.4).
    aval (input)
    The A coefficients corresponding to the appended variables. See (13.6.4).
    bkx (input)
    Bound keys on variables to be appended. See (13.6.3).
    blx (input)
    Lower bounds on variables to be appended. See (13.6.3).
    bux (input)
    Upper bounds on variables to be appended. See (13.6.3).
    Description:

    The function appends one or more variables to the optimization problem. Moreover, the function initializes c, A and the bounds corresponding to the appended variables as follows

    \begin{math}\nonumber{}\begin{array}{lcll}\nonumber{}c_{{\mathtt{numvar+k}}} & = & \mathtt{cval[k]}, & \mathtt{k}=0,\ldots ,\mathtt{num}-1,\\\nonumber{}l_{{\mathtt{numvar+k}}}^{x} & = & \mathtt{blx[k]}, & \mathtt{k}=0,\ldots ,\mathtt{num}-1,\\\nonumber{}u_{{\mathtt{numvar+k}}}^{x} & = & \mathtt{bux[k]}, & \mathtt{k}=0,\ldots ,\mathtt{num}-1,\end{array}\end{math} (13.6.3)

    and

    \begin{math}\nonumber{}\begin{array}{lclll}\nonumber{}a_{{\mathtt{asub[l]},\mathtt{numvar+k}}} & = & \mathtt{aval[l]}, & k=0,\ldots ,\mathtt{num}-1, & l=\mathtt{aptrb[k]},\ldots ,\mathtt{aptre[k]-1}\end{array}\end{math} (13.6.4)

    where numvar is the number variables before the new variables are appended.

    See also:

     

    Task.putmaxnumvar

    Sets the number of preallocated variables in the optimization task.

  • mosek.Task.checkconvexity

    Syntax:

     

    checkconvexity ()
    
    Description:
    This function checks if a quadratic optimization problem is convex. The amount of checking is controlled by mosek.iparam.check_convexity. The function returns mosek.rescode.err_nonconvex if the problem is not convex.
    See also:

     

    mosek.iparam.check_convexity
  • mosek.Task.checkdata

    Syntax:

     

    checkdata ()
    
    Description:
    Checks the data of the optimization task.
  • mosek.Task.checkmemtask

    Syntax:

     

    checkmemtask (
        str file,
        int line)
    
    Arguments:

     

    file (input)
    File from which the function is called.
    line (input)
    Line in the file from which the function is called.
    Description:
    Checks the memory allocated by the task.
  • mosek.Task.chgbound

    Syntax:

     

    chgbound (
        mosek.accmode accmode,
        int i,
        int lower,
        int finite,
        double value)
    
    Arguments:

     

    accmode (input)
    Defines if operations are performed row-wise (constraint-oriented) or column-wise (variable-oriented).
    i (input)
    Index of the constraint or variable for which the bounds should be changed.
    lower (input)
    If non-zero, then the lower bound is changed, otherwise the upper bound is changed.
    finite (input)
    If non-zero, then value is assumed to be finite.
    value (input)
    New value for the bound.
    Description:

    Changes a bound for one constraint or variable. If accmode equals mosek.accmode.con, a constraint bound is changed, otherwise a variable bound is changed.

    If lower is non-zero, then the lower bound is changed as follows:

    \begin{displaymath}\nonumber{}\mbox{new lower bound}=\left\lbrace{}\begin{array}{ll}\nonumber{}-\infty , & \mathtt{finite}=0,\\\nonumber{}\mathtt{value} & \mbox{otherwise}.\end{array}\right.\end{displaymath}

    Otherwise if lower is zero, then

    \begin{displaymath}\nonumber{}\mbox{new upper bound}=\left\lbrace{}\begin{array}{ll}\nonumber{}\infty , & \mathtt{finite}=0,\\\nonumber{}\mathtt{value} & \mbox{otherwise}.\end{array}\right.\end{displaymath}

    Please note that this function automatically updates the bound key for bound, in particular, if the lower and upper bounds are identical, the bound key is changed to fixed.

    See also:

     

    Task.putbound

    Changes the bound for either one constraint or one variable.

    mosek.dparam.data_tol_bound_inf
    mosek.dparam.data_tol_bound_wrn
  • mosek.Task.clonetask

    Syntax:

     

    Task clonetask ()
    
    Returns:
     
    Description:
    Creates a clone of an existing task copying all problem data and parameter settings to a new task. Call-back functions are not copied, so a task containing nonlinear functions cannot be cloned.
  • mosek.Task.commitchanges

    Syntax:

     

    commitchanges ()
    
    Description:
    Commits all cached problem changes to the task. It is usually not necessary explicitly to call this function since changes will be committed automatically when required.
  • mosek.Task.deletesolution

    Syntax:

     

    deletesolution (mosek.soltype whichsol)
    
    Arguments:

     

    whichsol (input)
    Selects a solution.
    Description:
    Undefines a solution and frees the memory it uses.
  • mosek.Task.dualsensitivity

    Syntax:

     

    dualsensitivity (
        array(int) subj,
        array(double) leftpricej,
        array(double) rightpricej,
        array(double) leftrangej,
        array(double) rightrangej)
    
    Arguments:

     

    subj (input)
    Index of objective coefficients to analyze.
    leftpricej (output)
    [[MathCmd 524]] is the left shadow price for the coefficients with index [[MathCmd 525]].
    rightpricej (output)
    [[MathCmd 526]] is the right shadow price for the coefficients with index [[MathCmd 525]].
    leftrangej (output)
    [[MathCmd 528]] is the left range [[MathCmd 457]] for the coefficient with index [[MathCmd 525]].
    rightrangej (output)
    [[MathCmd 531]] is the right range [[MathCmd 458]] for the coefficient with index [[MathCmd 525]].
    Description:

    Calculates sensitivity information for objective coefficients. The indexes of the coefficients to analyze are

    \begin{displaymath}\nonumber{}\lbrace{}\mathtt{subj}[i]|i\in{}0,\ldots ,\mathtt{numj}-1\rbrace{}\end{displaymath}

    The results are returned so that e.g [[MathCmd 535]] is the left shadow price of the objective coefficient with index [[MathCmd 536]].

    The type of sensitivity analysis to perform (basis or optimal partition) is controlled by the parameter mosek.iparam.sensitivity_type.

    For an example, please see section 11.5.

    See also:

     

    Task.primalsensitivity

    Perform sensitivity analysis on bounds.

    Task.sensitivityreport

    Creates a sensitivity report.

    mosek.iparam.sensitivity_type
    mosek.iparam.log_sensitivity
    mosek.iparam.log_sensitivity_opt
  • mosek.Task.getaij

    Syntax:

     

    double getaij (
        int i,
        int j)
    
    Arguments:

     

    i (input)
    Row index of the coefficient to be returned.
    j (input)
    Column index of the coefficient to be returned.
    Returns:
     
    Description:
    Obtains a single coefficient in A.
  • mosek.Task.getapiecenumnz

    Syntax:

     

    int getapiecenumnz (
        int firsti,
        int lasti,
        int firstj,
        int lastj)
    
    Arguments:

     

    firsti (input)
    Index of the first row in the rectangular piece.
    lasti (input)
    Index of the last row plus one in the rectangular piece.
    firstj (input)
    Index of the first column in the rectangular piece.
    lastj (input)
    Index of the last column plus one in the rectangular piece.
    Returns:
     
    Description:

    Obtains the number non-zeros in a rectangular piece of A, i.e. the number

    \begin{displaymath}\nonumber{}\left|\lbrace{}(i,j):~a_{{i,j}}\not=0,~\mathtt{firsti}\leq{}i\leq{}\mathtt{lasti}-1,~\mathtt{firstj}\leq{}j\leq{}\mathtt{lastj}-1\rbrace{}\right|\end{displaymath}

    where [[MathCmd 538]] means the number of elements in the set [[MathCmd 539]].

    This function is not an efficient way to obtain the number of non-zeros in one row or column. In that case use the function Task.getavecnumnz.

    See also:

     

    Task.getavecnumnz

    Obtains the number of non-zero elements in one row or column of A.

    Task.getaslicenumnz

    Obtains the number of non-zeros in a row or column slice of A.

  • mosek.Task.getaslice

    Syntax:

     

    getaslice (
        mosek.accmode accmode,
        int first,
        int last,
        List|None surp,
        array(int) ptrb,
        array(int) ptre,
        array(int) sub,
        array(double) val)
    
    Arguments:

     

    accmode (input)
    Defines whether a column-slice or a row-slice is requested.
    first (input)
    Index of the first row or variable in the sequence.
    last (input)
    Index of the last row or variable plus one in the sequence plus one.
    surp (input/output)
    The required rows and columns are stored sequentially in sub and val starting from position maxnumnz-surp[0]. Upon return surp has been decremented by the total number of non-zero elements in the rows and columns obtained.
    ptrb (output)
    ptrb[t] is an index pointing to the first element in the tth row or column obtained.
    ptre (output)
    ptre[t] is an index pointing to the last element plus one in the tth row or column obtained.
    sub (output)
    Contains the row or column subscripts.
    val (output)
    Contains the numerical elements.
    Description:
    Obtains a sequence of rows or columns from A in sparse format.
    See also:

     

    Task.getaslicenumnz

    Obtains the number of non-zeros in a row or column slice of A.

  • mosek.Task.getaslicenumnz

    Syntax:

     

    int getaslicenumnz (
        mosek.accmode accmode,
        int first,
        int last)
    
    Arguments:

     

    accmode (input)
    Defines whether non-zeros are counted in a column-slice or a row-slice.
    first (input)
    Index of the first row or variable in the sequence.
    last (input)
    Index of the last row or variable plus one in the sequence plus one.
    Returns:
     
    Description:
    Obtains the number of non-zeros in a row or column slice of A.
  • mosek.Task.getaslicetrip

    Syntax:

     

    getaslicetrip (
        mosek.accmode accmode,
        int first,
        int last,
        List|None surp,
        array(int) subi,
        array(int) subj,
        array(double) val)
    
    Arguments:

     

    accmode (input)
    Defines whether a column-slice or a row-slice is requested.
    first (input)
    Index of the first row or variable in the sequence.
    last (input)
    Index of the last row or variable in the sequence plus one.
    surp (input/output)
    The required rows and columns are stored sequentially in subi and val starting from position maxnumnz-surp[0]. On return surp has been decremented by the total number of non-zero elements in the rows and columns obtained.
    subi (output)
    Constraint subscripts.
    subj (output)
    Variable subscripts.
    val (output)
    Values.
    Description:
    Obtains a sequence of rows or columns from A in a sparse triplet format.
    See also:

     

    Task.getaslicenumnz

    Obtains the number of non-zeros in a row or column slice of A.

  • mosek.Task.getavec

    Syntax:

     

    getavec (
        mosek.accmode accmode,
        int i,
        List|None nzi,
        array(int) subi,
        array(double) vali)
    
    Arguments:

     

    accmode (input)
    Defines if operations are performed row-wise (constraint-oriented) or column-wise (variable-oriented).
    i (input)
    Index of the row or column.
    nzi (output)
    Number of non-zeros in the vector obtained.
    subi (output)
    Index of the non-zeros in the vector obtained.
    vali (output)
    Numerical values of the vector to be obtained.
    Description:

    Obtains one row or column of A in a sparse format. If accmode equals mosek.accmode.con a row is returned and hence:

    \begin{displaymath}\nonumber{}\mathtt{vali}[k]=a_{{i,\mathtt{subi}[k]}},\quad{}k=0,\ldots ,\mathtt{nzi[0]}-1\end{displaymath}

    If accmode equals mosek.accmode.var a column is returned, that is:

    \begin{displaymath}\nonumber{}\mathtt{vali}[k]=a_{{\mathtt{subi}[k],i}},\quad{}k=0,\ldots ,\mathtt{nzi[0]}-1.\end{displaymath}
  • mosek.Task.getavecnumnz

    Syntax:

     

    int getavecnumnz (
        mosek.accmode accmode,
        int i)
    
    Arguments:

     

    accmode (input)
    Defines whether non-zeros are counted by columns or by rows.
    i (input)
    Index of the row or column.
    Returns:
     
    Description:
    Obtains the number of non-zero elements in one row or column of A.
  • mosek.Task.getbound

    Syntax:

     

    getbound (
        mosek.accmode accmode,
        int i,
        List|None bk,
        List|None bl,
        List|None bu)
    
    Arguments:

     

    accmode (input)
    Defines if operations are performed row-wise (constraint-oriented) or column-wise (variable-oriented).
    i (input)
    Index of the constraint or variable for which the bound information should be obtained.
    bk (output)
    Bound keys.
    bl (output)
    Values for lower bounds.
    bu (output)
    Values for upper bounds.
    Description:
    Obtains bound information for one constraint or variable.
  • mosek.Task.getboundslice

    Syntax:

     

    getboundslice (
        mosek.accmode accmode,
        int first,
        int last,
        array(int) bk,
        array(double) bl,
        array(double) bu)
    
    Arguments:

     

    accmode (input)
    Defines if operations are performed row-wise (constraint-oriented) or column-wise (variable-oriented).
    first (input)
    First index in the sequence.
    last (input)
    Last index plus 1 in the sequence.
    bk (output)
    Bound keys.
    bl (output)
    Values for lower bounds.
    bu (output)
    Values for upper bounds.
    Description:
    Obtains bounds information for a sequence of variables or constraints.
  • mosek.Task.getc

    Syntax:

     

    getc (array(double) c)
    
    Arguments:

     

    c (output)
    Linear terms of the objective as a dense vector. The lengths is the number of variables.
    Description:
    Obtains all objective coefficients c.
  • mosek.Task.getcfix

    Syntax:

     

    double getcfix ()
    
    Returns:
     
    Description:
    Obtains the fixed term in the objective.
  • mosek.Task.getcone

    Syntax:

     

    getcone (
        int k,
        List|None conetype,
        List|None conepar,
        List|None nummem,
        array(int) submem)
    
    Arguments:

     

    k (input)
    Index of the cone constraint.
    conetype (output)
    Specifies the type of the cone.
    conepar (output)
    This argument is currently not used. Can be set to 0.0.
    nummem (output)
    Number of member variables in the cone.
    submem (output)
    Variable subscripts of the members in the cone.
    Description:
    Obtains a conic constraint.
  • mosek.Task.getconeinfo

    Syntax:

     

    getconeinfo (
        int k,
        List|None conetype,
        List|None conepar,
        List|None nummem)
    
    Arguments:

     

    k (input)
    Index of the conic constraint.
    conetype (output)
    Specifies the type of the cone.
    conepar (output)
    This argument is currently not used. Can be set to 0.0.
    nummem (output)
    Number of member variables in the cone.
    Description:
    Obtains information about a conic constraint.
  • mosek.Task.getconname

    Syntax:

     

    str getconname (int i)
    
    Arguments:

     

    i (input)
    Index.
    Returns:
     
    Description:
    Obtains a name of a constraint.
    See also:

     

    Task.getmaxnamelen

    Obtains the maximum length of any objective, constraint, variable or cone name.

  • mosek.Task.getcslice