This chapter lists all functionality in the MOSEK C API.
A signed integer interpreted as a boolean value.
The MOSEK Environment type.
A 32 bits signed integer used for indexing. This is used as indexer into arrays which are guaranteed to not exceed bits in length.
Signed 32bit integer.
Signed 64bit integer.
A signed integer. This is a 32 bits signed integer.
A signed integer used for indexing. This is used as indexer into arrays which on some platforms may exceed bits in length. On 32-bit architectures it will always be a signed 32 bits integer, while on 64-bit architectures it may be either a 32 or 64 bits signed integer.
A signed large integer. On 32-bit architectures it is always 32 bits, while on 64-bit architectures it may be either 32 or 64 bits.
An unsigned integer interpreted as a code list element. Each operation in a code list consists of 4 elements.
The floating point type used by MOSEK.
The string type used by MOSEK. This is an UTF-8 encoded zero-terminated char string.
The MOSEK Task type.
Unsigned 32bit integer.
Unsigned 64bit integer.
A pointer to a generic user-defined structure.
Wide char type. The actual type may differ depending on the platform; it is either a 16 or 32 bits signed or unsigned integer.
Definition of the progress call-back function. The progress call-back function is a user-defined function which will be called by MOSEK occasionally during the optimization process. In particular, the call-back function is called at the beginning of each iteration in the interior-point optimizer. For the simplex optimizers MSK_IPAR_LOG_SIM_FREQ controls how frequently the call-back is called.
Typically the user-defined call-back function displays information about the solution process. The call-back function can also be used to terminate the optimization process since if the progress call-back function returns a non-zero value, the optimization process is aborted.
It is important that the user-defined call-back function does not modify the optimization task, this will lead to undefined and incorrect results. The only MOSEK functions that can be called safely from within the user-defined call-back function are MSK_getdouinf and MSK_getintinf which access the task information database. The items in task information database are updated during the optimization process.
MSKintt MSKcallbackfunc ( MSKtask_t task, MSKuserhandle_t usrptr, MSKcallbackcodee caller);
void MSKexitfunc ( MSKuserhandle_t usrptr, MSKCONST char * file, MSKintt line, MSKCONST char * msg);
(input/output)
A pointer to a user-defined structure.
(input)
The name of the file where the fatal error occurred.
(input)
The line number in the file where the fatal error occurred.
(input)
A message about the error.
void MSKfreefunc ( MSKuserhandle_t usrptr, void * buffer);
(input)
A pointer to a user-defined structure.
(input/output)
A pointer to the buffer which should be freed.
void * MSKmallocfunc ( MSKuserhandle_t usrptr, MSKCONST size_t size);
(input)
A pointer to a user-defined structure.
(input)
The number of characters to allocate.
Type definition of the call-back function which is used to provide structural information about the nonlinear functions f and g in the optimization problem.
Hence, it is the user's responsibility to provide a function satisfying the definition. The function is inputted to MOSEK using the API function MSK_putnlfunc.
MSKintt MSKnlgetspfunc ( MSKuserhandle_t nlhandle, MSKintt * numgrdobjnz, MSKidxt * grdobjsub, MSKidxt i, MSKbooleant * convali, MSKintt * grdconinz, MSKidxt * grdconisub, MSKintt yo, MSKintt numycnz, MSKCONST MSKidxt * ycsub, MSKintt maxnumhesnz, MSKintt * numhesnz, MSKidxt * hessubi, MSKidxt * hessubj);
(input/output)
A pointer to a user-defined data structure specified when the function is attached to a task using the function MSK_putnlfunc.
(output)
If requested, numgrdobjnz should be assigned the number of non-zero elements in the gradient of f.
(output)
If requested, put here the positions of the non-zero elements in the gradient of f. The elements are stored in
![]() |
(input)
Index of a constraint. If i<0 or , no information about a constraint is requested.
(output)
If requested, assign a true/false value indicating if constraint i contains general nonlinear terms.
(output)
If requested, grdconinz shall be assigned the number of non-zero elements in .
(output)
If requested, this array shall contain the indexes of the non-zeros in . The length of the array must be the same as given in grdconinz.
(input)
If non-zero, then the f shall be included when the gradient and the Hessian of the Lagrangian are computed.
(input)
Number of constraint functions which are included in the definition of the Lagrangian. See (15.1.1).
(input)
Index of constraint functions which are included in the definition of the Lagrangian. See (15.1.1).
(input)
Length of the arguments hessubi and hessubj.
(output)
If requested, numhesnz should be assigned the number of non-zero elements in the lower triangular part of the Hessian of the Lagrangian:
![]() |
(15.1.1) |
(output)
If requested, hessubi and hessubj are used to convey the position of the non-zeros in the Hessian of the Lagrangian L (see (15.1.1)) as follows
![]() |
(15.1.2) |
for . All other positions in L are assumed to be zero. Please note that only the lower or the upper triangular part of the Hessian should be return.
(output)
See the argument hessubi.
Type definition of the call-back function which is used to provide structural and numerical information about the nonlinear functions f and g in an optimization problem.
For later use we need the definition of the Lagrangian L which is given by
![]() |
(15.1.3) |
MSKintt MSKnlgetvafunc ( MSKuserhandle_t nlhandle, MSKCONST MSKrealt * xx, MSKrealt yo, MSKCONST MSKrealt * yc, MSKrealt * objval, MSKintt * numgrdobjnz, MSKidxt * grdobjsub, MSKrealt * grdobjval, MSKintt numi, MSKCONST MSKidxt * subi, MSKrealt * conval, MSKCONST MSKintt * grdconptrb, MSKCONST MSKintt * grdconptre, MSKCONST MSKidxt * grdconsub, MSKrealt * grdconval, MSKrealt * grdlag, MSKintt maxnumhesnz, MSKintt * numhesnz, MSKidxt * hessubi, MSKidxt * hessubj, MSKrealt * hesval);
(input/output)
A pointer to a user-defined data structure. The pointer is passed to MOSEK when the function MSK_putnlfunc is called.
(input)
The point at which the nonlinear function must be evaluated. The length equals the number of variables in the task.
(input)
Multiplier on the objective function f.
(input)
Multipliers for the constraint functions . The length is numcon.
(output)
If requested, objval shall be assigned the value of f evaluated at xx.
(output)
If requested, numgrdobjnz shall be assigned the number of non-zero elements in the gradient of f.
(output)
If requested, it shall contain the position of the non-zero elements in the gradient of f. The elements are stored in
![]() |
(output)
If requested, it shall contain the the gradient of f evaluated at . The following data structure
![]() |
for is used.
(input)
Number of elements in subi.
(input)
contain the indexes of the constraints that has to be evaluated. The length is numi.
(output)
for the required constraint functions i.e.
![]() |
for
(input)
If given, it specifies the structure of the gradients of the constraint functions. See the argument grdconval for details.
(input)
If given, it specifies the structure of the gradients of the constraint functions. See the argument grdconval for details.
(input)
If requested, it shall specify the positions of the non-zeros in gradients of the constraints. See the argument grdconval for details.
(output)
If requested, it shall specify the values of the gradient of the nonlinear constraints.
Together grdconptrb, grdconptre, grdconsub and grdconval are used to specify the gradients of the nonlinear constraint functions.
Please note that both grdconsub and grdconval should be computed when requested.
The gradient data is stored as follows
![]() |
(output)
If requested, grdlag shall contain the gradient of the Lagrangian function, i.e.
![]() |
(input)
Maximum number of non-zeros in the Hessian of the Lagrangian, i.e. maxnumhesnz is the length of the arrays hessubi, hessubj, and hesval.
(output)
If requested, numhesnz shall be assigned the number of non-zeros elements in the Hessian of the Lagrangian L. See (15.1.3).
(output)
See the argument hesval.
(output)
See the argument hesval.
(output)
Together hessubi, hessubj, and hesval specify the Hessian of the Lagrangian function L defined in (15.1.3).
The Hessian is stored in the following format:
![]() |
for . Please note that if an element is specified multiple times, then the elements are added together. Hence, only the lower or the upper triangular part of the Hessian should be returned.
MSKrescodee MSKresponsefunc ( MSKuserhandle_t handle, MSKrescodee r, MSKCONST char * msg);
(input/output)
A pointer to a user-defined data structure or NULL.
(input)
The response code corresponding to the exception.
(input)
A string containing the exception message.
void MSKstreamfunc ( MSKuserhandle_t handle, MSKCONST char * str);
(input/output)
A pointer to a user-defined data structure (or a null pointer).
(input)
A string containing a message to a stream.
Functions in the interface grouped by functionality.
Analyzing the problem and associated data.
MSK_analyzeproblem
Analyze the data of a task.
MSK_analyzesolution
Print information related to the quality of the solution.
Reading and writing data files.
MSK_readbranchpriorities
Reads branching priority data from a file.
MSK_readdata
Reads problem data from a file.
MSK_readparamfile
Reads a parameter file.
MSK_readsolution
Reads a solution from a file.
MSK_writebranchpriorities
Writes branching priority data to a file.
MSK_writedata
Writes problem data to a file.
MSK_writeparamfile
Writes all the parameters to a parameter file.
MSK_writesolution
Write a solution to a file.
Obtain or define a solution.
MSK_deletesolution
Undefines a solution and frees the memory it uses.
MSK_getdbi
Obtains the dual bound infeasibility.
MSK_getdcni
Obtains the dual cone infeasibility.
MSK_getdeqi
Optains the dual equation infeasibility.
MSK_getdualobj
Obtains the dual objective value.
MSK_getinti
Obtains the primal equation infeasibility.
MSK_getpbi
Obtains the primal bound infeasibility.
MSK_getpcni
Obtains the primal cone infeasibility.
MSK_getpeqi
Obtains the primal equation infeasibility.
MSK_getprimalobj
Obtains the primal objective value.
MSK_getreducedcosts
Obtains the difference of (slx-sux) for a sequence of variables.
MSK_getsolution
Obtains the complete solution.
MSK_getsolutioni
Obtains the solution for a single constraint or variable.
MSK_getsolutionincallback
Obtains the whole or a part of the solution from the progress call-back function.
MSK_getsolutioninf
Obtains information about a solution.
MSK_getsolutionslice
Obtains a slice of the solution.
MSK_getsolutionstatus
Obtains information about the problem and solution statuses.
MSK_getsolutionstatuskeyslice
Obtains a slice of the solution status keys.
MSK_makesolutionstatusunknown
Sets the solution status to unknown.
MSK_optimizersummary
Prints a short summary with optimizer statistics for last optimization.
MSK_putsolution
Inserts a solution.
MSK_putsolutioni
Sets the primal and dual solution information for a single constraint or variable.
MSK_readsolution
Reads a solution from a file.
MSK_solstatostr
Obtains a solution status string.
MSK_solutiondef
Checks whether a solution is defined.
MSK_solutionsummary
Prints a short summary of the current solutions.
MSK_undefsolution
Undefines a solution.
Manipulating call-backs.
MSK_getcallbackfunc
Obtains the call-back function and the associated user handle.
MSK_getnlfunc
Gets nonlinear call-back functions.
MSK_getsolutionincallback
Obtains the whole or a part of the solution from the progress call-back function.
MSK_linkfunctoenvstream
Connects a user-defined function to a stream.
MSK_linkfunctotaskstream
Connects a user-defined function to a task stream.
MSK_putcallbackfunc
Input the progress call-back function.
MSK_putexitfunc
Inputs a user-defined exit function which is called in case of fatal errors.
MSK_putnlfunc
Inputs nonlinear function information.
MSK_putresponsefunc
Inputs a user-defined error call-back function.
MSK_unlinkfuncfromenvstream
Disconnects a user-defined function from a stream.
MSK_unlinkfuncfromtaskstream
Disconnects a user-defined function from a task stream.
Memory allocation and deallocation.
MSK_callocdbgenv
A replacement for the system calloc function.
MSK_callocdbgtask
A replacement for the system calloc function.
MSK_callocenv
A replacement for the system calloc function.
MSK_calloctask
A replacement for the system calloc function.
MSK_checkmemenv
Checks the memory allocated by the environment.
MSK_checkmemtask
Checks the memory allocated by the task.
MSK_freedbgenv
Frees space allocated by MOSEK.
MSK_freedbgtask
Frees space allocated by MOSEK.
MSK_freeenv
Frees space allocated by MOSEK.
MSK_freetask
Frees space allocated by MOSEK.
MSK_getmemusagetask
Obtains information about the amount of memory used by a task.
MSK_getmemusagetask64
Obtains information about the amount of memory used by a task.
Input or change problem specification.
MSK_append
Appends a number of variables or constraints to the optimization task.
MSK_appendcone
Appends a new cone constraint to the problem.
MSK_checkoutlicense
Check out a license feature from the license server ahead of time.
MSK_chgbound
Changes the bounds for one constraint or variable.
MSK_clonetask
Creates a clone of an existing task.
MSK_commitchanges
Commits all cached problem changes.
MSK_inputdata
Input the linear part of an optimization task in one function call.
MSK_inputdata64
Input the linear part of an optimization task in one function call.
MSK_putaij
Changes a single value in the linear coefficient matrix.
MSK_putaijlist
Changes one or more coefficients in the linear constraint matrix.
MSK_putavec
Replaces all elements in one row or column of the linear coefficient matrix.
MSK_putaveclist
Replaces all elements in one or more rows or columns in the linear constraint matrix by new values.
MSK_putaveclist64
Replaces all elements in one or more rows or columns in the linear constraint matrix by new values.
MSK_putbound
Changes the bound for either one constraint or one variable.
MSK_putboundlist
Changes the bounds of constraints or variables.
MSK_putboundslice
Modifies bounds.
MSK_putcfix
Replaces the fixed term in the objective.
MSK_putcj
Modifies one linear coefficient in the objective.
MSK_putclist
Modifies a part of the linear objective coefficients.
MSK_putcone
Replaces a conic constraint.
MSK_putobjsense
Sets the objective sense.
MSK_putqcon
Replaces all quadratic terms in constraints.
MSK_putqconk
Replaces all quadratic terms in a single constraint.
MSK_putqobj
Replaces all quadratic terms in the objective.
MSK_putqobjij
Replaces one coefficient in the quadratic term in the objective.
MSK_putvartype
Sets the variable type of one variable.
MSK_putvartypelist
Sets the variable type for one or more variables.
Functionality for deleting problem elements such as variables, constraints or cones.
MSK_remove
The function removes a number of constraints or variables.
MSK_removecone
Removes a conic constraint from the problem.
Functionality for adding problem elements such as variables, constraints or cones.
MSK_append
Appends a number of variables or constraints to the optimization task.
MSK_appendcone
Appends a new cone constraint to the problem.
Functionality for inspecting the problem specification (A,Q, bounds, objective e.t.c).
MSK_getaij
Obtains a single coefficient in linear constraint matrix.
MSK_getaslice
Obtains a sequence of rows or columns from the coefficient matrix.
MSK_getaslice64
Obtains a sequence of rows or columns from the coefficient matrix.
MSK_getaslicetrip
Obtains a sequence of rows or columns from the coefficient matrix in triplet format.
MSK_getavec
Obtains one row or column of the linear constraint matrix.
MSK_getavecnumnz
Obtains the number of non-zero elements in one row or column of the linear constraint matrix
MSK_getbound
Obtains bound information for one constraint or variable.
MSK_getboundslice
Obtains bounds information for a sequence of variables or constraints.
MSK_getc
Obtains all objective coefficients.
MSK_getcfix
Obtains the fixed term in the objective.
MSK_getcone
Obtains a conic constraint.
MSK_getconeinfo
Obtains information about a conic constraint.
MSK_getcslice
Obtains a sequence of coefficients from the objective.
MSK_getintpntnumthreads
Obtains the number of threads used by the interior-point optimizer.
MSK_getnumanz
Obtains the number of non-zeros in the coefficient matrix.
MSK_getnumanz64
Obtains the number of non-zeros in the coefficient matrix.
MSK_getnumcon
Obtains the number of constraints.
MSK_getnumcone
Obtains the number of cones.
MSK_getnumconemem
Obtains the number of members in a cone.
MSK_getnumintvar
Obtains the number of integer-constrained variables.
MSK_getnumqconknz
Obtains the number of non-zero quadratic terms in a constraint.
MSK_getnumqconknz64
Obtains the number of non-zero quadratic terms in a constraint.
MSK_getnumqobjnz
Obtains the number of non-zero quadratic terms in the objective.
MSK_getnumqobjnz64
Obtains the number of non-zero quadratic terms in the objective.
MSK_getnumvar
Obtains the number of variables.
MSK_getobjsense
Gets the objective sense.
MSK_getprobtype
Obtains the problem type.
MSK_getqconk
Obtains all the quadratic terms in a constraint.
MSK_getqconk64
Obtains all the quadratic terms in a constraint.
MSK_getqobj
Obtains all the quadratic terms in the objective.
MSK_getqobj64
Obtains all the quadratic terms in the objective.
MSK_getqobjij
Obtains one coefficient from the quadratic term of the objective
MSK_getvartype
Gets the variable type of one variable.
MSK_getvartypelist
Obtains the variable type for one or more variables.
Functionality related to conic terms in the problem.
MSK_appendcone
Appends a new cone constraint to the problem.
MSK_getcone
Obtains a conic constraint.
MSK_getconeinfo
Obtains information about a conic constraint.
MSK_getnumcone
Obtains the number of cones.
MSK_putcone
Replaces a conic constraint.
MSK_removecone
Removes a conic constraint from the problem.
Functionality related to changing or inspecting bounds on variables or constraints.
MSK_chgbound
Changes the bounds for one constraint or variable.
MSK_getbound
Obtains bound information for one constraint or variable.
MSK_getboundslice
Obtains bounds information for a sequence of variables or constraints.
MSK_putbound
Changes the bound for either one constraint or one variable.
MSK_putboundlist
Changes the bounds of constraints or variables.
MSK_putboundslice
Modifies bounds.
Task initialization and deletion.
MSK_deletetask
Deletes an optimization task.
MSK_makeemptytask
Creates a new and empty optimization task.
MSK_maketask
Creates a new optimization task.
Error handling.
MSK_exceptiontask
Echo a response code to a task stream.
MSK_getcodedesc
Obtains a short description of a response code.
MSK_getcodedisc
Obtains a short description of a response code.
MSK_getresponseclass
Obtain the class of a response code.
MSK_putresponsefunc
Inputs a user-defined error call-back function.
Output stream functions.
MSK_echoenv
Sends a message to a given environment stream.
MSK_echointro
Prints an intro to message stream.
MSK_echotask
Prints a format string to a task stream.
MSK_exceptiontask
Echo a response code to a task stream.
MSK_linkfiletoenvstream
Directs all output from a stream to a file.
MSK_linkfiletotaskstream
Directs all output from a task stream to a file.
MSK_linkfunctoenvstream
Connects a user-defined function to a stream.
MSK_linkfunctotaskstream
Connects a user-defined function to a task stream.
MSK_optimizersummary
Prints a short summary with optimizer statistics for last optimization.
MSK_printdata
Prints a part of the problem data to a stream.
MSK_printparam
Prints the current parameter settings.
MSK_readsummary
Prints information about last file read.
MSK_solutionsummary
Prints a short summary of the current solutions.
MSK_unlinkfuncfromenvstream
Disconnects a user-defined function from a stream.
MSK_unlinkfuncfromtaskstream
Disconnects a user-defined function from a task stream.
Change or inspect objective function.
MSK_getc
Obtains all objective coefficients.
MSK_getcfix
Obtains the fixed term in the objective.
MSK_getcslice
Obtains a sequence of coefficients from the objective.
MSK_getdualobj
Obtains the dual objective value.
MSK_getnumqobjnz
Obtains the number of non-zero quadratic terms in the objective.
MSK_getnumqobjnz64
Obtains the number of non-zero quadratic terms in the objective.
MSK_getobjname
Obtains the name assigned to the objective function.
MSK_getobjname64
Obtains the name assigned to the objective function.
MSK_getobjsense
Gets the objective sense.
MSK_getprimalobj
Obtains the primal objective value.
MSK_getqobj
Obtains all the quadratic terms in the objective.
MSK_getqobj64
Obtains all the quadratic terms in the objective.
MSK_getqobjij
Obtains one coefficient from the quadratic term of the objective
MSK_putcfix
Replaces the fixed term in the objective.
MSK_putcj
Modifies one linear coefficient in the objective.
MSK_putclist
Modifies a part of the linear objective coefficients.
MSK_putobjsense
Sets the objective sense.
MSK_putqobj
Replaces all quadratic terms in the objective.
MSK_putqobjij
Replaces one coefficient in the quadratic term in the objective.
Inspect statistics from the optimizer.
MSK_getdouinf
Obtains a double information item.
MSK_getinfindex
Obtains the index of a named information item.
MSK_getinfmax
Obtains the maximum index of an information of a given type inftype plus 1.
MSK_getinfname
Obtains the name of an information item.
MSK_getintinf
Obtains an integer information item.
MSK_getlintinf
Obtains an integer information item.
MSK_getnadouinf
Obtains a double information item.
MSK_getnaintinf
Obtains an integer information item.
MSK_getnaintparam
Obtains an integer parameter.
Setting and inspecting solver parameters.
MSK_getdouparam
Obtains a double parameter.
MSK_getintparam
Obtains an integer parameter.
MSK_getnadouparam
Obtains a double parameter.
MSK_getnastrparam
Obtains a string parameter.
MSK_getnastrparamal
Obtains the value of a string parameter.
MSK_getnumparam
Obtains the number of parameters of a given type.
MSK_getparammax
Obtains the maximum index of a parameter of a given type plus 1.
MSK_getparamname
Obtains the name of a parameter.
MSK_getstrparam
Obtains the value of a string parameter.
MSK_getstrparam64
Obtains the value of a string parameter.
MSK_getstrparamal
Obtains the value a string parameter.
MSK_getsymbcondim
Obtains dimensional information for the defined symbolic constants.
MSK_iparvaltosymnam
Obtains the symbolic name corresponding to a value that can be assigned to an integer parameter.
MSK_isdouparname
Checks a double parameter name.
MSK_isintparname
Checks an integer parameter name.
MSK_isstrparname
Checks a string parameter name.
MSK_putdouparam
Sets a double parameter.
MSK_putintparam
Sets an integer parameter.
MSK_putnadouparam
Sets a double parameter.
MSK_putnaintparam
Sets an integer parameter.
MSK_putnastrparam
Sets a string parameter.
MSK_putparam
Modifies the value of parameter.
MSK_putstrparam
Sets a string parameter.
MSK_setdefaults
Resets all parameters values.
MSK_symnamtovalue
Obtains the value corresponding to a symbolic name defined by MOSEK.
MSK_whichparam
Checks a parameter name.
Functionality related to naming.
MSK_getconname
Obtains a name of a constraint.
MSK_getconname64
Obtains a name of a constraint.
MSK_getmaxnamelen
Obtains the maximum length (not including terminating zero character) of any objective, constraint, variable or cone name.
MSK_getname
Obtains the name of a cone, a variable or a constraint.
MSK_getname64
Obtains the name of a cone, a variable or a constraint.
MSK_getnameapi64
Obtains the name of a cone, a variable or a constraint.
MSK_getnameindex
Checks whether a name has been assigned and returns the index corresponding to the name.
MSK_getnamelen64
Obtains the length of a problem item name.
MSK_getobjname
Obtains the name assigned to the objective function.
MSK_getobjname64
Obtains the name assigned to the objective function.
MSK_gettaskname
Obtains the task name.
MSK_gettaskname64
Obtains the task name.
MSK_getvarname
Obtains a name of a variable.
MSK_getvarname64
Obtains a name of a variable.
MSK_putname
Assigns a name to a problem item.
MSK_putobjname
Assigns a new name to the objective.
MSK_puttaskname
Assigns a new name to the task.
Functionality related to preallocating space for problem data.
MSK_getmaxnumanz
Obtains number of preallocated non-zeros in the linear constraint matrix.
MSK_getmaxnumanz64
Obtains number of preallocated non-zeros in the linear constraint matrix.
MSK_getmaxnumcon
Obtains the number of preallocated constraints in the optimization task.
MSK_getmaxnumcone
Obtains the number of preallocated cones in the optimization task.
MSK_getmaxnumqnz
Obtains the number of preallocated non-zeros for all quadratic terms in objective and constraints.
MSK_getmaxnumqnz64
Obtains the number of preallocated non-zeros for all quadratic terms in objective and constraints.
MSK_getmaxnumvar
Obtains the maximum number variables allowed.
MSK_putmaxnumanz
The function changes the size of the preallocated storage for linear coefficients.
MSK_putmaxnumanz64
The function changes the size of the preallocated storage for linear coefficients.
MSK_putmaxnumcon
Sets the number of preallocated constraints in the optimization task.
MSK_putmaxnumcone
Sets the number of preallocated conic constraints in the optimization task.
MSK_putmaxnumqnz
Changes the size of the preallocated storage for quadratic terms.
MSK_putmaxnumqnz64
Changes the size of the preallocated storage for quadratic terms.
MSK_putmaxnumvar
Sets the number of preallocated variables in the optimization task.
Functionality related to integer variables.
MSK_getnumintvar
Obtains the number of integer-constrained variables.
MSK_getvarbranchdir
Obtains the branching direction for a variable.
MSK_getvarbranchorder
Obtains the branching priority for a variable.
MSK_getvarbranchpri
Obtains the branching priority for a variable.
MSK_getvartype
Gets the variable type of one variable.
MSK_getvartypelist
Obtains the variable type for one or more variables.
MSK_putvarbranchorder
Assigns a branching priority and direction to a variable.
MSK_putvartype
Sets the variable type of one variable.
MSK_putvartypelist
Sets the variable type for one or more variables.
Functionality related to quadratic terms.
MSK_getqconk
Obtains all the quadratic terms in a constraint.
MSK_getqconk64
Obtains all the quadratic terms in a constraint.
MSK_getqobj
Obtains all the quadratic terms in the objective.
MSK_getqobj64
Obtains all the quadratic terms in the objective.
MSK_getqobjij
Obtains one coefficient from the quadratic term of the objective
MSK_putqcon
Replaces all quadratic terms in constraints.
MSK_putqconk
Replaces all quadratic terms in a single constraint.
MSK_putqobj
Replaces all quadratic terms in the objective.
MSK_putqobjij
Replaces one coefficient in the quadratic term in the objective.
Functions for diagnosing infeasibility.
MSK_getinfeasiblesubproblem
Obtains an infeasible sub problem.
MSK_relaxprimal
Creates a problem that finds the minimal change to the bounds that makes an infeasible problem feasible.
Functions for optimization.
MSK_checkdata
Checks data of the task.
MSK_netoptimize
Optimizes a pure network flow problem.
MSK_optimize
Optimizes the problem.
MSK_optimizeconcurrent
Optimize a given task with several optimizers concurrently.
MSK_optimizetrm
Optimizes the problem.
Functions for network optimization.
MSK_netextraction
Finds embedded network structure.
MSK_netoptimize
Optimizes a pure network flow problem.
Functions for sensitivity analysis.
MSK_dualsensitivity
Performs sensitivity analysis on objective coefficients.
MSK_primalsensitivity
Perform sensitivity analysis on bounds.
MSK_sensitivityreport
Creates a sensitivity report.
Functions for testing data validity.
MSK_checkconvexity
Checks if a quadratic optimization problem is convex.
Functions for solving linear systems with the basis matrix.
MSK_basiscond
Computes conditioning information for the basis matrix.
MSK_initbasissolve
Prepare a task for basis solver.
MSK_solvewithbasis
Solve a linear equation system involving a basis matrix.
Creation and initialization of environment.
MSK_checkinlicense
Check in a license feature from the license server ahead of time.
MSK_deleteenv
Delete a MOSEK environment.
MSK_initenv
Initialize a MOSEK environment.
MSK_makeenv
Creates a new MOSEK environment.
MSK_putlicensedefaults
Set defaults used by the license manager.
Change elements in the coefficient (A) matrix.
MSK_checkoutlicense
Check out a license feature from the license server ahead of time.
MSK_commitchanges
Commits all cached problem changes.
MSK_putaij
Changes a single value in the linear coefficient matrix.
MSK_putaijlist
Changes one or more coefficients in the linear constraint matrix.
MSK_putavec
Replaces all elements in one row or column of the linear coefficient matrix.
MSK_putaveclist
Replaces all elements in one or more rows or columns in the linear constraint matrix by new values.
MSK_putaveclist64
Replaces all elements in one or more rows or columns in the linear constraint matrix by new values.
A Mosek Environment
void * MSK_callocdbgenv ( MSKenv_t env, MSKCONST size_t number, MSKCONST size_t size, MSKCONST char * file, MSKCONST unsigned line);
void * MSK_callocenv ( MSKenv_t env, MSKCONST size_t number, MSKCONST size_t size);
MSKrescodee MSK_checkinlicense ( MSKenv_t env, MSKfeaturee feature);
Check in a license feature to the license server. By default all licenses consumed by functions using a single environment is kept checked out for the lifetime of the MOSEK environment. This function checks in a given license feature to the license server immidiatly.
If the given license feature is not checked out or is in use by a call to MSK_optimizetrm calling this function has no effect.
Please note that returning a license to the license server incurs a small overhead, so frequent calls to this function should be avoided.
MSKrescodee MSK_checkmemenv ( MSKenv_t env, MSKCONST char * file, MSKintt line);
MSKrescodee MSK_checkoutlicense ( MSKenv_t env, MSKfeaturee feature);
Check out a license feature from the license server. Normally the required license features will be automatically checked out the first time it is needed by the function MSK_optimizetrm. This function can be used to check out one or more features ahead of time.
The license will remain checked out until the environment is deleted with MSK_deleteenv or the function MSK_checkinlicense is called.
If a given feature is already checked out when this function is called, only one feature will be checked out from the license server.
MSKrescodee MSK_checkversion ( MSKenv_t env, MSKintt major, MSKintt minor, MSKintt build, MSKintt revision);
MSKrescodee MSK_deleteenv (MSKenv_t * env)
Deletes a MOSEK environment and all the data associated with it.
Before calling this function it is a good idea to call the function MSK_unlinkfuncfromenvstream for each stream that has have had function linked to it.
MSKrescodee MSK_echoenv ( MSKenv_t env, MSKstreamtypee whichstream, MSKCONST char * format, ...);
MSKrescodee MSK_echointro ( MSKenv_t env, MSKintt longver);
void MSK_freedbgenv ( MSKenv_t env, MSKCONST void * buffer, MSKCONST char * file, MSKCONST unsigned line);
void MSK_freeenv ( MSKenv_t env, MSKCONST void * buffer);
MSKrescodee MSK_getbuildinfo ( char * buildstate, char * builddate, char * buildtool);
MSKrescodee MSK_getcodedesc ( MSKrescodee code, char * symname, char * str);
MSKrescodee MSK_getcodedisc ( MSKrescodee code, char * symname, char * str);
MSKrescodee MSK_getglbdllname ( MSKenv_t env, MSKCONST size_t sizedllname, char * dllname);
MSKrescodee MSK_getsymbcondim ( MSKenv_t env, MSKintt * num, size_t * maxlen);
MSKrescodee MSK_getversion ( MSKintt * major, MSKintt * minor, MSKintt * build, MSKintt * revision);
MSKrescodee MSK_initenv (MSKenv_t env)
MSKrescodee MSK_iparvaltosymnam ( MSKenv_t env, MSKiparame whichparam, MSKintt whichvalue, char * symbolicname);
MSKbooleant MSK_isinfinity (MSKrealt value)
MSKrescodee MSK_linkfiletoenvstream ( MSKenv_t env, MSKstreamtypee whichstream, MSKCONST char * filename, MSKintt append);
MSKrescodee MSK_linkfunctoenvstream ( MSKenv_t env, MSKstreamtypee whichstream, MSKuserhandle_t handle, MSKstreamfunc func);
MSKrescodee MSK_makeemptytask ( MSKenv_t env, MSKtask_t * task);
MSKrescodee MSK_makeenv ( MSKenv_t * env, MSKuserhandle_t usrptr, MSKmallocfunc usrmalloc, MSKfreefunc usrfree, MSKCONST char * dbgfile);
Initialize a MOSEK environment.
Sets the path to the DLL/shared libraries that MOSEK is loading.
Set defaults used by the license manager.
Set defaults default CPU type and cache sizes.
MSKrescodee MSK_maketask ( MSKenv_t env, MSKintt maxnumcon, MSKintt maxnumvar, MSKtask_t * task);
MSKrescodee MSK_putcpudefaults ( MSKenv_t env, int cputype, MSKintt sizel1, MSKintt sizel2);
MSKrescodee MSK_putdllpath ( MSKenv_t env, MSKCONST char * dllpath);
MSKrescodee MSK_putexitfunc ( MSKenv_t env, MSKexitfunc exitfunc, MSKuserhandle_t handle);
MSKrescodee MSK_putkeepdlls ( MSKenv_t env, MSKintt keepdlls);
MSKrescodee MSK_putlicensedefaults ( MSKenv_t env, MSKCONST char * licensefile, MSKCONST MSKintt * licensebuf, MSKintt licwait, MSKintt licdebug);
void MSK_replacefileext ( char * filename, MSKCONST char * newextension);
char * MSK_strdupdbgenv ( MSKenv_t env, MSKCONST char * str, MSKCONST char * file, MSKCONST unsigned line);
char * MSK_strdupenv ( MSKenv_t env, MSKCONST char * str);
MSKbooleant MSK_symnamtovalue ( MSKCONST char * name, char * value);
MSKrescodee MSK_unlinkfuncfromenvstream ( MSKenv_t env, MSKstreamtypee whichstream);
MSKrescodee MSK_utf8towchar ( MSKCONST size_t outputlen, size_t * len, size_t * conv, MSKwchart * output, MSKCONST char * input);
MSKrescodee MSK_wchartoutf8 ( MSKCONST size_t outputlen, size_t * len, size_t * conv, char * output, MSKCONST MSKwchart * input);
A Mosek Optimization task
MSKrescodee MSK_analyzeproblem ( MSKtask_t task, MSKstreamtypee whichstream);
MSKrescodee MSK_analyzesolution ( MSKtask_t task, MSKstreamtypee whichstream, MSKsoltypee whichsol);
Print information related to the quality of the solution and other solution statistics.
By default this function prints information about the largest infeasibilites in the solution, the primal (and possibly dual) objective value and the solution status.
Following parameters can be used to configure the printed statistics:
Obtains the primal equation infeasibility.
Optains the dual equation infeasibility.
Obtains the primal bound infeasibility.
Obtains the dual bound infeasibility.
Obtains the dual cone infeasibility.
Obtains the primal cone infeasibility.
Obtains information about a solution.
Obtains information about the problem and solution statuses.
MSKrescodee MSK_append ( MSKtask_t task, MSKaccmodee accmode, MSKintt num);
The function removes a number of constraints or variables.
MSKrescodee MSK_appendcone ( MSKtask_t task, MSKconetypee conetype, MSKrealt conepar, MSKintt nummem, MSKCONST MSKidxt * submem);
Appends a new conic constraint to the problem. Hence, add a constraint
![]() |
to the problem where is a convex cone.
is a subset of the variables which will be specified by the argument submem.
Depending on the value of conetype this function appends a normal (MSK_CT_QUAD) or rotated quadratic cone (MSK_CT_RQUAD). Define
![]() |
. Depending on the value of conetype this function appends one of the constraints:
Quadratic cone (MSK_CT_QUAD) :
![]() |
Rotated quadratic cone (MSK_CT_RQUAD) :
![]() |
Please note that the sets of variables appearing in different conic constraints must be disjoint.
For an explained code example see Section 5.4.
MSKrescodee MSK_basiscond ( MSKtask_t task, MSKrealt * nrmbasis, MSKrealt * nrminvbasis);
If a basic solution is available and it defines a nonsingular basis, then this function computes the 1-norm estimate of the basis matrix and an 1-norm estimate for the inverse of the basis matrix. The 1-norm estimates are computed using the method outlined in [9, pp. 388-391].
By defintion the 1-norm condition number of a matrix B is defined as
![]() |
Moreover, the larger the condition number is the harder it is to solve linear equation systems involving B. Given estimates for and
it is also possible to estimate
.
MSKrescodee MSK_bktostr ( MSKtask_t task, MSKboundkeye bk, char * str);
MSKrescodee MSK_callbackcodetostr ( MSKcallbackcodee code, char * callbackcodestr);
void * MSK_callocdbgtask ( MSKtask_t task, MSKCONST size_t number, MSKCONST size_t size, MSKCONST char * file, MSKCONST unsigned line);
void * MSK_calloctask ( MSKtask_t task, MSKCONST size_t number, MSKCONST size_t size);
MSKrescodee MSK_checkconvexity (MSKtask_t task)
This function checks if a quadratic optimization problem is convex. The amount of checking is controlled by MSK_IPAR_CHECK_CONVEXITY.
The function returns an error code other than MSK_RES_OK if the problem is not convex.
MSKrescodee MSK_checkdata (MSKtask_t task)
MSKrescodee MSK_checkmemtask ( MSKtask_t task, MSKCONST char * file, MSKintt line);
MSKrescodee MSK_chgbound ( MSKtask_t task, MSKaccmodee accmode, MSKidxt i, MSKintt lower, MSKintt finite, MSKrealt value);
Changes a bound for one constraint or variable. If accmode equals MSK_ACC_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:
![]() |
Otherwise if lower is zero, then
![]() |
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.
Changes the bound for either one constraint or one variable.
MSKrescodee MSK_clonetask ( MSKtask_t task, MSKtask_t * clonedtask);
MSKrescodee MSK_commitchanges (MSKtask_t task)
MSKrescodee MSK_conetypetostr ( MSKtask_t task, MSKconetypee conetype, char * str);
MSKrescodee MSK_deletesolution ( MSKtask_t task, MSKsoltypee whichsol);
MSKrescodee MSK_deletetask (MSKtask_t * task)
MSKrescodee MSK_dualsensitivity ( MSKtask_t task, MSKintt numj, MSKCONST MSKidxt * subj, MSKrealt * leftpricej, MSKrealt * rightpricej, MSKrealt * leftrangej, MSKrealt * rightrangej);
Calculates sensitivity information for objective coefficients. The indexes of the coefficients to analyze are
![]() |
The results are returned so that e.g is the left shadow price of the objective coefficient with index
.
The type of sensitivity analysis to perform (basis or optimal partition) is controlled by the parameter MSK_IPAR_SENSITIVITY_TYPE.
For an example, please see Section 12.5.
Perform sensitivity analysis on bounds.
Creates a sensitivity report.
MSKrescodee MSK_echotask ( MSKtask_t task, MSKstreamtypee whichstream, MSKCONST char * format, ...);
MSKrescodee MSK_exceptiontask ( MSKtask_t task, MSKrescodee code, ...);
void MSK_freedbgtask ( MSKtask_t task, MSKCONST void * buffer, MSKCONST char * file, MSKCONST unsigned line);
void MSK_freetask ( MSKtask_t task, MSKCONST void * buffer);
MSKrescodee MSK_getaij ( MSKtask_t task, MSKidxt i, MSKidxt j, MSKrealt * aij);
MSKrescodee MSK_getapiecenumnz ( MSKtask_t task, MSKidxt firsti, MSKidxt lasti, MSKidxt firstj, MSKidxt lastj, MSKintt * numnz);
Obtains the number non-zeros in a rectangular piece of A, i.e. the number
![]() |
where means the number of elements in the set
.
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 MSK_getavecnumnz.
Obtains the number of non-zero elements in one row or column of the linear constraint matrix
Obtains the number of non-zeros in a row or column slice of the coefficient matrix.
MSKrescodee MSK_getaslice ( MSKtask_t task, MSKaccmodee accmode, MSKidxt first, MSKidxt last, MSKintt maxnumnz, MSKintt * surp, MSKintt * ptrb, MSKlidxt * ptre, MSKidxt * sub, MSKrealt * val);
Obtains the number of non-zeros in a row or column slice of the coefficient matrix.
MSKrescodee MSK_getaslice64 ( MSKtask_t task, MSKaccmodee accmode, MSKidxt first, MSKidxt last, MSKint64t maxnumnz, MSKint64t * surp, MSKint64t * ptrb, MSKint64t * ptre, MSKidxt * sub, MSKrealt * val);
Obtains the number of non-zeros in a slice of rows or columns of the coefficient matrix.
MSKrescodee MSK_getaslicenumnz ( MSKtask_t task, MSKaccmodee accmode, MSKidxt first, MSKidxt last, MSKintt * numnz);
MSKrescodee MSK_getaslicenumnz64 ( MSKtask_t task, MSKaccmodee accmode, MSKidxt first, MSKidxt last, MSKint64t * numnz);
MSKrescodee MSK_getaslicetrip ( MSKtask_t task, MSKaccmodee accmode, MSKidxt first, MSKidxt last, MSKintt maxnumnz, MSKintt * surp, MSKidxt * subi, MSKidxt * subj, MSKrealt * val);
Obtains a sequence of rows or columns from A in a sparse triplet format.
Define as
![]() |
when the function is called and by
![]() |
where surp[0] is the value upon termination. Using this notation then
![]() |
Obtains the number of non-zeros in a row or column slice of the coefficient matrix.
MSKrescodee MSK_getavec ( MSKtask_t task, MSKaccmodee accmode, MSKidxt i, MSKintt * nzi, MSKidxt * subi, MSKrealt * vali);
Obtains one row or column of A in a sparse format. If accmode equals MSK_ACC_CON a row is returned and hence:
![]() |
If accmode equals MSK_ACC_VAR a column is returned, that is:
![]() |
MSKrescodee MSK_getavecnumnz ( MSKtask_t task, MSKaccmodee accmode, MSKidxt i, MSKintt * nzj);
MSKrescodee MSK_getbound ( MSKtask_t task, MSKaccmodee accmode, MSKidxt i, MSKboundkeye * bk, MSKrealt * bl, MSKrealt * bu);
MSKrescodee MSK_getboundslice ( MSKtask_t task, MSKaccmodee accmode, MSKidxt first, MSKidxt last, MSKboundkeye * bk, MSKrealt * bl, MSKrealt * bu);
MSKrescodee MSK_getc ( MSKtask_t task, MSKrealt * c);
MSKrescodee MSK_getcallbackfunc ( MSKtask_t task, MSKcallbackfunc * func, MSKuserhandle_t * handle);
MSKrescodee MSK_getcfix ( MSKtask_t task, MSKrealt * cfix);
MSKrescodee MSK_getcone ( MSKtask_t task, MSKidxt k, MSKconetypee * conetype, MSKrealt * conepar, MSKintt * nummem, MSKidxt * submem);
MSKrescodee MSK_getconeinfo ( MSKtask_t task, MSKidxt k, MSKconetypee * conetype, MSKrealt * conepar, MSKintt * nummem);
MSKrescodee MSK_getconname ( MSKtask_t task, MSKidxt i, MSKCONST size_t maxlen, char * name);
Obtains the maximum length (not including terminating zero character) of any objective, constraint, variable or cone name.
MSKrescodee MSK_getconname64 ( MSKtask_t task, MSKidxt i, MSKint64t maxlen, char * name);
Obtains the maximum length (not including terminating zero character) of any objective, constraint, variable or cone name.
MSKrescodee MSK_getcslice ( MSKtask_t task, MSKidxt first, MSKidxt last, MSKrealt * c);
MSKrescodee MSK_getdbi ( MSKtask_t task, MSKsoltypee whichsol, MSKaccmodee accmode, MSKCONST MSKidxt * sub, MSKintt len, MSKrealt * dbi);
Dual bound infeasibility. If acmode is MSK_ACC_CON then
![]() |
(15.4.1) |
else
![]() |
(15.4.2) |
Obtains information about a solution.
MSKrescodee MSK_getdcni ( MSKtask_t task, MSKsoltypee whichsol, MSKCONST MSKidxt * sub, MSKintt len, MSKrealt * dcni);
Obtains information about a solution.
MSKrescodee MSK_getdeqi ( MSKtask_t task, MSKsoltypee whichsol, MSKaccmodee accmode, MSKCONST MSKidxt * sub, MSKintt len, MSKrealt * deqi, MSKintt normalize);
Optains the dual equation infeasibility. If acmode is MSK_ACC_CON then
![]() |
(15.4.3) |
If acmode is MSK_ACC_VAR then
![]() |
(15.4.4) |
Obtains information about a solution.
MSKrescodee MSK_getdouinf ( MSKtask_t task, MSKdinfiteme whichdinf, MSKrealt * dvalue);
MSKrescodee MSK_getdouparam ( MSKtask_t task, MSKdparame param, MSKrealt * parvalue);
MSKrescodee MSK_getdualobj ( MSKtask_t task, MSKsoltypee whichsol, MSKrealt * dualobj);
MSKrescodee MSK_getenv ( MSKtask_t task, MSKenv_t * env);
MSKrescodee MSK_getinfeasiblesubproblem ( MSKtask_t task, MSKsoltypee whichsol, MSKtask_t * inftask);
Creates a problem that finds the minimal change to the bounds that makes an infeasible problem feasible.
MSKrescodee MSK_getinfindex ( MSKtask_t task, MSKinftypee inftype, MSKCONST char * infname, MSKintt * infindex);
MSKrescodee MSK_getinfmax ( MSKtask_t task, MSKinftypee inftype, MSKintt * infmax);
MSKrescodee MSK_getinfname ( MSKtask_t task, MSKinftypee inftype, MSKintt whichinf, char * infname);
MSKrescodee MSK_getinti ( MSKtask_t task, MSKsoltypee whichsol, MSKCONST MSKidxt * sub, MSKintt len, MSKrealt * inti);
Obtains the primal equation infeasibility.
![]() |
(15.4.5) |
Obtains information about a solution.
MSKrescodee MSK_getintinf ( MSKtask_t task, MSKiinfiteme whichiinf, MSKintt * ivalue);
MSKrescodee MSK_getintparam ( MSKtask_t task, MSKiparame param, MSKintt * parvalue);
MSKrescodee MSK_getintpntnumthreads ( MSKtask_t task, MSKintt * numthreads);
MSKrescodee MSK_getlasterror ( MSKtask_t task, MSKrescodee * lastrescode, MSKCONST size_t maxlen, size_t * lastmsglen, char * lastmsg);
Obtains the last response code and corresponding message reported in MOSEK.
If there is no previous error, warning or termination code for this task, lastrescode returns MSK_RES_OK and lastmsg returns an empty string, otherwise the last response code different from MSK_RES_OK and the corresponding message are returned.
MSKrescodee MSK_getlasterror64 ( MSKtask_t task, MSKrescodee * lastrescode, MSKint64t maxlen, MSKint64t * lastmsglen, char * lastmsg);
Obtains the last response code and corresponding message reported in MOSEK.
If there is no previous error, warning or termination code for this task, lastrescode returns MSK_RES_OK and lastmsg returns an empty string, otherwise the last response code different from MSK_RES_OK and the corresponding message are returned.
MSKrescodee MSK_getlintinf ( MSKtask_t task, MSKliinfiteme whichliinf, MSKint64t * ivalue);
MSKrescodee MSK_getmaxnamelen ( MSKtask_t task, size_t * maxlen);
MSKrescodee MSK_getmaxnumanz ( MSKtask_t task, MSKintt * maxnumanz);
MSKrescodee MSK_getmaxnumanz64 ( MSKtask_t task, MSKint64t * maxnumanz);
MSKrescodee MSK_getmaxnumcon ( MSKtask_t task, MSKintt * maxnumcon);
MSKrescodee MSK_getmaxnumcone ( MSKtask_t task, MSKintt * maxnumcone);
MSKrescodee MSK_getmaxnumqnz ( MSKtask_t task, MSKintt * maxnumqnz);
MSKrescodee MSK_getmaxnumqnz64 ( MSKtask_t task, MSKint64t * maxnumqnz);
MSKrescodee MSK_getmaxnumvar ( MSKtask_t task, MSKintt * maxnumvar);
MSKrescodee MSK_getmemusagetask ( MSKtask_t task, size_t * meminuse, size_t * maxmemuse);
MSKrescodee MSK_getmemusagetask64 ( MSKtask_t task, MSKint64t * meminuse, MSKint64t * maxmemuse);
MSKrescodee MSK_getnadouinf ( MSKtask_t task, MSKCONST char * whichdinf, MSKrealt * dvalue);
MSKrescodee MSK_getnadouparam ( MSKtask_t task, MSKCONST char * paramname, MSKrealt * parvalue);
MSKrescodee MSK_getnaintinf ( MSKtask_t task, MSKCONST char * infitemname, MSKintt * ivalue);
MSKrescodee MSK_getnaintparam ( MSKtask_t task, MSKCONST char * paramname, MSKintt * parvalue);
MSKrescodee MSK_getname ( MSKtask_t task, MSKproblemiteme whichitem, MSKidxt i, MSKCONST size_t maxlen, size_t * len, char * name);
Obtains the maximum length (not including terminating zero character) of any objective, constraint, variable or cone name.
MSKrescodee MSK_getname64 ( MSKtask_t task, MSKproblemiteme whichitem, MSKidxt i, MSKint64t maxlen, MSKint64t * len, char * name);
Obtains the maximum length (not including terminating zero character) of any objective, constraint, variable or cone name.
MSKrescodee MSK_getnameapi64 ( MSKtask_t task, MSKproblemiteme whichitem, MSKidxt i, MSKint64t maxlen, char * name);
Obtains the maximum length (not including terminating zero character) of any objective, constraint, variable or cone name.
MSKrescodee MSK_getnameindex ( MSKtask_t task, MSKproblemiteme whichitem, MSKCONST char * name, MSKintt * asgn, MSKidxt * index);
MSKrescodee MSK_getnamelen64 ( MSKtask_t task, MSKproblemiteme whichitem, MSKidxt i, MSKint64t * len);
Obtains the maximum length (not including terminating zero character) of any objective, constraint, variable or cone name.
Obtains the name of a cone, a variable or a constraint.
Obtains the name of a cone, a variable or a constraint.
MSKrescodee MSK_getnastrparam ( MSKtask_t task, MSKCONST char * paramname, MSKCONST size_t maxlen, size_t * len, char * parvalue);
MSKrescodee MSK_getnastrparamal ( MSKtask_t task, MSKCONST char * paramname, MSKCONST size_t numaddchr, MSKstring_t * value);
MSKrescodee MSK_getnlfunc ( MSKtask_t task, MSKuserhandle_t * nlhandle, MSKnlgetspfunc * nlgetsp, MSKnlgetvafunc * nlgetva);
MSKrescodee MSK_getnumanz ( MSKtask_t task, MSKintt * numanz);
MSKrescodee MSK_getnumanz64 ( MSKtask_t task, MSKint64t * numanz);
MSKrescodee MSK_getnumcon ( MSKtask_t task, MSKintt * numcon);
MSKrescodee MSK_getnumcone ( MSKtask_t task, MSKintt * numcone);
MSKrescodee MSK_getnumconemem ( MSKtask_t task, MSKidxt k, MSKintt * nummem);
MSKrescodee MSK_getnumintvar ( MSKtask_t task, MSKintt * numintvar);
MSKrescodee MSK_getnumparam ( MSKtask_t task, MSKparametertypee partype, MSKintt * numparam);
MSKrescodee MSK_getnumqconknz ( MSKtask_t task, MSKidxt k, MSKintt * numqcnz);
MSKrescodee MSK_getnumqconknz64 ( MSKtask_t task, MSKidxt k, MSKint64t * numqcnz);
MSKrescodee MSK_getnumqobjnz ( MSKtask_t task, MSKintt * numqonz);
MSKrescodee MSK_getnumqobjnz64 ( MSKtask_t task, MSKint64t * numqonz);
MSKrescodee MSK_getnumvar ( MSKtask_t task, MSKintt * numvar);
MSKrescodee MSK_getobjname ( MSKtask_t task, MSKCONST size_t maxlen, size_t * len, char * objname);
MSKrescodee MSK_getobjname64 ( MSKtask_t task, MSKint64t maxlen, MSKint64t * len, char * objname);
MSKrescodee MSK_getobjsense ( MSKtask_t task, MSKobjsensee * sense);
Sets the objective sense.
MSKrescodee MSK_getparammax ( MSKtask_t task, MSKparametertypee partype, MSKCONST MSKintt * parammax);
MSKrescodee MSK_getparamname ( MSKtask_t task, MSKparametertypee partype, MSKintt param, char * parname);
MSKrescodee MSK_getpbi ( MSKtask_t task, MSKsoltypee whichsol, MSKaccmodee accmode, MSKCONST MSKidxt * sub, MSKintt len, MSKrealt * pbi, MSKintt normalize);
Obtains the primal bound infeasibility. If acmode is MSK_ACC_CON then
![]() |
(15.4.6) |
If acmode is MSK_ACC_VAR then
![]() |
(15.4.7) |
Obtains information about a solution.
MSKrescodee MSK_getpcni ( MSKtask_t task, MSKsoltypee whichsol, MSKCONST MSKidxt * sub, MSKintt len, MSKrealt * pcni);
Obtains information about a solution.
MSKrescodee MSK_getpeqi ( MSKtask_t task, MSKsoltypee whichsol, MSKCONST MSKidxt * sub, MSKintt len, MSKrealt * peqi, MSKintt normalize);
Obtains the primal equation infeasibility.
![]() |
(15.4.8) |
Obtains information about a solution.
MSKrescodee MSK_getprimalobj ( MSKtask_t task, MSKsoltypee whichsol, MSKrealt * primalobj);
MSKrescodee MSK_getprobtype ( MSKtask_t task, MSKproblemtypee * probtype);
MSKrescodee MSK_getqconk ( MSKtask_t task, MSKidxt k, MSKintt maxnumqcnz, MSKintt * qcsurp, MSKintt * numqcnz, MSKidxt * qcsubi, MSKidxt * qcsubj, MSKrealt * qcval);
MSKrescodee MSK_getqconk64 ( MSKtask_t task, MSKidxt k, MSKint64t maxnumqcnz, MSKint64t * qcsurp, MSKint64t * numqcnz, MSKidxt * qcsubi, MSKidxt * qcsubj, MSKrealt * qcval);
MSKrescodee MSK_getqobj ( MSKtask_t task, MSKintt maxnumqonz, MSKintt * qosurp, MSKintt * numqonz, MSKidxt * qosubi, MSKidxt * qosubj, MSKrealt * qoval);
MSKrescodee MSK_getqobj64 ( MSKtask_t task, MSKint64t maxnumqonz, MSKint64t * qosurp, MSKint64t * numqonz, MSKidxt * qosubi, MSKidxt * qosubj, MSKrealt * qoval);
MSKrescodee MSK_getqobjij ( MSKtask_t task, MSKidxt i, MSKidxt j, MSKrealt * qoij);
MSKrescodee MSK_getreducedcosts ( MSKtask_t task, MSKsoltypee whichsol, MSKidxt first, MSKidxt last, MSKrealt * redcosts);
Computes the reduced costs for a sequence of variables and return them in the variable redcosts i.e.
![]() |
(15.4.9) |
MSKrescodee MSK_getsolution ( MSKtask_t task, MSKsoltypee whichsol, MSKprostae * prosta, MSKsolstae * solsta, MSKstakeye * skc, MSKstakeye * skx, MSKstakeye * skn, MSKrealt * xc, MSKrealt * xx, MSKrealt * y, MSKrealt * slc, MSKrealt * suc, MSKrealt * slx, MSKrealt * sux, MSKrealt * snx);
Obtains the complete solution.
Consider the case of linear programming. The primal problem is given by
![]() |
(15.4.10) |
and the corresponding dual problem is
![]() |
(15.4.11) |
In this case the mapping between variables and arguments to the function is as follows:
xx: Corresponds to variable x.
y: Corresponds to variable y.
slc: Corresponds to variable .
suc: Corresponds to variable .
slx: Corresponds to variable .
sux: Corresponds to variable .
xc: Corresponds to Ax.
The meaning of the values returned by this function depend on the solution status returned in the argument solsta. The most important possible values of solsta are:
MSK_SOL_STA_OPTIMAL An optimal solution satisfying the optimality criteria for continuous problems is returned.
MSK_SOL_STA_INTEGER_OPTIMAL An optimal solution satisfying the optimality criteria for integer problems is returned.
MSK_SOL_STA_PRIM_FEAS A solution satisfying the feasibility criteria.
MSK_SOL_STA_PRIM_INFEAS_CER A primal certificate of infeasibility is returned.
MSK_SOL_STA_DUAL_INFEAS_CER A dual certificate of infeasibility is returned.
Obtains the solution for a single constraint or variable.
Obtains a slice of the solution.
MSKrescodee MSK_getsolutioni ( MSKtask_t task, MSKaccmodee accmode, MSKidxt i, MSKsoltypee whichsol, MSKstakeye * sk, MSKrealt * x, MSKrealt * sl, MSKrealt * su, MSKrealt * sn);
Obtains the complete solution.
Obtains a slice of the solution.
MSKrescodee MSK_getsolutionincallback ( MSKtask_t task, MSKcallbackcodee where, MSKsoltypee whichsol, MSKprostae * prosta, MSKsolstae * solsta, MSKstakeye * skc, MSKstakeye * skx, MSKstakeye * skn, MSKrealt * xc, MSKrealt * xx, MSKrealt * y, MSKrealt * slc, MSKrealt * suc, MSKrealt * slx, MSKrealt * sux, MSKrealt * snx);
Obtains the whole or a part of the solution from within a progress call-back. This function must only be called from a progress call-back function.
This is an experimental feature. Please contact MOSEK support before using this function.
MSKrescodee MSK_getsolutioninf ( MSKtask_t task, MSKsoltypee whichsol, MSKprostae * prosta, MSKsolstae * solsta, MSKrealt * primalobj, MSKrealt * maxpbi, MSKrealt * maxpcni, MSKrealt * maxpeqi, MSKrealt * maxinti, MSKrealt * dualobj, MSKrealt * maxdbi, MSKrealt * maxdcni, MSKrealt * maxdeqi);
Value of the primal objective.
![]() |
(15.4.12) |
Maximum infeasibility in primal bounds on variables.
![]() |
(15.4.13) |
Maximum infeasibility in primal equality constraints.
![]() |
(15.4.14) |
Maximum infeasibility in integer constraints.
![]() |
(15.4.15) |
Value of the dual objective.
![]() |
(15.4.16) |
Maximum infeasibility in bounds on dual variables.
![]() |
(15.4.17) |
Maximum infeasibility in the dual equality constraints.
![]() |
(15.4.18) |
Obtains information about the quality of a solution. Part of the following documentation is restricted to the linear case, it should be clear how to extend to other problem classes.
When optimizing MOSEK solves a reformulated problem with only equality constraints.
![]() |
(15.4.19) |
where
![]() |
and the corresponding dual problem is
![]() |
(15.4.20) |
The values returned by this function refers to these problems.
Please note that this function computes the objective value and other values every time it is called. Hence, for efficiency reasons this function should not be used too frequently.
If only the problem status or the solution status is required then use MSK_getsolutionstatus instead.
Obtains the primal equation infeasibility.
Optains the dual equation infeasibility.
Obtains the primal bound infeasibility.
Obtains the dual bound infeasibility.
Obtains the dual cone infeasibility.
Obtains the primal cone infeasibility.
Print information related to the quality of the solution.
Obtains information about the problem and solution statuses.
MSKrescodee MSK_getsolutionslice ( MSKtask_t task, MSKsoltypee whichsol, MSKsoliteme solitem, MSKidxt first, MSKidxt last, MSKrealt * values);
Obtains a slice of the solution.
Consider the case of linear programming. The primal problem is given by
![]() |
(15.4.21) |
and the corresponding dual problem is
![]() |
(15.4.22) |
The solitem argument determines which part of the solution is returned:
MSK_SOL_ITEM_XX: The variable values return x.
MSK_SOL_ITEM_Y: The variable values return y.
MSK_SOL_ITEM_SLC: The variable values return .
MSK_SOL_ITEM_SUC: The variable values return .
MSK_SOL_ITEM_SLX: The variable values return .
MSK_SOL_ITEM_SUX: The variable values return .
A conic optimization problem has the same primal variables as in the linear case. Recall that the dual of a conic optimization problem is given by:
![]() |
(15.4.23) |
This introduces one additional dual variable . This variable can be acceded by selecting solitem as MSK_SOL_ITEM_SNX.
The meaning of the values returned by this function also depends on the solution status which can be obtained with MSK_getsolutionstatus. Depending on the solution status value will be:
MSK_SOL_STA_OPTIMAL A part of the optimal solution satisfying the optimality criteria for continuous problems.
MSK_SOL_STA_INTEGER_OPTIMAL A part of the optimal solution satisfying the optimality criteria for integer problems.
MSK_SOL_STA_PRIM_FEAS A part of the solution satisfying the feasibility criteria.
MSK_SOL_STA_PRIM_INFEAS_CER A part of the primal certificate of infeasibility.
MSK_SOL_STA_DUAL_INFEAS_CER A part of the dual certificate of infeasibility.
Obtains the complete solution.
Obtains the solution for a single constraint or variable.
MSKrescodee MSK_getsolutionstatus ( MSKtask_t task, MSKsoltypee whichsol, MSKprostae * prosta, MSKsolstae * solsta);
MSKrescodee MSK_getsolutionstatuskeyslice ( MSKtask_t task, MSKaccmodee accmode, MSKsoltypee whichsol, MSKidxt first, MSKidxt last, MSKstakeye * sk);
Obtains the complete solution.
Obtains the solution for a single constraint or variable.
MSKrescodee MSK_getstrparam ( MSKtask_t task, MSKsparame param, MSKCONST size_t maxlen, size_t * len, char * parvalue);
MSKrescodee MSK_getstrparam64 ( MSKtask_t task, MSKsparame param, MSKint64t maxlen, MSKint64t * len, char * parvalue);
MSKrescodee MSK_getstrparamal ( MSKtask_t task, MSKsparame param, MSKCONST size_t numaddchr, MSKstring_t * value);
MSKrescodee MSK_getsymbcon ( MSKtask_t task, MSKidxt i, MSKCONST size_t maxlen, char * name, MSKintt * value);
MSKrescodee MSK_gettaskname ( MSKtask_t task, MSKCONST size_t maxlen, size_t * len, char * taskname);
MSKrescodee MSK_gettaskname64 ( MSKtask_t task, MSKint64t maxlen, MSKint64t * len, char * taskname);
MSKrescodee MSK_getvarbranchdir ( MSKtask_t task, MSKidxt j, MSKbranchdire * direction);
MSKrescodee MSK_getvarbranchorder ( MSKtask_t task, MSKidxt j, MSKintt * priority, MSKbranchdire * direction);
MSKrescodee MSK_getvarbranchpri ( MSKtask_t task, MSKidxt j, MSKintt * priority);
MSKrescodee MSK_getvarname ( MSKtask_t task, MSKidxt i, MSKCONST size_t maxlen, char * name);
Obtains the maximum length (not including terminating zero character) of any objective, constraint, variable or cone name.
MSKrescodee MSK_getvarname64 ( MSKtask_t task, MSKidxt i, MSKint64t maxlen, char * name);
Obtains the maximum length (not including terminating zero character) of any objective, constraint, variable or cone name.
MSKrescodee MSK_getvartype ( MSKtask_t task, MSKidxt j, MSKvariabletypee * vartype);
MSKrescodee MSK_getvartypelist ( MSKtask_t task, MSKintt num, MSKCONST MSKidxt * subj, MSKvariabletypee * vartype);
Obtains the variable type of one or more variables.
Upon return vartype[k] is the variable type of variable subj[k].
MSKrescodee MSK_initbasissolve ( MSKtask_t task, MSKidxt * basis);
The array of basis indexes to use.
The array is interpreted as follows: If , then
is in the basis at position i, otherwise
is in the basis at position i.
Prepare a task for use with the MSK_solvewithbasis function.
This function should be called
If the basis is singular i.e. not invertible, then the response code MSK_RES_ERR_BASIS_SINGULAR.
MSKrescodee MSK_inputdata ( MSKtask_t task, MSKintt maxnumcon, MSKintt maxnumvar, MSKintt numcon, MSKintt numvar, MSKCONST MSKrealt * c, MSKrealt cfix, MSKCONST MSKintt * aptrb, MSKCONST MSKintt * aptre, MSKCONST MSKidxt * asub, MSKCONST MSKrealt * aval, MSKCONST MSKboundkeye * bkc, MSKCONST MSKrealt * blc, MSKCONST MSKrealt * buc, MSKCONST MSKboundkeye * bkx, MSKCONST MSKrealt * blx, MSKCONST MSKrealt * bux);
Input the linear part of an optimization problem.
The non-zeros of A are inputted column-wise in the format described in Section 5.8.3.2.
For an explained code example see Section 5.2 and Section 5.8.3.
MSKrescodee MSK_inputdata64 ( MSKtask_t task, MSKintt maxnumcon, MSKintt maxnumvar, MSKintt numcon, MSKintt numvar, MSKCONST MSKrealt * c, MSKrealt cfix, MSKCONST MSKint64t * aptrb, MSKCONST MSKint64t * aptre, MSKCONST MSKidxt * asub, MSKCONST MSKrealt * aval, MSKCONST MSKboundkeye * bkc, MSKCONST MSKrealt * blc, MSKCONST MSKrealt * buc, MSKCONST MSKboundkeye * bkx, MSKCONST MSKrealt * blx, MSKCONST MSKrealt * bux);
Input the linear part of an optimization problem.
The non-zeros of A are inputted column-wise in the format described in Section 5.8.3.2.
For an explained code example see Section 5.2 and Section 5.8.3.
MSKrescodee MSK_isdouparname ( MSKtask_t task, MSKCONST char * parname, MSKdparame * param);
MSKrescodee MSK_isintparname ( MSKtask_t task, MSKCONST char * parname, MSKiparame * param);
MSKrescodee MSK_isstrparname ( MSKtask_t task, MSKCONST char * parname, MSKsparame * param);
MSKrescodee MSK_linkfiletotaskstream ( MSKtask_t task, MSKstreamtypee whichstream, MSKCONST char * filename, MSKintt append);
MSKrescodee MSK_linkfunctotaskstream ( MSKtask_t task, MSKstreamtypee whichstream, MSKuserhandle_t handle, MSKstreamfunc func);
MSKrescodee MSK_makesolutionstatusunknown ( MSKtask_t task, MSKsoltypee whichsol);
MSKrescodee MSK_netextraction ( MSKtask_t task, MSKintt * numcon, MSKintt * numvar, MSKidxt * netcon, MSKidxt * netvar, MSKrealt * scalcon, MSKrealt * scalvar, MSKrealt * cx, MSKboundkeye * bkc, MSKrealt * blc, MSKrealt * buc, MSKboundkeye * bkx, MSKrealt * blx, MSKrealt * bux, MSKidxt * from, MSKidxt * to);
Uses a heuristic to find an embedded network in the problem specified in task. The returned network is a pure network flow problem and can be solved with a direct call to the network optimizer MSK_netoptimize.
Each arc a in the network corresponds to a scaled subset of elements in column from the constraint matrix A stored in task. Each node n in the network corresponds to a scaled subset of elements in constraint i=netcon[n] from A. Data structures for network problems is explained in 5.2 and 6.6. The relation between A and the extracted embedded network can be explained as follows:
Please note if a column j=netvar[a] is only represented by one non-zero in the embedded network, then either from[a]=netcon or to[a]=netcon.
Optimizes a pure network flow problem.
MSKrescodee MSK_netoptimize ( MSKtask_t task, MSKintt numcon, MSKintt numvar, MSKCONST MSKrealt * cc, MSKCONST MSKrealt * cx, MSKCONST MSKboundkeye * bkc, MSKCONST MSKrealt * blc, MSKCONST MSKrealt * buc, MSKCONST MSKboundkeye * bkx, MSKCONST MSKrealt * blx, MSKCONST MSKrealt * bux, MSKCONST MSKidxt * from, MSKCONST MSKidxt * to, MSKprostae * prosta, MSKsolstae * solsta, MSKbooleant hotstart, MSKstakeye * skc, MSKstakeye * skx, MSKrealt * xc, MSKrealt * xx, MSKrealt * y, MSKrealt * slc, MSKrealt * suc, MSKrealt * slx, MSKrealt * sux);
Finds embedded network structure.
MSKrescodee MSK_optimize (MSKtask_t task)
Optimize a given task with several optimizers concurrently.
Obtains the complete solution.
Obtains the solution for a single constraint or variable.
Obtains information about a solution.
MSKrescodee MSK_optimizeconcurrent ( MSKtask_t task, MSKCONST MSKtask_t * taskarray, MSKintt num);
Solves several instances of the same problem in parallel, with unique parameter settings for each task. The argument task contains the problem to be solved. taskarray is a pointer to an array of num empty tasks. The task task and the num tasks pointed to by taskarray are solved in parallel. That is threads are started with one optimizer in each. Each of the tasks can be initialized with different parameters, e.g different selection of solver.
All the concurrently running tasks are stopped when the optimizer successfully terminates for one of the tasks. After the function returns task contains the solution found by the task that finished first.
After MSK_optimizeconcurrent returns task holds the optimal solution of the task which finished first. If all the concurrent optimizations finished without providing an optimal solution the error code from the solution of the task task is returned.
In summary a call to MSK_optimizeconcurrent does the following:
For an explained code example see Section 8.6.4.
MSKrescodee MSK_optimizersummary ( MSKtask_t task, MSKstreamtypee whichstream);
MSKrescodee MSK_optimizetrm ( MSKtask_t task, MSKrescodee * trmcode);
Calls the optimizer. Depending on the problem type and the selected optimizer this will call one of the optimizers in MOSEK. By default the interior point optimizer will be selected for continuous problems. The optimizer may be selected manually by setting the parameter MSK_IPAR_OPTIMIZER.
This function is equivalent to MSK_optimize except in the case where MSK_optimize would have returned a termination response code such as
Response codes comes in three categories:
This function returns errors on the left hand side. Warnings are not returned and termination codes are returned in the separate argument trmcode.
Optimizes the problem.
Optimize a given task with several optimizers concurrently.
Obtains the complete solution.
Obtains the solution for a single constraint or variable.
Obtains information about a solution.
MSKrescodee MSK_primalsensitivity ( MSKtask_t task, MSKintt numi, MSKCONST MSKidxt * subi, MSKCONST MSKmarke * marki, MSKintt numj, MSKCONST MSKidxt * subj, MSKCONST MSKmarke * markj, MSKrealt * leftpricei, MSKrealt * rightpricei, MSKrealt * leftrangei, MSKrealt * rightrangei, MSKrealt * leftpricej, MSKrealt * rightpricej, MSKrealt * leftrangej, MSKrealt * rightrangej);
Calculates sensitivity information for bounds on variables and constraints.
For details on sensitivity analysis and the definitions of shadow price and linearity interval see chapter 12.
The constraints for which sensitivity analysis is performed are given by the data structures:
Consider the problem:
![]() |
(15.4.24) |
Suppose that
numi = 1; subi = [0]; marki = [MSK_MARK_UP]
then
leftpricei[0], rightpricei[0], leftrangei[0] and rightrangei[0] will contain the sensitivity information for the upper bound on constraint 0 given by the expression:
![]() |
(15.4.25) |
Similarly, the variables for which to perform sensitivity analysis are given by the structures:
For an example, please see Section 12.5.
The type of sensitivity analysis to be performed (basis or optimal partition) is controlled by the parameter MSK_IPAR_SENSITIVITY_TYPE.
Performs sensitivity analysis on objective coefficients.
Creates a sensitivity report.
MSKrescodee MSK_printdata ( MSKtask_t task, MSKstreamtypee whichstream, MSKidxt firsti, MSKidxt lasti, MSKidxt firstj, MSKidxt lastj, MSKidxt firstk, MSKidxt lastk, MSKintt c, MSKintt qo, MSKintt a, MSKintt qc, MSKintt bc, MSKintt bx, MSKintt vartype, MSKintt cones);
MSKrescodee MSK_printparam (MSKtask_t task)
MSKrescodee MSK_probtypetostr ( MSKtask_t task, MSKproblemtypee probtype, char * str);
MSKrescodee MSK_prostatostr ( MSKtask_t task, MSKprostae prosta, char * str);
MSKrescodee MSK_putaij ( MSKtask_t task, MSKidxt i, MSKidxt j, MSKrealt aij);
Changes a coefficient in A using the method
![]() |
Replaces all elements in one row or column of the linear coefficient matrix.
Changes a single value in the linear coefficient matrix.
The function changes the size of the preallocated storage for linear coefficients.
MSKrescodee MSK_putaijlist ( MSKtask_t task, MSKintt num, MSKCONST MSKidxt * subi, MSKCONST MSKidxt * subj, MSKCONST MSKrealt * valij);
Changes one or more coefficients in A using the method
![]() |
If the same entry appears multiple times only the last one will be used.
Replaces all elements in one row or column of the linear coefficient matrix.
Changes a single value in the linear coefficient matrix.
The function changes the size of the preallocated storage for linear coefficients.
MSKrescodee MSK_putavec ( MSKtask_t task, MSKaccmodee accmode, MSKidxt i, MSKintt nzi, MSKCONST MSKidxt * asub, MSKCONST MSKrealt * aval);
Replaces all elements in one row or column of A.
Assuming that there are no duplicate subscripts in asub, assignment is performed as follows:
If accmode is MSK_ACC_CON, then
![]() |
and all other .
If accmode is MSK_ACC_VAR, then
![]() |
and all other .
If asub contains duplicates, the corresponding coefficients will be added together.
For an explanation of the meaning of ptrb and ptre see Section 5.8.3.2.
Replaces all elements in one row or column of the linear coefficient matrix.
Changes a single value in the linear coefficient matrix.
The function changes the size of the preallocated storage for linear coefficients.
MSKrescodee MSK_putaveclist ( MSKtask_t task, MSKaccmodee accmode, MSKintt num, MSKCONST MSKidxt * sub, MSKCONST MSKintt * ptrb, MSKCONST MSKintt * ptre, MSKCONST MSKidxt * asub, MSKCONST MSKrealt * aval);
Replaces all elements in a set of rows or columns of A.
The elements are replaced as follows.
If accmode is MSK_ACC_CON, then for
![]() |
If accmode is MSK_ACC_VAR, then for
![]() |
If the same row or column appears multiple times only the last one will be used.
Replaces all elements in one row or column of the linear coefficient matrix.
The function changes the size of the preallocated storage for linear coefficients.
MSKrescodee MSK_putaveclist64 ( MSKtask_t task, MSKaccmodee accmode, MSKintt num, MSKCONST MSKidxt * sub, MSKCONST MSKint64t * ptrb, MSKCONST MSKint64t * ptre, MSKCONST MSKidxt * asub, MSKCONST MSKrealt * aval);
Replaces all elements in a set of rows or columns of A.
The elements are replaced as follows.
If accmode is MSK_ACC_CON, then for
![]() |
If accmode is MSK_ACC_VAR, then for
![]() |
If the same row or column appears multiple times only the last one will be used.
Replaces all elements in one row or column of the linear coefficient matrix.
The function changes the size of the preallocated storage for linear coefficients.
MSKrescodee MSK_putbound ( MSKtask_t task, MSKaccmodee accmode, MSKidxt i, MSKboundkeye bk, MSKrealt bl, MSKrealt bu);
Changes the bounds for either one constraint or one variable.
If the a bound value specified is numerically larger than MSK_DPAR_DATA_TOL_BOUND_INF it is considered infinite and the bound key is changed accordingly. If a bound value is numerically larger than MSK_DPAR_DATA_TOL_BOUND_WRN, a warning will be displayed, but the bound is inputted as specified.
Changes the bounds of constraints or variables.
MSKrescodee MSK_putboundlist ( MSKtask_t task, MSKaccmodee accmode, MSKintt num, MSKCONST MSKidxt * sub, MSKCONST MSKboundkeye * bk, MSKCONST MSKrealt * bl, MSKCONST MSKrealt * bu);
Changes the bound for either one constraint or one variable.
MSKrescodee MSK_putboundslice ( MSKtask_t task, MSKaccmodee con, MSKidxt first, MSKidxt last, MSKCONST MSKboundkeye * bk, MSKCONST MSKrealt * bl, MSKCONST MSKrealt * bu);
Changes the bound for either one constraint or one variable.
MSKrescodee MSK_putcallbackfunc ( MSKtask_t task, MSKcallbackfunc func, MSKuserhandle_t handle);
MSKrescodee MSK_putcfix ( MSKtask_t task, MSKrealt cfix);
MSKrescodee MSK_putcj ( MSKtask_t task, MSKidxt j, MSKrealt cj);
Modifies one coefficient in the linear objective vector c, i.e.
![]() |
MSKrescodee MSK_putclist ( MSKtask_t task, MSKintt num, MSKCONST MSKidxt * subj, MSKCONST MSKrealt * val);
Modifies elements in the linear term c in the objective using the principle
![]() |
If a variable index is specified multiple times in subj only the last entry is used.
MSKrescodee MSK_putcone ( MSKtask_t task, MSKidxt k, MSKconetypee conetype, MSKrealt conepar, MSKintt nummem, MSKCONST MSKidxt * submem);
MSKrescodee MSK_putdouparam ( MSKtask_t task, MSKdparame param, MSKrealt parvalue);
MSKrescodee MSK_putintparam ( MSKtask_t task, MSKiparame param, MSKintt parvalue);
MSKrescodee MSK_putmaxnumanz ( MSKtask_t task, MSKintt maxnumanz);
MOSEK stores only the non-zero elements in A. Therefore, MOSEK cannot predict how much storage is required to store A. Using this function it is possible to specify the number of non-zeros to preallocate for storing A.
If the number of non-zeros in the problem is known, it is a good idea to set maxnumanz slightly larger than this number, otherwise a rough estimate can be used. In general, if A is inputted in many small chunks, setting this value may speed up the the data input phase.
It is not mandatory to call this function, since MOSEK will reallocate internal structures whenever it is necessary.
MSKrescodee MSK_putmaxnumanz64 ( MSKtask_t task, MSKint64t maxnumanz);
MSKrescodee MSK_putmaxnumcon ( MSKtask_t task, MSKintt maxnumcon);
Sets the number of preallocated constraints in the optimization task. When this number of constraints is reached MOSEK will automatically allocate more space for constraints.
It is never mandatory to call this function, since MOSEK will reallocate any internal structures whenever it is required.
Please note that maxnumcon must be larger than the current number of constraints in the task.
MSKrescodee MSK_putmaxnumcone ( MSKtask_t task, MSKintt maxnumcone);
Sets the number of preallocated conic constraints in the optimization task. When this number of conic constraints is reached MOSEK will automatically allocate more space for conic constraints.
It is never mandatory to call this function, since MOSEK will reallocate any internal structures whenever it is required.
Please note that maxnumcon must be larger than the current number of constraints in the task.
MSKrescodee MSK_putmaxnumqnz ( MSKtask_t task, MSKintt maxnumqnz);
MOSEK stores only the non-zero elements in Q. Therefore, MOSEK cannot predict how much storage is required to store Q. Using this function it is possible to specify the number non-zeros to preallocate for storing Q (both objective and constraints).
It may be advantageous to reserve more non-zeros for Q than actually needed since it may improve the internal efficiency of MOSEK, however, it is never worthwhile to specify more than the double of the anticipated number of non-zeros in Q.
It is never mandatory to call this function, since its only function is to give a hint of the amount of data to preallocate for efficiency reasons.
MSKrescodee MSK_putmaxnumqnz64 ( MSKtask_t task, MSKint64t maxnumqnz);
MOSEK stores only the non-zero elements in Q. Therefore, MOSEK cannot predict how much storage is required to store Q. Using this function it is possible to specify the number non-zeros to preallocate for storing Q (both objective and constraints).
It may be advantageous to reserve more non-zeros for Q than actually needed since it may improve the internal efficiency of MOSEK, however, it is never worthwhile to specify more than the double of the anticipated number of non-zeros in Q.
It is never mandatory to call this function, since its only function is to give a hint of the amount of data to preallocate for efficiency reasons.
MSKrescodee MSK_putmaxnumvar ( MSKtask_t task, MSKintt maxnumvar);
Sets the number of preallocated variables in the optimization task. When this number of variables is reached MOSEK will automatically allocate more space for variables.
It is never mandatory to call this function, since its only function is to give a hint of the amount of data to preallocate for efficiency reasons.
Please note that maxnumvar must be larger than the current number of variables in the task.
MSKrescodee MSK_putnadouparam ( MSKtask_t task, MSKCONST char * paramname, MSKrealt parvalue);
MSKrescodee MSK_putnaintparam ( MSKtask_t task, MSKCONST char * paramname, MSKintt parvalue);
MSKrescodee MSK_putname ( MSKtask_t task, MSKproblemiteme whichitem, MSKidxt i, MSKCONST char * name);
MSKrescodee MSK_putnastrparam ( MSKtask_t task, MSKCONST char * paramname, MSKCONST char * parvalue);
MSKrescodee MSK_putnlfunc ( MSKtask_t task, MSKuserhandle_t nlhandle, MSKnlgetspfunc nlgetsp, MSKnlgetvafunc nlgetva);
MSKrescodee MSK_putobjname ( MSKtask_t task, MSKCONST char * objname);
MSKrescodee MSK_putobjsense ( MSKtask_t task, MSKobjsensee sense);
Gets the objective sense.
MSKrescodee MSK_putparam ( MSKtask_t task, MSKCONST char * parname, MSKCONST char * parvalue);
MSKrescodee MSK_putqcon ( MSKtask_t task, MSKintt numqcnz, MSKCONST MSKidxt * qcsubk, MSKCONST MSKidxt * qcsubi, MSKCONST MSKidxt * qcsubj, MSKCONST MSKrealt * qcval);
Replaces all quadratic entries in the constraints. Consider constraints on the form:
![]() |
(15.4.26) |
The function assigns values to q such that:
![]() |
(15.4.27) |
and
![]() |
(15.4.28) |
Values not assigned are set to zero.
Please note that duplicate entries are added together.
Replaces all quadratic terms in a single constraint.
Changes the size of the preallocated storage for quadratic terms.
MSKrescodee MSK_putqconk ( MSKtask_t task, MSKidxt k, MSKintt numqcnz, MSKCONST MSKidxt * qcsubi, MSKCONST MSKintt * qcsubj, MSKCONST MSKrealt * qcval);
Replaces all the quadratic entries in one constraint k of the form:
![]() |
(15.4.29) |
It is assumed that is symmetric, i.e.
, and therefore, only the values of
for which i≥j should be inputted to MOSEK. To be precise, MOSEK uses the following procedure
![]() |
Please note that:
For a code example see Section 5.3.2.
Replaces all quadratic terms in constraints.
Changes the size of the preallocated storage for quadratic terms.
MSKrescodee MSK_putqobj ( MSKtask_t task, MSKintt numqonz, MSKCONST MSKidxt * qosubi, MSKCONST MSKidxt * qosubj, MSKCONST MSKrealt * qoval);
Replaces all the quadratic terms in the objective
![]() |
(15.4.30) |
It is assumed that is symmetric, i.e.
, and therefore, only the values of
for which i≥j should be specified. To be precise, MOSEK uses the following procedure
![]() |
Please note that:
For a code example see Section 5.3.1.
MSKrescodee MSK_putqobjij ( MSKtask_t task, MSKidxt i, MSKidxt j, MSKrealt qoij);
Replaces one coefficient in the quadratic term in the objective. The function performs the assignment
![]() |
Only the elements in the lower triangular part are accepted. Setting with j>i will cause an error.
Please note that replacing all quadratic element, one at a time, is more computationally expensive than replacing all elements at once. Use MSK_putqobj instead whenever possible.
MSKrescodee MSK_putresponsefunc ( MSKtask_t task, MSKresponsefunc responsefunc, MSKuserhandle_t handle);
MSKrescodee MSK_putsolution ( MSKtask_t task, MSKsoltypee whichsol, MSKCONST MSKstakeye * skc, MSKCONST MSKstakeye * skx, MSKCONST MSKstakeye * skn, MSKCONST MSKrealt * xc, MSKCONST MSKrealt * xx, MSKCONST MSKrealt * y, MSKCONST MSKrealt * slc, MSKCONST MSKrealt * suc, MSKCONST MSKrealt * slx, MSKCONST MSKrealt * sux, MSKCONST MSKrealt * snx);
MSKrescodee MSK_putsolutioni ( MSKtask_t task, MSKaccmodee accmode, MSKidxt i, MSKsoltypee whichsol, MSKstakeye sk, MSKrealt x, MSKrealt sl, MSKrealt su, MSKrealt sn);
Sets the primal and dual solution information for a single constraint or variable.
To define a solution or a significant part of a solution, first call the MSK_makesolutionstatusunknown function, then for each relevant constraint and variable call MSK_putsolutioni to set the solution information.
Sets the solution status to unknown.
MSKrescodee MSK_putsolutionyi ( MSKtask_t task, MSKidxt i, MSKsoltypee whichsol, MSKrealt y);
Sets the solution status to unknown.
Sets the primal and dual solution information for a single constraint or variable.
MSKrescodee MSK_putstrparam ( MSKtask_t task, MSKsparame param, MSKCONST char * parvalue);
MSKrescodee MSK_puttaskname ( MSKtask_t task, MSKCONST char * taskname);
MSKrescodee MSK_putvarbranchorder ( MSKtask_t task, MSKidxt j, MSKintt priority, int direction);
MSKrescodee MSK_putvartype ( MSKtask_t task, MSKidxt j, MSKvariabletypee vartype);
Sets the variable type for one or more variables.
MSKrescodee MSK_putvartypelist ( MSKtask_t task, MSKintt num, MSKCONST MSKidxt * subj, MSKCONST MSKvariabletypee * vartype);
Sets the variable type for one or more variables, i.e. variable number is assigned the variable type
.
If the same index is specified multiple times in subj only the last entry takes effect.
Sets the variable type of one variable.
MSKrescodee MSK_readbranchpriorities ( MSKtask_t task, MSKCONST char * filename);
Writes branching priority data to a file.
MSKrescodee MSK_readdata ( MSKtask_t task, MSKCONST char * filename);
Reads an optimization data and associated data from a file.
The data file format is determined by the MSK_IPAR_READ_DATA_FORMAT parameter. By default the parameter has the value MSK_DATA_FORMAT_EXTENSION indicating that the extension of the input file should determine the file type, where the extension is interpreted as follows:
Writes problem data to a file.
MSKrescodee MSK_readparamfile (MSKtask_t task)
MSKrescodee MSK_readsolution ( MSKtask_t task, MSKsoltypee whichsol, MSKCONST char * filename);
MSKrescodee MSK_readsummary ( MSKtask_t task, MSKstreamtypee whichstream);
MSKrescodee MSK_relaxprimal ( MSKtask_t task, MSKtask_t * relaxedtask, MSKrealt * wlc, MSKrealt * wuc, MSKrealt * wlx, MSKrealt * wux);
Creates a problem that computes the minimal (weighted) relaxation of the bounds that will make an infeasible problem feasible.
Given an existing task describing the problem
![]() |
(15.4.31) |
the function forms a new task relaxedtask having the form
![]() |
(15.4.32) |
Hence, the function adds so-called elasticity variables to all the constraints which relax the constraints, for instance and
relax
and
respectively. It should be obvious that (15.4.32) is feasible. Moreover, the function adds the constraint
![]() |
to the problem which makes the variable p bigger than the total weighted sum of the relaxation to the bounds. ,
,
and
are user-defined weights which normally should be nonnegative. If a weight is negative, then the corresponding elasticity variable is fixed to zero.
Hence, when the problem (15.4.32) is optimized, the weighted minimal change to the bounds such that the problem is feasible is computed.
One can specify that a bound should be strictly enforced by assigning a negative value to the corresponding weight, i.e if then
is fixed to zero.
Now let be the optimal objective value to (15.4.32), then a natural thing to do is to solve the optimization problem
![]() |
(15.4.33) |
where the original objective function is minimized subject to the constraint that the total weighted relaxation is minimal.
The parameter MSK_IPAR_FEASREPAIR_OPTIMIZE controls whether the function returns the problem (15.4.32) or the problem (15.4.33).The parameter can take one of the following values.
: The returned task relaxedtask contains problem (15.4.32) and is not optimized.
: The returned task relaxedtask contains problem (15.4.32) and is optimized.
: The returned task relaxedtask contains problem (15.4.33) and is optimized.
Please note that the v variables are appended to the x variables ordered as
![]() |
in the returned task.
If NAME_CON (NAME_VAR) is the name of the ith constraint (variable) then the new variables are named as follows:
where “*” can be replaced by a user-defined string by setting the MSK_SPAR_FEASREPAIR_NAME_SEPARATOR parameter.
Please note that if or
then the feasibility repair problem becomes infeasible. Such trivial conflicts must therefore be removed manually before using MSK_relaxprimal.
The above discussion shows how the function works for a linear optimization problem. However, the function also works for quadratic and conic optimization problems but it cannot be used for general nonlinear optimization problems.
MSKrescodee MSK_remove ( MSKtask_t task, MSKaccmodee accmode, MSKintt num, MSKCONST MSKintt * sub);
Appends a number of variables or constraints to the optimization task.
MSKrescodee MSK_removecone ( MSKtask_t task, MSKidxt k);
Removes a conic constraint from the problem. This implies that all the conic constraints appearing after cone number k are renumbered, decresing their indexes by one.
In general, it is much more efficient to remove a cone with a high index than a low index.
MSKrescodee MSK_resizetask ( MSKtask_t task, MSKintt maxnumcon, MSKintt maxnumvar, MSKintt maxnumcone, MSKintt maxnumanz, MSKintt maxnumqnz);
Sets the amount of preallocated space assigned for each type of data in an optimization task.
It is never mandatory to call this function, since its only function is to give a hint of the amount of data to preallocate for efficiency reasons.
Please note that the procedure is destructive in the sense that all existing data stored in the task is destroyed.
Sets the number of preallocated variables in the optimization task.
Sets the number of preallocated constraints in the optimization task.
Sets the number of preallocated conic constraints in the optimization task.
The function changes the size of the preallocated storage for linear coefficients.
Changes the size of the preallocated storage for quadratic terms.
MSKrescodee MSK_sensitivityreport ( MSKtask_t task, MSKstreamtypee whichstream);
Performs sensitivity analysis on objective coefficients.
Perform sensitivity analysis on bounds.
MSKrescodee MSK_setdefaults (MSKtask_t task)
MSKrescodee MSK_sktostr ( MSKtask_t task, MSKintt sk, char * str);
MSKrescodee MSK_solstatostr ( MSKtask_t task, MSKsolstae solsta, char * str);
MSKrescodee MSK_solutiondef ( MSKtask_t task, MSKsoltypee whichsol, MSKintt * isdef);
MSKrescodee MSK_solutionsummary ( MSKtask_t task, MSKstreamtypee whichstream);
MSKrescodee MSK_solvewithbasis ( MSKtask_t task, MSKintt transp, MSKintt * numnz, MSKidxt * sub, MSKrealt * val);
As input it contains the positions of the non-zeros in b, i.e.
![]() |
As output it contains the positions of the non-zeros in . It is important that sub has room for numcon elements.
As input it is the vector b. Although the positions of the non-zero elements are specified in sub it is required that if b[i]=0. As output val is the vector
.
Please note that val is a dense vector — not a packed sparse vector. This implies that val has room for numcon elements.
If a basic solution is available, then exactly basis variables are defined. These
basis variables are denoted the basis. Associated with the basis is a basis matrix denoted B. This function solves either the linear equation system
![]() |
(15.4.34) |
or the system
![]() |
(15.4.35) |
for the unknowns , with b being a user-defined vector.
In order to make sense of the solution it is important to know the ordering of the variables in the basis because the ordering specifies how B is constructed. When calling MSK_initbasissolve an ordering of the basis variables is obtained, whicd can be used to deduce how MOSEK has constructed B. Indeed if the kth basis variable is variable
it implies that
![]() |
Otherwise if the kth basis variable is variable it implies that`
![]() |
Given the knowledge of how B is constructed it is possible to interpret the solution correctly.
Please note that this function exploits the sparsity in the vector b to speed up the computations.
Prepare a task for basis solver.
char * MSK_strdupdbgtask ( MSKtask_t task, MSKCONST char * str, MSKCONST char * file, MSKCONST unsigned line);
char * MSK_strduptask ( MSKtask_t task, MSKCONST char * str);
MSKrescodee MSK_strtoconetype ( MSKtask_t task, MSKCONST char * str, MSKconetypee * conetype);
MSKrescodee MSK_strtosk ( MSKtask_t task, MSKCONST char * str, MSKintt * sk);
MSKrescodee MSK_undefsolution ( MSKtask_t task, MSKsoltypee whichsol);
MSKrescodee MSK_unlinkfuncfromtaskstream ( MSKtask_t task, MSKstreamtypee whichstream);
MSKrescodee MSK_whichparam ( MSKtask_t task, MSKCONST char * parname, MSKparametertypee * partype, MSKintt * param);
MSKrescodee MSK_writebranchpriorities ( MSKtask_t task, MSKCONST char * filename);
Reads branching priority data from a file.
MSKrescodee MSK_writedata ( MSKtask_t task, MSKCONST char * filename);
Writes problem data associated with the optimization task to a file in one of four formats:
LP : A text based row oriented format. File extension .lp. See Appendix D.
MPS : A text based column oriented format. File extension .mps. See Appendix C.
OPF : A text based row oriented format. File extension .opf. Supports more problem types than MPS and LP. See Appendix E.
MBT : A binary format for fast reading and writing. File extension .mbt.
By default the data file format is determined by the file name extension. This behaviour can be overridden by setting the MSK_IPAR_WRITE_DATA_FORMAT parameter.
MOSEK is able to read and write files in a compressed format (gzip). To write in the compressed format append the extension ".gz". E.g to write a gzip compressed MPS file use the extension mps.gz.
Please note that MPS, LP and OPF files require all variables to have unique names. If a task contains no names, it is possible to write the file with automaticly generated anonymous names by setting the MSK_IPAR_WRITE_GENERIC_NAMES parameter to MSK_ON.
Reads problem data from a file.
MSKrescodee MSK_writeparamfile ( MSKtask_t task, MSKCONST char * filename);
MSKrescodee MSK_writesolution ( MSKtask_t task, MSKsoltypee whichsol, MSKCONST char * filename);