如何在CVXR中求解具有不同底数的指数项的目标函数?

问题描述

我正在使用CVXR来求解凹目标函数。决策变量(x)是一维的,目标函数是2个对数项的总和,其中第二项是指数的,且底数为“ ab”(例如a^xb^x); “ ab”是常量。

我的完整目标函数是:

(-x*sum(ln(y))) + ln((1-x)/((a^(1-x))-(b^(1-x))))

其中y是给定的一维数据向量。

当我将具有(a^xb^x)的第二项添加到目标函数时,我不断得到

Error in a^(1 - x): non-numeric argument to binary operator

CVXR中是否有任何原子函数可用于编码constant^x? 这是我的代码:

library(CVXR)
a <- 7
b <- 0.3
M=1000
x_i # is a given vector of 1-D data

x <- Variable(1)
nominator <- (1-x)
denominator <- (1/((a^(1-x))-(b^(1-x))))
obj <- (-xsum(log(x_i)) + Mlog(nominator/denominator)) # change M to the length of X_i later
constr <- list(x>0)
prob <- Problem(Maximize(obj),constr)
result <- solve(prob)
alpha_hat <- result$getValue(x)

请告诉我我在做什么错。非常感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...