我想知道是否有人能够建议一些软件包来解决非线性优化问题,该问题可以为最佳解决方案提供整数变量?问题是最小化具有等式约束的函数,该函数受一些下边界和上边界约束。
我在 R 中使用了 'nloptr' 包来解决非线性优化问题,该问题效果很好,但现在想扩展该方法以将某些变量作为整数。从我到目前为止对 nloptr 的使用和理解来看,它只能返回连续变量,而不是整数变量以获得最佳解决方案。
我相信这类问题需要使用混合整数非线性规划来解决。
nloptr 形式的问题的一个示例:
min f(x) (x-y)^2/y + (p-q)^2/q
so that (x-y)^2/y + (p-q)^2/q = 10.2
where
x and p are positive integers not equal to 0
and
y and q may or may not be positive integers not equal to 0
Run Code Online (Sandbox Code Playgroud)
R 中的 nloptr 代码如下所示
library('nloptr')
x1 <- c(50,25,20,15)
fn <- function(x) {
(((x[1] - x[2])^2)/x[2]) + (((x[3] - x[4])^2)/x[4])
}
heq <- function(x) {
fn(x)-10.2
}
lower_limit <- c(0,0,0,0)
upper_limit <- …Run Code Online (Sandbox Code Playgroud)