This chapter lists all functionality in the MOSEK .NET API.
Functions in the interface grouped by functionality.
Analyzing the problem and associated data.
mosek.Task.analyzeproblem
Analyze the data of a task.
mosek.Task.analyzesolution
Print information related to the quality of the solution.
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.writebranchpriorities
Writes branching priority data to a file.
mosek.Task.writedata
Writes problem data to a file.
mosek.Task.writeparamfile
Writes all the parameters to a parameter file.
mosek.Task.writesolution
Write a solution to a file.
Obtain or define a solution.
mosek.Task.deletesolution
Undefines a solution and frees the memory it uses.
mosek.Task.getdbi
Obtains the dual bound infeasibility.
mosek.Task.getdcni
Obtains the dual cone infeasibility.
mosek.Task.getdeqi
Optains the dual equation infeasibility.
mosek.Task.getdualobj
Obtains the dual objective value.
mosek.Task.getinti
Obtains the primal equation infeasibility.
mosek.Task.getpbi
Obtains the primal bound infeasibility.
mosek.Task.getpcni
Obtains the primal cone infeasibility.
mosek.Task.getpeqi
Obtains the primal equation infeasibility.
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.optimizersummary
Prints a short summary with optimizer statistics for last optimization.
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.solstatostr
Obtains a solution status string.
mosek.Task.solutiondef
Checks whether a solution is defined.
mosek.Task.solutionsummary
Prints a short summary of the current solutions.
mosek.Task.undefsolution
Undefines a solution.
Memory allocation and deallocation.
mosek.Task.checkmem
Checks the memory allocated by the task.
mosek.Task.getmemusage
Obtains information about the amount of memory used by a task.
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.Env.checkoutlicense
Check out a license feature from the license server ahead of time.
mosek.Task.chgbound
Changes the bounds for one constraint or variable.
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.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 the linear constraint matrix.
mosek.Task.putavec
Replaces all elements in one row or column of the linear coefficient matrix.
mosek.Task.putaveclist
Replaces all elements in one or more rows or columns in the linear constraint matrix by new values.
mosek.Task.putaveclist
Replaces all elements in one or more rows or columns in the linear constraint matrix 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 the linear objective coefficients.
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 coefficient 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.
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.
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.
Functionality for inspecting the problem specification (A,Q, bounds, objective e.t.c).
mosek.Task.getaij
Obtains a single coefficient in linear constraint matrix.
mosek.Task.getaslice
Obtains a sequence of rows or columns from the coefficient matrix.
mosek.Task.getaslice
Obtains a sequence of rows or columns from the coefficient matrix.
mosek.Task.getaslicetrip
Obtains a sequence of rows or columns from the coefficient matrix in triplet format.
mosek.Task.getavec
Obtains one row or column of the linear constraint matrix.
mosek.Task.getavecnumnz
Obtains the number of non-zero elements in one row or column of the linear constraint matrix
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.
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 sequence of coefficients from the objective.
mosek.Task.getintpntnumthreads
Obtains the number of threads used by the interior-point optimizer.
mosek.Task.getnumanz
Obtains the number of non-zeros in the coefficient matrix.
mosek.Task.getnumanz64
Obtains the number of non-zeros in the coefficient matrix.
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.getnumqconknz
Obtains the number of non-zero quadratic terms in a constraint.
mosek.Task.getnumqconknz64
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.getnumqobjnz64
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.getqconk64
Obtains all the quadratic terms in a constraint.
mosek.Task.getqobj
Obtains all the quadratic terms in the objective.
mosek.Task.getqobj64
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.
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.
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.
Error handling.
mosek.Env.getcodedesc
Obtains a short description of a response code.
mosek.Env.getcodedisc
Obtains a short description of a response code.
Output stream functions.
mosek.Env.echointro
Prints an intro to message stream.
mosek.Env.linkfiletostream
Directs all output from a stream to a file.
mosek.Task.linkfiletostream
Directs all output from a task stream to a file.
mosek.Task.optimizersummary
Prints a short summary with optimizer statistics for last optimization.
mosek.Task.printdata
Prints a part of the problem data to a stream.
mosek.Task.readsummary
Prints information about last file read.
mosek.Task.solutionsummary
Prints a short summary of the current solutions.
Change or inspect objective function.
mosek.Task.getc
Obtains all objective coefficients.
mosek.Task.getcfix
Obtains the fixed term in the objective.
mosek.Task.getcslice
Obtains a sequence of coefficients from the objective.
mosek.Task.getdualobj
Obtains the dual objective value.
mosek.Task.getnumqobjnz
Obtains the number of non-zero quadratic terms in the objective.
mosek.Task.getnumqobjnz64
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.getqobj64
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 the linear objective coefficients.
mosek.Task.putobjsense
Sets the objective sense.
mosek.Task.putqobj
Replaces all quadratic terms in the objective.
mosek.Task.putqobjij
Replaces one coefficient in the quadratic term in the objective.
Inspect statistics from the optimizer.
mosek.Task.getdouinf
Obtains a double information item.
mosek.Task.getinfindex
Obtains the index of a named information item.
mosek.Task.getintinf
Obtains an integer information item.
mosek.Task.getlintinf
Obtains an integer information item.
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.Env.iparvaltosymnam
Obtains the symbolic name corresponding to a value that can be assigned to an integer parameter.
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.
Functionality related to naming.
mosek.Task.getconname
Obtains a name of a constraint.
mosek.Task.getname
Obtains the name of a cone, a variable or a constraint.
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.getnamelen
Obtains the length of a problem item name.
mosek.Task.getobjname
Obtains the name assigned to the objective function.
mosek.Task.gettaskname64
Obtains the task name.
mosek.Task.getvarname
Obtains a name of a variable.
mosek.Task.putname
Assigns a name to a problem item.
mosek.Task.putobjname
Assigns a new name to the objective.
mosek.Task.puttaskname
Assigns a new name to the task.
Functionality related to preallocating space for problem data.
mosek.Task.getmaxnumanz
Obtains number of preallocated non-zeros in the linear constraint matrix.
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 all quadratic terms in 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.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 quadratic terms.
mosek.Task.putmaxnumqnz
Changes the size of the preallocated storage for quadratic terms.
mosek.Task.putmaxnumvar
Sets the number of preallocated variables in the optimization task.
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.getvarbranchorder
Obtains the branching priority 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.
Functionality related to quadratic terms.
mosek.Task.getqconk
Obtains all the quadratic terms in a constraint.
mosek.Task.getqconk64
Obtains all the quadratic terms in a constraint.
mosek.Task.getqobj
Obtains all the quadratic terms in the objective.
mosek.Task.getqobj64
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 coefficient in the quadratic term in the objective.
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.
Functions for optimization.
mosek.Task.checkdata
Checks data of the task.
mosek.Task.netoptimize
Optimizes a pure network flow problem.
mosek.Task.optimizeconcurrent
Optimize a given task with several optimizers concurrently.
mosek.Task.optimize
Optimizes the problem.
Functions for network optimization.
mosek.Task.netextraction
Finds embedded network structure.
mosek.Task.netoptimize
Optimizes a pure network flow problem.
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.
Functions for testing data validity.
mosek.Task.checkconvexity
Checks if a quadratic optimization problem is convex.
Functions for solving linear systems with the basis matrix.
mosek.Task.basiscond
Computes conditioning information for the basis matrix.
mosek.Task.initbasissolve
Prepare a task for basis solver.
mosek.Task.solvewithbasis
Solve a linear equation system involving a basis matrix.
Creation and initialization of environment.
mosek.Env.checkinlicense
Check in a license feature from the license server ahead of time.
mosek.Env.init
Initialize a MOSEK environment.
mosek.Env.putlicensedefaults
Set defaults used by the license manager.
Change elements in the coefficient (A) matrix.
mosek.Env.checkoutlicense
Check out a license feature from the license server ahead of time.
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 the linear constraint matrix.
mosek.Task.putavec
Replaces all elements in one row or column of the linear coefficient matrix.
mosek.Task.putaveclist
Replaces all elements in one or more rows or columns in the linear constraint matrix by new values.
mosek.Task.putaveclist
Replaces all elements in one or more rows or columns in the linear constraint matrix by new values.
System.Exception
This exception is raised is an input or output array was shorter than required.
A Mosek Environment
public Env ()
public Env (string dbgfile)
public void checkinlicense (feature 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 mosek.Task.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.
public void checkoutlicense (feature 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 mosek.Task.optimizetrm. This function can be used to check out one or more features ahead of time.
The license will remain checked out for the lifetime of the MOSEK environment or until the function mosek.Env.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.
public void echointro (int longver)
public void getbuildinfo ( StringBuilder buildstate, StringBuilder builddate, StringBuilder buildtool);
public void getcodedesc ( rescode code, StringBuilder symname, StringBuilder str);
public void getcodedisc ( rescode code, StringBuilder symname, StringBuilder str);
public void getversion ( out int major, out int minor, out int build, out int revision);
public void init ()
public void iparvaltosymnam ( iparam whichparam, int whichvalue, StringBuilder symbolicname);
public void linkfiletostream ( streamtype whichstream, string filename, int append);
public void putcpudefaults ( int cputype, int sizel1, int sizel2);
public void putdllpath (string dllpath)
public void putkeepdlls (int keepdlls)
public void putlicensedefaults ( string licensefile, int[] licensebuf, int licwait, int licdebug);
public void set_Stream ( streamtype whichstream, Stream stream);
mosek.Exception
This is an exception class representing MOSEK errors.
public Error (rescode code)
public Error ( rescode code, string msg);
System.Exception
This is the base class for exceptions based on MOSEK response codes.
public Exception (rescode code)
mosek.Callback
This is the base class for user-defined progress call-back objects. An object of this type can be attached to a MOSEK task in order to receive frequent calls with a progress indicator during long optimizations. The calls are received by overriding a certain member of this class.
The call-back method is called at the beginning of each iteration in the interior-point optimizer. For the simplex optimizers the parameter mosek.iparam.log_sim_freq controls how frequent the call-backs are.
Typically, the user-defined call-back method displays information about the solution process. The call-back function can also be used to terminate the optimization process: If the method returns a non-zero value when called, MOSEK will abort optimization and perform proper cleanup of the task.
It is important that the user-defined call-back function does not modify the optimization task, this will lead to undefined behavior and incorrect results. The only MOSEK functions that can be called safely from within the user-defined call-back function are mosek.Task.getdouinf and mosek.Task.getintinf which access the task information database. The items in task information database are updated during the optimization process.
public Progress ()
public CType(int) progress (callbackcode caller)
mosek.Callback
Base class for stream printer classes which can be attached to MOSEK tasks and environments to intercept output.
public Stream ()
A Mosek Optimization task
public Task ( Env env, int maxnumcon, int maxnumvar);
public void analyzeproblem (streamtype whichstream)
public void analyzesolution ( streamtype whichstream, soltype 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.
public void append ( accmode accmode, int num);
The function removes a number of constraints or variables.
public void appendcone ( conetype conetype, double conepar, int[] submem);
public void appendcone ( conetype conetype, double conepar, int nummem, int[] 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 (mosek.conetype.quad) or rotated quadratic cone (mosek.conetype.rquad). Define
![]() |
. Depending on the value of conetype this function appends one of the constraints:
Quadratic cone (mosek.conetype.quad) :
![]() |
Rotated quadratic cone (mosek.conetype.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.
public void basiscond ( out double nrmbasis, out double 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
.
public void checkconvexity ()
This function checks if a quadratic optimization problem is convex. The amount of checking is controlled by mosek.iparam.check_convexity.
The function throws an exception if the problem is not convex.
public void checkdata ()
public void checkmem ( string file, int line);
public void chgbound ( accmode accmode, int i, int lower, int finite, double value);
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:
![]() |
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.
public void commitchanges ()
public void deletesolution (soltype whichsol)
public void dualsensitivity ( int[] subj, double[] leftpricej, double[] rightpricej, double[] leftrangej, double[] 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 mosek.iparam.sensitivity_type.
For an example, please see Section 12.5.
Perform sensitivity analysis on bounds.
Creates a sensitivity report.
public double getaij ( int i, int j);
public void getaij ( int i, int j, out double aij);
public int getapiecenumnz ( int firsti, int lasti, int firstj, int lastj);
public void getapiecenumnz ( int firsti, int lasti, int firstj, int lastj, out int 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 mosek.Task.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.
public void getaslice ( accmode accmode, int first, int last, ref int surp, int[] ptrb, int[] ptre, int[] sub, double[] val);
Obtains the number of non-zeros in a row or column slice of the coefficient matrix.
public void getaslice ( accmode accmode, int first, int last, ref long surp, long[] ptrb, long[] ptre, int[] sub, double[] val);
Obtains the number of non-zeros in a slice of rows or columns of the coefficient matrix.
public void getaslicenumnz ( accmode accmode, int first, int last, out int numnz);
public long getaslicenumnz ( accmode accmode, int first, int last);
public void getaslicenumnz ( accmode accmode, int first, int last, out long numnz);
public void getaslicetrip ( accmode accmode, int first, int last, ref int surp, int[] subi, int[] subj, double[] val);
Obtains the number of non-zeros in a row or column slice of the coefficient matrix.
public void getavec ( accmode accmode, int i, out int nzi, int[] subi, double[] vali);
Obtains one row or column of A in a sparse format. If accmode equals mosek.accmode.con a row is returned and hence:
![]() |
If accmode equals mosek.accmode.var a column is returned, that is:
![]() |
public int getavecnumnz ( accmode accmode, int i);
public void getavecnumnz ( accmode accmode, int i, out int nzj);
public void getbound ( accmode accmode, int i, out boundkey bk, out double bl, out double bu);
public void getboundslice ( accmode accmode, int first, int last, boundkey[] bk, double[] bl, double[] bu);
public void getc (double[] c)
public double getcfix ()
public void getcfix (out double cfix)
public void getcone ( int k, out conetype conetype, out double conepar, out int nummem, int[] submem);
public void getconeinfo ( int k, out conetype conetype, out double conepar, out int nummem);
public string getconname (int i)
public void getconname ( int i, StringBuilder name);
public void getcslice ( int first, int last, double[] c);
public void getdbi ( soltype whichsol, accmode accmode, int[] sub, double[] dbi);
Dual bound infeasibility. If acmode is mosek.accmode.con then
![]() |
(15.9.1) |
else
![]() |
(15.9.2) |
Obtains information about a solution.
public void getdcni ( soltype whichsol, int[] sub, double[] dcni);
Obtains information about a solution.
public void getdeqi ( soltype whichsol, accmode accmode, int[] sub, double[] deqi, int normalize);
Optains the dual equation infeasibility. If acmode is mosek.accmode.con then
![]() |
(15.9.3) |
If acmode is mosek.accmode.var then
![]() |
(15.9.4) |
Obtains information about a solution.
public double getdouinf (dinfitem whichdinf)
public void getdouinf ( dinfitem whichdinf, out double dvalue);
public void getdualobj ( soltype whichsol, out double dualobj);
public Task getinfeasiblesubproblem (soltype whichsol)
public void getinfeasiblesubproblem ( soltype whichsol, out Task inftask);
Creates a problem that finds the minimal change to the bounds that makes an infeasible problem feasible.
public void getinfindex ( inftype inftype, string infname, out int infindex);
public void getinti ( soltype whichsol, int[] sub, double[] inti);
Obtains the primal equation infeasibility.
![]() |
(15.9.5) |
Obtains information about a solution.
public int getintinf (iinfitem whichiinf)
public void getintinf ( iinfitem whichiinf, out int ivalue);
public int getintpntnumthreads ()
public void getintpntnumthreads (out int numthreads)
public long getlintinf (liinfitem whichliinf)
public void getlintinf ( liinfitem whichliinf, out long ivalue);
public long getmaxnumanz ()
public void getmaxnumanz (out long maxnumanz)
public void getmaxnumcon (out int maxnumcon)
public void getmaxnumcone (out int maxnumcone)
public void getmaxnumqnz (out long maxnumqnz)
public void getmaxnumvar (out int maxnumvar)
public void getmemusage ( out long meminuse, out long maxmemuse);
public string getname ( problemitem whichitem, int i, out long len);
public void getname ( problemitem whichitem, int i, out long len, StringBuilder name);
public string getname ( problemitem whichitem, int i);
public void getname ( problemitem whichitem, int i, StringBuilder name);
public int getnameindex ( problemitem whichitem, string name, out int asgn);
public void getnameindex ( problemitem whichitem, string name, out int asgn, out int index);
public long getnamelen ( problemitem whichitem, int i);
public void getnamelen ( problemitem whichitem, int i, out long len);
Obtains the name of a cone, a variable or a constraint.
public int getnumanz ()
public void getnumanz (out int numanz)
public long getnumanz64 ()
public void getnumanz64 (out long numanz)
public int getnumcon ()
public void getnumcon (out int numcon)
public int getnumcone ()
public void getnumcone (out int numcone)
public void getnumconemem ( int k, out int nummem);
public void getnumintvar (out int numintvar)
public void getnumparam ( parametertype partype, out int numparam);
public int getnumqconknz (int k)
public void getnumqconknz ( int k, out int numqcnz);
public long getnumqconknz64 (int k)
public void getnumqconknz64 ( int k, out long numqcnz);
public int getnumqobjnz ()
public void getnumqobjnz (out int numqonz)
public long getnumqobjnz64 ()
public void getnumqobjnz64 (out long numqonz)
public int getnumvar ()
public void getnumvar (out int numvar)
public string getobjname (out long len)
public void getobjname ( out long len, StringBuilder objname);
public objsense getobjsense ()
public void getobjsense (out objsense sense)
Sets the objective sense.
public void getpbi ( soltype whichsol, accmode accmode, int[] sub, double[] pbi, int normalize);
Obtains the primal bound infeasibility. If acmode is mosek.accmode.con then
![]() |
(15.9.6) |
If acmode is mosek.accmode.var then
![]() |
(15.9.7) |
Obtains information about a solution.
public void getpcni ( soltype whichsol, int[] sub, double[] pcni);
Obtains information about a solution.
public void getpeqi ( soltype whichsol, int[] sub, double[] peqi, int normalize);
Obtains the primal equation infeasibility.
![]() |
(15.9.8) |
Obtains information about a solution.
public double getprimalobj (soltype whichsol)
public void getprimalobj ( soltype whichsol, out double primalobj);
public problemtype getprobtype ()
public void getprobtype (out problemtype probtype)
public int getqconk ( int k, ref int qcsurp, int[] qcsubi, int[] qcsubj, double[] qcval);
public void getqconk ( int k, ref int qcsurp, out int numqcnz, int[] qcsubi, int[] qcsubj, double[] qcval);
public long getqconk64 ( int k, ref long qcsurp, int[] qcsubi, int[] qcsubj, double[] qcval);
public void getqconk64 ( int k, ref long qcsurp, out long numqcnz, int[] qcsubi, int[] qcsubj, double[] qcval);
public void getqobj ( ref int qosurp, out int numqonz, int[] qosubi, int[] qosubj, double[] qoval);
public void getqobj64 ( ref long qosurp, out long numqonz, int[] qosubi, int[] qosubj, double[] qoval);
public void getqobjij ( int i, int j, out double qoij);
public void getsolution ( soltype whichsol, out prosta prosta, out solsta solsta, stakey[] skc, stakey[] skx, stakey[] skn, double[] xc, double[] xx, double[] y, double[] slc, double[] suc, double[] slx, double[] sux, double[] snx);
Obtains the complete solution.
Consider the case of linear programming. The primal problem is given by
![]() |
(15.9.10) |
and the corresponding dual problem is
![]() |
(15.9.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:
mosek.solsta.optimal An optimal solution satisfying the optimality criteria for continuous problems is returned.
mosek.solsta.integer_optimal An optimal solution satisfying the optimality criteria for integer problems is returned.
mosek.solsta.prim_feas A solution satisfying the feasibility criteria.
mosek.solsta.prim_infeas_cer A primal certificate of infeasibility is returned.
mosek.solsta.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.
public void getsolutioni ( accmode accmode, int i, soltype whichsol, out stakey sk, out double x, out double sl, out double su, out double sn);
Obtains the complete solution.
Obtains a slice of the solution.
public void getsolutioninf ( soltype whichsol, out prosta prosta, out solsta solsta, out double primalobj, out double maxpbi, out double maxpcni, out double maxpeqi, out double maxinti, out double dualobj, out double maxdbi, out double maxdcni, out double maxdeqi);
Value of the primal objective.
![]() |
(15.9.12) |
Maximum infeasibility in primal bounds on variables.
![]() |
(15.9.13) |
Maximum infeasibility in primal equality constraints.
![]() |
(15.9.14) |
Maximum infeasibility in integer constraints.
![]() |
(15.9.15) |
Value of the dual objective.
![]() |
(15.9.16) |
Maximum infeasibility in bounds on dual variables.
![]() |
(15.9.17) |
Maximum infeasibility in the dual equality constraints.
![]() |
(15.9.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.9.19) |
where
![]() |
and the corresponding dual problem is
![]() |
(15.9.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 mosek.Task.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.
public void getsolutionslice ( soltype whichsol, solitem solitem, int first, int last, double[] values);
Obtains a slice of the solution.
Consider the case of linear programming. The primal problem is given by
![]() |
(15.9.21) |
and the corresponding dual problem is
![]() |
(15.9.22) |
The solitem argument determines which part of the solution is returned:
mosek.solitem.xx: The variable values return x.
mosek.solitem.y: The variable values return y.
mosek.solitem.slc: The variable values return .
mosek.solitem.suc: The variable values return .
mosek.solitem.slx: The variable values return .
mosek.solitem.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.9.23) |
This introduces one additional dual variable . This variable can be acceded by selecting solitem as mosek.solitem.snx.
The meaning of the values returned by this function also depends on the solution status which can be obtained with mosek.Task.getsolutionstatus. Depending on the solution status value will be:
mosek.solsta.optimal A part of the optimal solution satisfying the optimality criteria for continuous problems.
mosek.solsta.integer_optimal A part of the optimal solution satisfying the optimality criteria for integer problems.
mosek.solsta.prim_feas A part of the solution satisfying the feasibility criteria.
mosek.solsta.prim_infeas_cer A part of the primal certificate of infeasibility.
mosek.solsta.dual_infeas_cer A part of the dual certificate of infeasibility.
Obtains the complete solution.
Obtains the solution for a single constraint or variable.
public void getsolutionstatuskeyslice ( accmode accmode, soltype whichsol, int first, int last, stakey[] sk);
Obtains the complete solution.
Obtains the solution for a single constraint or variable.
public string gettaskname64 (out long len)
public void gettaskname64 ( out long len, StringBuilder taskname);
public int getvarbranchdir (int j)
public void getvarbranchdir ( int j, out int direction);
public void getvarbranchorder ( int j, out int priority, out int direction);
public int getvarbranchpri (int j)
public void getvarbranchpri ( int j, out int priority);
public string getvarname (int i)
public void getvarname ( int i, StringBuilder name);
public variabletype getvartype (int j)
public void getvartype ( int j, out variabletype vartype);
public void getvartypelist ( int[] subj, variabletype[] vartype);
Obtains the variable type of one or more variables.
Upon return vartype[k] is the variable type of variable subj[k].
public void initbasissolve (int[] 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 mosek.Task.solvewithbasis function.
This function should be called
If the basis is singular i.e. not invertible, then
the exception mosek.rescode.err_basis_singular is generated.
public void inputdata ( int maxnumcon, int maxnumvar, double[] c, double cfix, int[] aptrb, int[] aptre, int[] asub, double[] aval, boundkey[] bkc, double[] blc, double[] buc, boundkey[] bkx, double[] blx, double[] 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.
public void inputdata ( int maxnumcon, int maxnumvar, double[] c, double cfix, long[] aptrb, long[] aptre, int[] asub, double[] aval, boundkey[] bkc, double[] blc, double[] buc, boundkey[] bkx, double[] blx, double[] bux);
public void inputdata ( int maxnumcon, int maxnumvar, int numcon, int numvar, double[] c, double cfix, long[] aptrb, long[] aptre, int[] asub, double[] aval, boundkey[] bkc, double[] blc, double[] buc, boundkey[] bkx, double[] blx, double[] 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.
public void isdouparname ( string parname, out dparam param);
public void isintparname ( string parname, out iparam param);
public void isstrparname ( string parname, out sparam param);
public void linkfiletostream ( streamtype whichstream, string filename, int append);
public void makesolutionstatusunknown (soltype whichsol)
public void netextraction ( out int numcon, out int numvar, int[] netcon, int[] netvar, double[] scalcon, double[] scalvar, double[] cx, boundkey[] bkc, double[] blc, double[] buc, boundkey[] bkx, double[] blx, double[] bux, int[] from, int[] 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 mosek.Task.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.2. 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.
public void netoptimize ( double[] cc, double[] cx, boundkey[] bkc, double[] blc, double[] buc, boundkey[] bkx, double[] blx, double[] bux, int[] from, int[] to, out prosta prosta, out solsta solsta, int hotstart, stakey[] skc, stakey[] skx, double[] xc, double[] xx, double[] y, double[] slc, double[] suc, double[] slx, double[] sux);
public void netoptimize ( int numcon, int numvar, double[] cc, double[] cx, boundkey[] bkc, double[] blc, double[] buc, boundkey[] bkx, double[] blx, double[] bux, int[] from, int[] to, out prosta prosta, out solsta solsta, int hotstart, stakey[] skc, stakey[] skx, double[] xc, double[] xx, double[] y, double[] slc, double[] suc, double[] slx, double[] sux);
Finds embedded network structure.
public void optimizeconcurrent (Task[] taskarray)
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 mosek.Task.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 mosek.Task.optimizeconcurrent does the following:
For an explained code example see Section 8.6.4.
public void optimizersummary (streamtype whichstream)
public rescode optimize ()
public void optimize (out rescode trmcode)
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.
public void primalsensitivity ( int[] subi, mark[] marki, int[] subj, mark[] markj, double[] leftpricei, double[] rightpricei, double[] leftrangei, double[] rightrangei, double[] leftpricej, double[] rightpricej, double[] leftrangej, double[] rightrangej);
public void primalsensitivity ( int numi, int[] subi, mark[] marki, int numj, int[] subj, mark[] markj, double[] leftpricei, double[] rightpricei, double[] leftrangei, double[] rightrangei, double[] leftpricej, double[] rightpricej, double[] leftrangej, double[] 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.9.24) |
Suppose that
numi = 1; subi = [0]; marki = [mosek.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.9.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 mosek.iparam.sensitivity_type.
Performs sensitivity analysis on objective coefficients.
Creates a sensitivity report.
public void printdata ( streamtype whichstream, int firsti, int lasti, int firstj, int lastj, int firstk, int lastk, int c, int qo, int a, int qc, int bc, int bx, int vartype, int cones);
public void probtypetostr ( problemtype probtype, StringBuilder str);
public void prostatostr ( prosta prosta, StringBuilder str);
public void putaij ( int i, int j, double 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.
public void putaijlist ( int[] subi, int[] subj, double[] valij);
public void putaijlist ( int num, int[] subi, int[] subj, double[] 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.
public void putavec ( accmode accmode, int i, int[] asub, double[] aval);
public void putavec ( accmode accmode, int i, int nzi, int[] asub, double[] 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 mosek.accmode.con, then
![]() |
and all other .
If accmode is mosek.accmode.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.
public void putaveclist ( accmode accmode, int[] sub, int[] ptrb, int[] ptre, int[] asub, double[] aval);
public void putaveclist ( accmode accmode, int num, int[] sub, int[] ptrb, int[] ptre, int[] asub, double[] aval);
Replaces all elements in a set of rows or columns of A.
The elements are replaced as follows.
If accmode is mosek.accmode.con, then for
![]() |
If accmode is mosek.accmode.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.
public void putaveclist ( accmode accmode, int[] sub, long[] ptrb, long[] ptre, int[] asub, double[] aval);
public void putaveclist ( accmode accmode, int num, int[] sub, long[] ptrb, long[] ptre, int[] asub, double[] aval);
Replaces all elements in a set of rows or columns of A.
The elements are replaced as follows.
If accmode is mosek.accmode.con, then for
![]() |
If accmode is mosek.accmode.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.
public void putbound ( accmode accmode, int i, boundkey bk, double bl, double bu);
Changes the bounds for either one constraint or one variable.
If the a bound value specified is numerically larger than mosek.dparam.data_tol_bound_inf it is considered infinite and the bound key is changed accordingly. If a bound value is numerically larger than mosek.dparam.data_tol_bound_wrn, a warning will be displayed, but the bound is inputted as specified.
Changes the bounds of constraints or variables.
public void putboundlist ( accmode accmode, int[] sub, boundkey[] bk, double[] bl, double[] bu);
public void putboundlist ( accmode accmode, int num, int[] sub, boundkey[] bk, double[] bl, double[] bu);
Changes the bound for either one constraint or one variable.
public void putboundslice ( accmode con, int first, int last, boundkey[] bk, double[] bl, double[] bu);
Changes the bound for either one constraint or one variable.
public void putcfix (double cfix)
public void putcj ( int j, double cj);
Modifies one coefficient in the linear objective vector c, i.e.
![]() |
public void putclist ( int[] subj, double[] val);
public void putclist ( int num, int[] subj, double[] 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.
public void putcone ( int k, conetype conetype, double conepar, int[] submem);
public void putcone ( int k, conetype conetype, double conepar, int nummem, int[] submem);
public void putdouparam ( dparam param, double parvalue);
public void putintparam ( iparam param, int parvalue);
public void putmaxnumanz (int 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.
public void putmaxnumanz (long maxnumanz)
public void putmaxnumcon (int 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.
public void putmaxnumcone (int 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.
public void putmaxnumqnz (int 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.
public void putmaxnumqnz (long 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.
public void putmaxnumvar (int 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.
public void putnadouparam ( string paramname, double parvalue);
public void putnaintparam ( string paramname, int parvalue);
public void putname ( problemitem whichitem, int i, string name);
public void putnastrparam ( string paramname, string parvalue);
public void putobjname (string objname)
public void putobjsense (objsense sense)
Gets the objective sense.
public void putparam ( string parname, string parvalue);
public void putqcon ( int[] qcsubk, int[] qcsubi, int[] qcsubj, double[] qcval);
public void putqcon ( int numqcnz, int[] qcsubk, int[] qcsubi, int[] qcsubj, double[] qcval);
Replaces all quadratic entries in the constraints. Consider constraints on the form:
![]() |
(15.9.26) |
The function assigns values to q such that:
![]() |
(15.9.27) |
and
![]() |
(15.9.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.
public void putqconk ( int k, int[] qcsubi, int[] qcsubj, double[] qcval);
public void putqconk ( int k, int numqcnz, int[] qcsubi, int[] qcsubj, double[] qcval);
Replaces all the quadratic entries in one constraint k of the form:
![]() |
(15.9.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.
public void putqobj ( int[] qosubi, int[] qosubj, double[] qoval);
public void putqobj ( int numqonz, int[] qosubi, int[] qosubj, double[] qoval);
Replaces all the quadratic terms in the objective
![]() |
(15.9.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.
public void putqobjij ( int i, int j, double 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 mosek.Task.putqobj instead whenever possible.
public void putsolution ( soltype whichsol, stakey[] skc, stakey[] skx, stakey[] skn, double[] xc, double[] xx, double[] y, double[] slc, double[] suc, double[] slx, double[] sux, double[] snx);
public void putsolutioni ( accmode accmode, int i, soltype whichsol, stakey sk, double x, double sl, double su, double 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 mosek.Task.makesolutionstatusunknown function, then for each relevant constraint and variable call mosek.Task.putsolutioni to set the solution information.
Sets the solution status to unknown.
public void putsolutionyi ( int i, soltype whichsol, double y);
Sets the solution status to unknown.
Sets the primal and dual solution information for a single constraint or variable.
public void putstrparam ( sparam param, string parvalue);
public void puttaskname (string taskname)
public void putvarbranchorder ( int j, int priority, int direction);
public void putvartype ( int j, variabletype vartype);
Sets the variable type for one or more variables.
public void putvartypelist ( int[] subj, variabletype[] vartype);
public void putvartypelist ( int num, int[] subj, variabletype[] 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.
public void readbranchpriorities (string filename)
Writes branching priority data to a file.
public void readdata (string filename)
Reads an optimization data and associated data from a file.
The data file format is determined by the mosek.iparam.read_data_format parameter. By default the parameter has the value mosek.dataformat.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.
public void readparamfile ()
public void readsolution ( soltype whichsol, string filename);
public void readsummary (streamtype whichstream)
public Task relaxprimal ( double[] wlc, double[] wuc, double[] wlx, double[] wux);
public void relaxprimal ( out Task relaxedtask, double[] wlc, double[] wuc, double[] wlx, double[] 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.9.31) |
the function forms a new task relaxedtask having the form
![]() |
(15.9.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.9.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.9.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.9.32), then a natural thing to do is to solve the optimization problem
![]() |
(15.9.33) |
where the original objective function is minimized subject to the constraint that the total weighted relaxation is minimal.
The parameter mosek.iparam.feasrepair_optimize controls whether the function returns the problem (15.9.32) or the problem (15.9.33).The parameter can take one of the following values.
: The returned task relaxedtask contains problem (15.9.32) and is not optimized.
: The returned task relaxedtask contains problem (15.9.32) and is optimized.
: The returned task relaxedtask contains problem (15.9.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 mosek.sparam.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 mosek.Task.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.
public void remove ( accmode accmode, int[] sub);
public void remove ( accmode accmode, int num, int[] sub);
Appends a number of variables or constraints to the optimization task.
public void removecone (int 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.
public void resizetask ( int maxnumcon, int maxnumvar, int maxnumcone, int maxnumanz, int 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.
public void sensitivityreport (streamtype whichstream)
Performs sensitivity analysis on objective coefficients.
Perform sensitivity analysis on bounds.
public void set_Stream ( streamtype whichstream, Stream stream);
public void setdefaults ()
public void sktostr ( int sk, StringBuilder str);
public void solstatostr ( solsta solsta, StringBuilder str);
public int solutiondef (soltype whichsol)
public void solutiondef ( soltype whichsol, out int isdef);
public void solutionsummary (streamtype whichstream)
public void solvewithbasis ( int transp, ref int numnz, int[] sub, double[] 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.9.34) |
or the system
![]() |
(15.9.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 mosek.Task.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.
public void strtoconetype ( string str, out conetype conetype);
public void strtosk ( string str, out int sk);
public void undefsolution (soltype whichsol)
public void writebranchpriorities (string filename)
Reads branching priority data from a file.
public void writedata (string 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 mosek.iparam.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 mosek.iparam.write_generic_names parameter to mosek.onoffkey.on.
Reads problem data from a file.
public void writeparamfile (string filename)
public void writesolution ( soltype whichsol, string filename);
mosek.Exception
This is an exception class representing MOSEK warnings.
public Warning (rescode code)