mosek(Rmosek)
mosek()所属R语言包:Rmosek
Solve an optimization problem
解决的优化问题
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Solve an optimization problem using the MOSEK Optimization Library.
解决一个优化问题,使用MOSEK优化库。
Please see the 'userguide.pdf' for a detailed introduction to this package. This file is located in the "doc" directory at the root of this package:<br> system.file("doc", "userguide.pdf", package="Rmosek")
请参阅“userguide.pdf详细介绍了这个包。在这个包的根目录下,该文件位于“doc”目录:参考system.file("doc", "userguide.pdf", package="Rmosek")
用法----------Usage----------
mosek(problem, opts = list())
参数----------Arguments----------
参数:problem
The optimization problem. <table summary="Rd table"> <tr> <td align="left"> problem </td><td align="left"> LIST </td><td align="left"> </td> </tr> <tr> <td align="left"> ..$sense </td><td align="left"> STRING </td><td align="left"> </td> </tr> <tr> <td align="left"> ..$c </td><td align="left"> NUMERIC VECTOR </td><td align="left"> </td> </tr> <tr> <td align="left"> ..$c0 </td><td align="left"> NUMERIC </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$A </td><td align="left"> SPARSE MATRIX </td><td align="left"> </td> </tr> <tr> <td align="left"> ..$bc </td><td align="left"> NUMERIC MATRIX (2 rows) </td><td align="left"> </td> </tr> <tr> <td align="left"> ..$bx </td><td align="left"> NUMERIC MATRIX (2 rows) </td><td align="left"> </td> </tr> <tr> <td align="left"> ..$cones </td><td align="left"> LIST MATRIX (2 rows) </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$intsub </td><td align="left"> NUMERIC VECTOR </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$scopt </td><td align="left"> LIST </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$iparam/$dparam/$sparam </td><td align="left"> LIST </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ....$<MSK_PARAM> </td><td align="left"> STRING / NUMERIC </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$sol </td><td align="left"> LIST </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ....$itr/$bas/$int </td><td align="left"> LIST </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> </td> </tr> </table>
最优化问题。 <table summary="Rd table"> <TR> <td ALIGN="LEFT">问题</ TD> <TD ALIGN="LEFT"> LIST </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT">元感</ TD> <TD ALIGN="LEFT"> STRING </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> .. $ C </ TD> <TD ALIGN="LEFT">数值向量</ TD> <TD ALIGN="LEFT"> </ TD> </ TR文章<td ALIGN="LEFT">元C0 </ TD> <td ALIGN="LEFT">数字</ TD> <TD ALIGN="LEFT">(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT"> .. $ A </ TD> <TD ALIGN="LEFT">稀疏矩阵</ TD> <TD ALIGN="LEFT"> </ TD> </ TR文章<td ALIGN="LEFT">元BC </ TD> <TD ALIGN="LEFT">数值矩阵(2行)</ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT">元BX </ TD> <TD ALIGN="LEFT">数值矩阵(2行)</ TD> <TD ALIGN="LEFT"> < / TD> </ TR> <TR> <td ALIGN="LEFT">元锥</ TD> <TD ALIGN="LEFT">列表MATRIX(2行)</ TD> <TD对齐=“左“>(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT">元intsub </ TD> <TD ALIGN="LEFT">数值向量</ TD> <TD对齐= “左”>(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT">元scopt </ TD> <TD ALIGN="LEFT"> LIST </ TD> <TD调整=“”>(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT">元IPARAM / $ dparam / $ sparam </ TD> <TD ALIGN="LEFT"> LIST </ TD> <TD ALIGN="LEFT">(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT"> .... $ <MSK_PARAM> </ TD> <TD调整=“”>字符串/数字</ TD> <TD ALIGN="LEFT">(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT">元溶胶</ TD> <td ALIGN="LEFT"> LIST </ TD> <TD ALIGN="LEFT">(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT"> .... $ ITR / BAS /美元整数</ TD> <TD ALIGN="LEFT"> LIST </ TD> <TD ALIGN="LEFT">(可选)</ TD> </ TR> <TR> <TD对齐=“左边“> </ TD> </ TR> </ TABLE>
参数:opts
The interface options. <table summary="Rd table"> <tr> <td align="left"> opts </td><td align="left"> LIST </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$verbose </td><td align="left"> NUMERIC </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$usesol </td><td align="left"> BOOLEAN </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$useparam </td><td align="left"> BOOLEAN </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$soldetail </td><td align="left"> NUMERIC </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$getinfo </td><td align="left"> BOOLEAN </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$writebefore </td><td align="left"> STRING (filepath) </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> ..$writeafter </td><td align="left"> STRING (filepath) </td><td align="left"> (OPTIONAL) </td> </tr> <tr> <td align="left"> </td> </tr> </table>
接口选项。 <table summary="Rd table"> <TR> <td ALIGN="LEFT"> OPTS </ TD> <TD ALIGN="LEFT"> LIST </ TD> <TD ALIGN="LEFT">(可选)< / TD> </ TR> <TR> <td ALIGN="LEFT">元详细</ TD> <td ALIGN="LEFT">数字</ TD> <TD ALIGN="LEFT">(可选) </ TD> </ TR> <TR> <td ALIGN="LEFT">元以UseSOL方式</ TD> <TD ALIGN="LEFT"> BOOLEAN </ TD> <TD ALIGN="LEFT">(OPTIONAL )</ TD> </ TR> <TR> <td ALIGN="LEFT">元useparam </ TD> <TD ALIGN="LEFT"> BOOLEAN </ TD> <TD ALIGN="LEFT">(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT">元soldetail </ TD> <td ALIGN="LEFT">数字</ TD> <TD ALIGN="LEFT"> (可选)</ TD> </ TR> <TR> <td ALIGN="LEFT">元GetInfo的</ TD> <TD ALIGN="LEFT"> BOOLEAN </ TD> <TD对齐=“左边” (可选)</ TD> </ TR> <TR> <td ALIGN="LEFT">元writebefore </ TD> <TD ALIGN="LEFT"> STRING(路径)</ TD> <TD调整=“”>(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT">元writeafter </ TD> <TD ALIGN="LEFT"> STRING(路径)</ TD > <td ALIGN="LEFT">(可选)</ TD> </ TR> <TR> <td ALIGN="LEFT"> </ TD> </ TR> </ TABLE>
Details
详细信息----------Details----------
The optimization problem should be described in a named list of definitions. The number of variables in the problem is determined from the number of columns in the constraint matrix A.
在命名定义列表的最优化问题应加以说明。从约束矩阵A中的列的数目来确定的问题中的变量的数目。
Like a Linear Program it has a linear objective with one coefficient in c for each variable, some optional constant c0, and the improving direction sense. The constraints can either be linear, specified as rows in A with lower and upper bounds as columns in bc (you can use Inf if needed), or conic as specified in the list-typed matrix cones (add constraints copyx=x if some variable x appears in multiple cones). Each variable has lower and upper bounds as columns in bx, and will be integer if it appears in the intsub list.
一个线性规划一样,它有一个线性目标一个系数c为每个变量,一些可选的常量c0,和改进的方向sense的。可以是线性的约束,指定行A列表中指定的上限和下限,列在bc(你可以使用Inf如果需要的话),或圆锥类型的矩阵cones(添加约束copyx = x,如果一些变量x出现在多个锥)。每个变量有上界和下界为列在bx,将是一个整数,如果它出现在intsub列表。
As an advanced feature, non-linear unary operators involving exponential or logarithmic functions can be added with scopt.
作为一种先进的功能,涉及指数函数和对数函数的非线性的一元运算符,可加用scopt。
Parameters can also be specified for the MOSEK call. iparam is integer-typed parameters, dparam ia double-typed parameters and sparam is string-typed parameters. These parameters can be ignored by setting the option useparam to FALSE (the default is TRUE).
参数也可以被指定为MOSEK调用。 iparam是整数类型的参数,dparam IA双类型参数和sparam是字符串类型的参数。通过设置选项“useparam为FALSE(默认为TRUE),这些参数可以忽略不计。
Initial solutions are specified in sol and should have the same format as the solution returned by the function call. This solution can be ignored by setting the option usesol to FALSE (the default is TRUE).
初始解指定在sol和应该具有相同的格式,该溶液由函数调用返回。通过设置选项“usesol为FALSE(默认为TRUE),该解决方案可以忽略不计。
The amount of information printed by the interface can be limited by verbose (default=10). The generated model can be exported to any standard modeling fileformat (e.g. lp, opf, lp or mbt), with (resp. without) the identified solution using writeafter (resp. writebefore).
信息的接口打印量是有限的,verbose(默认为10)。生成的模型可以出口到任何标准的建模档案格式(例如LP,LP,OPF或MBT),(或无)确定的解决方案,使用writeafter(或者writebefore)。
The optimization process can be terminated at any moment using CTRL + C.
优化过程可以在任何时候使用CTRL + C终止
值----------Value----------
参数:r
The returned results. <table summary="Rd table"> <tr> <td align="left"> r </td><td align="left"> LIST </td><td align="left"> </td> </tr> <tr> <td align="left"> ..$response </td><td align="left"> LIST </td><td align="left"> </td> </tr> <tr> <td align="left"> ....$code </td><td align="left"> NUMERIC </td><td align="left"> </td> </tr> <tr> <td align="left"> ....$msg </td><td align="left"> STRING </td><td align="left"> </td> </tr> <tr> <td align="left"> ..$sol </td><td align="left"> LIST </td><td align="left"> </td> </tr> <tr> <td align="left"> ....$itr/$bas/$int </td><td align="left"> LIST </td><td align="left"> (SOLVER DEPENDENT) </td> </tr> <tr> <td align="left"> ......$solsta </td><td align="left"> STRING </td><td align="left"> </td> </tr> <tr> <td align="left"> ......$prosta </td><td align="left"> STRING </td><td align="left"> </td> </tr> <tr> <td align="left"> ......$skc </td><td align="left"> STRING VECTOR </td><td align="left"> </td> </tr> <tr> <td align="left"> ......$skx </td><td align="left"> STRING VECTOR </td><td align="left"> </td> </tr> <tr> <td align="left"> ......$skn </td><td align="left"> STRING VECTOR </td><td align="left"> (NOT IN $bas) </td> </tr> <tr> <td align="left"> ......$xc </td><td align="left"> NUMERIC VECTOR </td><td align="left"> </td> </tr> <tr> <td align="left"> ......$xx </td><td align="left"> NUMERIC VECTOR </td><td align="left"> </td> </tr> <tr> <td align="left"> ......$slc </td><td align="left"> NUMERIC VECTOR </td><td align="left"> (NOT IN $int) </td> </tr> <tr> <td align="left"> ......$suc </td><td align="left"> NUMERIC VECTOR </td><td align="left"> (NOT IN $int) </td> </tr> <tr> <td align="left"> ......$slx </td><td align="left"> NUMERIC VECTOR </td><td align="left"> (NOT IN $int) </td> </tr> <tr> <td align="left"> ......$sux </td><td align="left"> NUMERIC VECTOR </td><td align="left"> (NOT IN $int) </td> </tr> <tr> <td align="left"> ......$snx </td><td align="left"> NUMERIC VECTOR </td><td align="left"> (NOT IN $int/$bas) </td> </tr> <tr> <td align="left"> ......$pobjval </td><td align="left"> NUMERIC </td><td align="left"> * </td> </tr> <tr> <td align="left"> ......$dobjval </td><td align="left"> NUMERIC </td><td align="left"> *(NOT IN $int) </td> </tr> <tr> <td align="left"> ......$pobjbound </td><td align="left"> NUMERIC </td><td align="left"> *($int ONLY) </td> </tr> <tr> <td align="left"> ......$maxinfeas </td><td align="left"> LIST </td><td align="left"> * </td> </tr> <tr> <td align="left"> ........$pbound </td><td align="left"> NUMERIC </td><td align="left"> * </td> </tr> <tr> <td align="left"> ........$peq </td><td align="left"> NUMERIC </td><td align="left"> * </td> </tr> <tr> <td align="left"> ........$pcone </td><td align="left"> NUMERIC </td><td align="left"> *(NOT IN $bas) </td> </tr> <tr> <td align="left"> ........$dbound </td><td align="left"> NUMERIC </td><td align="left"> *(NOT IN $int) </td> </tr> <tr> <td align="left"> ........$deq </td><td align="left"> NUMERIC </td><td align="left"> *(NOT IN $int) </td> </tr> <tr> <td align="left"> ........$dcone </td><td align="left"> NUMERIC </td><td align="left"> *(NOT IN $int/$bas)</td> </tr> <tr> <td align="left"> ........$int </td><td align="left"> NUMERIC </td><td align="left"> *($int ONLY) </td> </tr> <tr> <td align="left"> ..$iinfo/$dinfo </td><td align="left"> LIST </td><td align="left"> * </td> </tr> <tr> <td align="left"> ....$<MSK_INFO> </td><td align="left"> NUMERIC </td><td align="left"> * </td> </tr> <tr> <td align="left"> </td> </tr> </table> <table summary="Rd table"> <tr> <td align="left">*Starred items must be requested using an option.</td> </tr> </table>
返回的结果。 <table summary="Rd table"> <TR> <td ALIGN="LEFT"> R </ TD> <TD ALIGN="LEFT"> LIST </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT">元响应</ TD> <TD ALIGN="LEFT"> LIST </ TD> <TD ALIGN="LEFT"> </ TD> </ TR文章<td ALIGN="LEFT"> .... $代码</ TD> <TD ALIGN="LEFT"> NUMERIC </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> .... $味精</ TD> <TD ALIGN="LEFT"> STRING </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT">元溶胶</ TD> <TD ALIGN="LEFT"> LIST </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> .... $ ITR / BAS /美元整数</ TD> <TD ALIGN="LEFT">列表</ TD> <TD ALIGN="LEFT">(SOLVER而定)</ TD> </ TR> <TR> <td ALIGN="LEFT"> ...... $ solsta </ TD> <TD ALIGN="LEFT"> STRING </ TD> <TD对齐= “左”> </ TD> </ TR> <TR> <td ALIGN="LEFT"> ...... $前列腺</ TD> <TD ALIGN="LEFT"> STRING </ TD> <TD ALIGN =“左”> </ TD> </ TR> <TR> <td ALIGN="LEFT"> ...... $ SKC </ TD> <TD ALIGN="LEFT">字符串向量</ TD > <td ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> ...... $ SKX </ TD> <TD ALIGN="LEFT">字符串向量</ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> ......的SKN </ TD> <TD ALIGN =“左边” >字符串向量</ TD> <TD ALIGN="LEFT">(NOT IN $ BAS)</ TD> </ TR> <TR> <td ALIGN="LEFT"> ...... XC </ TD> <TD ALIGN="LEFT">数值向量</ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> ...... $ XX </ TD> <TD ALIGN="LEFT">数值向量</ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> ....元SLC </ TD> <TD ALIGN="LEFT">数值向量</ TD> <TD ALIGN="LEFT">(NOT IN INT)</ TD> </ TR> <TR> <TD调整=“左”> ...... SUC </ TD> <TD ALIGN="LEFT">数值向量</ TD> <TD ALIGN="LEFT">(NOT IN $ INT)</ TD> < / TR> <TR> <td ALIGN="LEFT"> ...... $ SLX </ TD> <TD ALIGN="LEFT">数值向量</ TD> <TD ALIGN="LEFT">(NOT在诠释)</ TD> </ TR> <TR> <td ALIGN="LEFT"> ...... sux的</ TD> <TD ALIGN="LEFT">数值向量</ TD> < TD对齐=“左”(NOT IN INT)</ TD> </ TR> <TR> <td ALIGN="LEFT"> ...... $ SNX </ TD> <TD对齐=“左边“数字向量</ TD>的<td ALIGN="LEFT">(NOT IN美元整数/ BAS)</ TD> </ TR> <TR> <td ALIGN="LEFT"> ...... pobjval </ TD> <TD ALIGN="LEFT"> NUMERIC </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> ... ... dobjval </ TD> <TD ALIGN="LEFT"> NUMERIC </ TD> <TD ALIGN="LEFT"> *(美元整数)</ TD> </ TR> <TR> <TD对齐=“左”...... pobjbound </ TD> <td ALIGN="LEFT">数字</ TD> <TD ALIGN="LEFT"> *(整型)</ TD> < / TR> <TR> <td ALIGN="LEFT"> ...... maxinfeas </ TD> <TD ALIGN="LEFT"> LIST </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT">。$ pbound </ TD> <td ALIGN="LEFT">数字</ TD> <TD对齐=“左边“> * </ TD> </ TR> <TR> <td ALIGN="LEFT">。$ PEQ </ TD> <TD ALIGN="LEFT"> NUMERIC </ TD> < TD对齐=“”> * </ TD> </ TR> <TR> <td ALIGN="LEFT">。$ pcone </ TD> <TD ALIGN="LEFT"> NUMERIC </ TD> <TD ALIGN="LEFT"> *($浅)</ TD> </ TR> <TR> <td ALIGN="LEFT">。$ dbound </ TD> <td ALIGN="LEFT">数字</ TD> <TD ALIGN="LEFT"> *(美元整数)</ TD> </ TR> <TR> <td ALIGN="LEFT">。 ....... $的DEQ </ TD> <td ALIGN="LEFT">数字</ TD> <TD ALIGN="LEFT"> *(美元整数)</ TD> </ TR> < TR> <td ALIGN="LEFT">。$ dcone </ TD> <TD ALIGN="LEFT"> NUMERIC </ TD> <TD ALIGN="LEFT"> *(NOT IN $ INT / $ BAS)</ TD> </ TR> <TR> <td ALIGN="LEFT">。$诠释</ TD> <TD ALIGN="LEFT"> NUMERIC </ TD > <td ALIGN="LEFT"> *(整型)</ TD> </ TR> <TR> <td ALIGN="LEFT">元iinfo / $ dinfo </ TD> <TD对齐=“左“> LIST </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> .... $ <MSK_INFO> </ TD> < TD对齐=“”> NUMERIC </ TD> <TD ALIGN="LEFT"> </ TD> </ TR> <TR> <td ALIGN="LEFT"> </ TD> </ TR> </表> summary="Rd table"> <TR> <td ALIGN="LEFT"> *星号标记项目,必须要求使用的选项。</ TD> </ TR> </ TABLE>
The result is a named list containing the response of the MOSEK Optimization Library. A response code of zero is the signal of success.
其结果是一个命名列表,包含MOSEK优化库的响应。零响应代码是成功的信号。
Depending on the specified solver, one or more solutions may be returned. The interior-point solution itr, the basic (corner point) solution bas, and the integer solution int.
根据指定的解算器,一个或多个的解决方案可能被返回。内部点解决方案itr,(角点)的基本解决方案bas,和整数解int。
The problem status prosta in all solutions shows the feasibility of your problem description. All solutions are described by a solution status solsta (e.g. optimal) along with the variable and constraint activities. All activities will further have a bound key that specify their value in relation to the declared bounds.
问题状态prosta的所有解决方案的可行性问题描述。的溶液状态solsta(例如最佳)所描述的所有解决方案都随着变量和约束的活动。所有活动将进一步绑定键,指定其价值在有关声明的界限。
Dual variables are returned for all defined bounds wherever possible. Integer solutions int does not have any dual variables as such definitions would not make sense. Basic (corner point) solutions bas would never be returned if the problem had conic constraints, and does not define snx.
双变量将返回所有已定义的界限尽可能。整数解int没有任何双变量,这样的定义是没有意义的。基本(角点)解决方案bas永远不会被退回问题是否有圆锥曲线的约束,并没有定义snx。
Setting option soldetail larger than 1 extracts pobjval, pobjval and pobjbound. Larger than 2 extracts maxinfeas. Setting option getinfo to TRUE extracts iinfo and dinfo.
设置选项soldetail大于1提取物pobjval,pobjval和pobjbound。大于2提取maxinfeas。设置选项“getinfo到TRUE,提取iinfo和dinfo。
参见----------See Also----------
mosek_version mosek_clean
mosek_versionmosek_clean
实例----------Examples----------
lo1 <- list()
lo1$sense <- "max"
lo1$c <- c(3,1,5,1)
lo1$A <- Matrix(c(3,1,2,0,
2,1,3,1,
0,2,0,3), nrow=3, byrow=TRUE, sparse=TRUE)
lo1$bc <- rbind(blc = c(30,15,-Inf),
buc = c(30,Inf,25))
lo1$bx <- rbind(blx = c(0,0,0,0),
bux = c(Inf,10,Inf,Inf))
r <- mosek(lo1, list( soldetail = 1 ))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|