x <- Variable(2)
cost <- geo_mean(x)
prob <- Problem(Maximize(cost), list(sum(x) <= 1))
result <- solve(prob)
result$value
result$getValue(x)
if (FALSE) {
x <- Variable(5)
p <- c(0.07, 0.12, 0.23, 0.19, 0.39)
prob <- Problem(Maximize(geo_mean(x,p)), list(p_norm(x) <= 1))
result <- solve(prob)
result$value
result$getValue(x)
}
Run the code above in your browser using DataLab