我试图解决一个非线性优化问题,其中目标函数是非线性的,约束是线性的。我在 R 中阅读了一些关于 ROI 包的内容,并决定使用它。但是,我在解决优化问题时遇到了问题。
我本质上是试图最小化供需曲线下的面积。供需曲线的方程在代码中定义:
目标函数:最小化(供给曲线积分+需求曲线积分),
受约束q大于或等于34155(存储在称为ICR的变量中),
q大于或等于0
且q小于或等于40000 .
我试图通过 RStudio 中的 ROI 包运行它,但我不断收到错误消息,告诉我找不到求解器。
library(tidyverse)
library(ROI)
library(rSymPy)
library(mosaicCalc)
# Initializing parameters for demand curve
A1 <- 6190735.2198302800
B1 <- -1222739.9618776600
C1 <- 103427.9556133250
D1 <- -4857.0627045073
E1 <- 136.7660814828
# Initializing parameters for Supply Curve
S1 <- -1.152
S2 <- 0.002
S3 <- a-9.037e-09
S4 <- 2.082e-13
S5 <- -1.64e-18
ICR <- 34155
demand_curve_integral <- antiD(A1 + B1*q + C1*(q^2)+ D1*(q^3) + E1*(q^4) ~q)
supply_curve_integral <- antiD(S1 + S2*(q) + S3*(q^2) + S4*(q^3) + S5*(q^4)~q)
# Setting up the objective function
obj_func <- function(q){ (18.081*demand_curve_integral(q))+supply_curve_integral(q)}
# Setting up the optimization Problem
lp <- OP(objective = F_objective(obj_func, n=1L),
constraints=L_constraint(L=matrix(c(1, 1, 1), nrow=3),
dir=c(">=", ">=", "<="),
rhs=c(ICR, 0, 40000, 1))),
maximum = FALSE)
sol <- ROI_solve(lp)
这是我在 RStudio 中不断遇到的错误:
Error in ROI_solve(lp) : no solver found for this signature:
objective: F
constraints: L
bounds: V
cones: X
maximum: FALSE
C: TRUE
I: FALSE
B: FALSE
我应该怎么做才能纠正这个错误?