找回密码
 注册
查看: 4079|回复: 0

R语言 lpSolve包 lp()函数中文帮助文档(中英文对照)

  [复制链接]
发表于 2012-9-21 23:12:22 | 显示全部楼层 |阅读模式
lp(lpSolve)
lp()所属R语言包:lpSolve

                                        Linear and Integer Programming
                                         线性整数规划

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Interface to lp\_solve linear/integer programming system
LP \ _solve的线性/整数规划系统的接口


用法----------Usage----------


lp (direction = "min", objective.in, const.mat, const.dir, const.rhs,
        transpose.constraints = TRUE, int.vec, presolve=0, compute.sens=0,
        binary.vec, all.int=FALSE, all.bin=FALSE, scale = 196, dense.const,
        num.bin.solns=1, use.rw=FALSE)



参数----------Arguments----------

参数:direction
Character string giving direction of optimization: "min" (default) or "max."
字符串优化的方向:“MIN”(默认)或“最大”。


参数:objective.in
Numeric vector of coefficients of objective function
数字目标函数的系数向量


参数:const.mat
Matrix of numeric constraint coefficients, one row  per constraint, one column per variable (unless transpose.constraints =  FALSE; see below).
数值约束系数矩阵,每个约束的一排,每个变量的一列(除非transpose.constraints = FALSE;见下文)。


参数:const.dir
Vector of character strings giving the direction of  the constraint: each value should be one of "<," "<=," "=," "==," ">," or ">=". (In each pair the two values are identical.)
向量的字符串,给人的方向的约束:每个值应该是一个“<”,“<=”,“=”,“==”,“>”,或“> =”。 (在每一对中的两个值是相同的。)


参数:const.rhs
Vector of numeric values for the right-hand sides of  the constraints.
向量的数值为右手侧的约束。


参数:transpose.constraints
By default each constraint occupies a row  of const.mat, and that matrix needs to be transposed before being passed  to the optimizing code.  For very large constraint matrices it may be wiser  to construct the constraints in a matrix column-by-column. In that case set  transpose.constraints to FALSE.
默认情况下,每个约束占有const.mat排,该矩阵需要被传递到最优化的代码之前,进行调换。对于非常大的约束矩阵,它可能是明智的,构建一个矩阵列列的约束。在这种情况下,设置transpose.constraints为FALSE。


参数:int.vec
Numeric vector giving the indices of variables that are  required to be integer. The length of this vector will therefore be the  number of integer variables.
数字矢量提供的变量都必须是整数的指数。因此,此向量的长度将是整数变量的数目。


参数:presolve
Numeric: presolve? Default 0 (no); any non-zero value means "yes." Currently ignored.
数字:presolve?默认值0(无),任何非零值意味着“是”。目前忽略不计。


参数:compute.sens
Numeric: compute sensitivity? Default 0 (no); any non-zero value means "yes."
数字:计算灵敏度?默认值0(无),任何非零值意味着“是”。


参数:binary.vec
Numeric vector like int.vec giving the indices of variables  that are required to be binary.
像int.vec给指数的变量所需要的是二进制的数字矢量。


参数:all.int
Logical: should all variables be integer? Default: FALSE.
逻辑:所有的变量是整数?默认值:FALSE。


参数:all.bin
Logical: should all variables be binary? Default: FALSE.
逻辑:所有的变量应该是二进制?默认值:FALSE。


参数:scale
Integer: value for lpSolve scaling. Details can be found in the lpSolve documentation. Set to 0 for no scaling. Default: 196
整数:lpSolve缩放值。详情可参阅在lpSolve文件。设置为0,不结垢。默认值:196


参数:dense.const
Three column dense constraint array. This is ignored if const.mat is supplied. Otherwise the columns are constraint number, column number, and value; there should be one row for each non-zero entry in the constraint matrix.
三列密集的约束阵列。这是如果提供const.mat,忽略。否则,列约束号,列号,和值,应该有一个排的约束矩阵中的每个非零项。


参数:num.bin.solns
Integer: if all.bin=TRUE, the user can request up to num.bin.solns optimal solutions to be returned.
整数:如果all.bin = TRUE,用户可以要求返回num.bin.solns最佳的解决方案。


参数:use.rw
Logical: if TRUE and num.bin.solns > 1, write the lp out to a file and read it back in for each solution after the first. This is just to defeat a bug somewhere. Although the default is FALSE, we recommend you set this to TRUE if you need num.bin.solns > 1, until the bug is found.
逻辑:如果为true,num.bin.solns> 1时,写的LP到一个文件中,并为每个解决方案后的第一次回读。这是刚刚打败了一个错误的地方。虽然默认为FALSE,我们建议您设置为TRUE如果你需要num.bin.solns,> 1,直到发现错误。


Details

详细信息----------Details----------

This function calls the lp\_solve 5.5 solver. That system has many options not supported here. The current version is maintained at http://lpsolve.sourceforge.net/5.5
该函数调用的lp \ _solve 5.5求解。该系统有很多不支持的选项。当前版本保持在http://lpsolve.sourceforge.net/5.5

Note that every variable is assumed to be >= 0!
请注意,每个变量被假定为> = 0!


值----------Value----------

An lp object. See lp.object for details.
LP对象。见lp.object的详细信息。


(作者)----------Author(s)----------


Sam Buttrey, <a href="mailto:buttrey@nps.edu">buttrey@nps.edu</a>



参见----------See Also----------

lp.assign, lp.transport
lp.assign,lp.transport


实例----------Examples----------


#[]
# Set up problem: maximize[设置问题:最大化]
#   x1 + 9 x2 +   x3 subject to[X1 + X2 + X3受]
#   x1 + 2 x2 + 3 x3  &lt;= 9[X1 + X2 + 3×3 = 9]
# 3 x1 + 2 x2 + 2 x3 &lt;= 15[3 X1 + X2 + X3 <= 15]
#[]
f.obj <- c(1, 9, 3)
f.con <- matrix (c(1, 2, 3, 3, 2, 2), nrow=2, byrow=TRUE)
f.dir <- c("<=", "<=")
f.rhs <- c(9, 15)
#[]
# Now run.[现在运行。]
#[]
lp ("max", f.obj, f.con, f.dir, f.rhs)
## Not run: Success: the objective function is 40.5[#不运行:成功:目标函数为40.5]
lp ("max", f.obj, f.con, f.dir, f.rhs)$solution
## Not run: [1] 0.0 4.5 0.0[#不运行:[1] 0.0 4.5 0.0]
#[]
# The same problem using the dense constraint approach:[同样的问题使用密集的约束方法:]
#[]
f.con.d <- matrix (c(rep (1:2,each=3), rep (1:3, 2), t(f.con)), ncol=3)
lp ("max", f.obj, , f.dir, f.rhs, dense.const=f.con.d)
## Not run: Success: the objective function is 40.5[#不运行:成功:目标函数为40.5]
#[]
# Get sensitivities[取得的敏感性]
#[]
lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$sens.coef.from
## Not run: [1] -1e+30  2e+00 -1e+30[#不运行:[1]-1E +30 2E +00 1E +30]
lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$sens.coef.to  
## Not run: [1] 4.50e+00 1.00e+30 1.35e+01[#不运行:[1] 4.50E +00 1.00E +30 1.35e +01]
#[]
# Right now the dual values for the constraints and the variables are[眼下的约束和变量的双值]
# combined, constraints coming first. So in this example...[相结合,约束第一。因此,在这个例子中...]
#[]
lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$duals     
## Not run: [1]   4.5   0.0  -3.5   0.0 -10.5[#不运行:[1] 4.5 0.0 -3.5 0.0 -10.5]
#[]
# ...the duals of the constraints are 4.5 and 0, and of the variables,[...偶的约束分别为4.5和0,变量,]
# -3.5, 0.0, -10.5. Here are the lower and upper limits on these:[3.5,0.0,-10.5。以下是对这些的下限和上限的:]
#[]
lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$duals.from
## Not run: [1]  0e+00 -1e+30 -1e+30 -1e+30 -6e+00[#不运行:[1] 0E +00 1E +30 1E +30 1E +30-6E +00]
lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)$duals.to  
## Not run: [1] 1.5e+01 1.0e+30 3.0e+00 1.0e+30 3.0e+00[#不运行:[1] 1.5E +01 1.0E +30 3.0E +00 1.0E +30 3.0E +00]
#[]
# Run again, this time requiring that all three variables be integer[再次运行,这时候需要所有这三个变量是整数]
#[]
lp ("max", f.obj, f.con, f.dir, f.rhs, int.vec=1:3)
## Not run: Success: the objective function is 37[#不运行:成功:目标函数是37]
lp ("max", f.obj, f.con, f.dir, f.rhs, int.vec=1:3)$solution
## Not run: [1] 1 4 0[#不运行:[1] 1 4 0]
#[]
# You can get sensitivities in the integer case, but they're harder to[您可以在整数的情况下的灵敏度,但他们更难]
# interpret.[解释。]
#[]
lp ("max", f.obj, f.con, f.dir, f.rhs, int.vec=1:3, compute.sens=TRUE)$duals
## Not run: [1] 1 0 0 7 0[#不运行:[1] 1 0 0 7 0]
#[]
# Here's an example in which we want more than one solution to a problem[下面是一个例子中,我们要一个以上的解决问题的办法]
# in which all variables are binary: the 8-queens problem, [中的所有变量都是二进制的:八皇后问题,]
# with dense constraints.[与浓密的限制。]
#[]
chess.obj <- rep (1, 64)
q8 <- make.q8 ()
chess.dir <- rep (c("=", "<"), c(16, 26))
chess.rhs <- rep (1, 42)
lp ('max', chess.obj, , chess.dir, chess.rhs, dense.const = q8,
    all.bin=TRUE, num.bin.solns=3)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-23 18:36 , Processed in 0.023649 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表