Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JuMP rejects my non-linear objective for Hypatia but Convex.jl doesn't #3896

Closed
haansn08 opened this issue Nov 28, 2024 · 1 comment
Closed

Comments

@haansn08
Copy link

haansn08 commented Nov 28, 2024

I have a non-linear objective which is supported by the Hypatia solver (I think because my objective function can be rewritten to something linear and replaced with multiple "Logarithm cone" constraints, see equation (51a) of https://github.com/jump-dev/Hypatia.jl/wiki/files/coneref.pdf ). I know my program can be solved by Hypatia because Convex.jl seems to have no problem with it:

using Convex, Hypatia

winning_probabilities = Dict(
	[0,0] => 0.0134,
	[1,0] => 0.063,
	[0,1] => 0.4836,
	[1,1] => 0.44,
)
prices = [0.42, 0.8]

n = length(prices)
cash = Variable(1, Positive())
f = Variable(n, Positive())
objective = sum(p * log(cash + s'*(f./prices)) for (s,p) in winning_probabilities)
sum_one = cash + sum(f) == 1

problem = maximize(objective, sum_one)
solve!(problem, Hypatia.Optimizer)

However it seems JuMP doesn't like my objective and gives me an error:

using JuMP
model = Model(Hypatia.Optimizer)
@variable(model, cash, lower_bound=0, upper_bound=1)
@variable(model, f[1:n], lower_bound=0, upper_bound=1)
@constraint(model, cash + sum(f) == 1)
@objective(model, Max, sum(p * log(cash + s'*(f./prices)) for (s,p) in winning_probabilities))
# ERROR: The solver does not support an objective function of type MathOptInterface.ScalarNonlinearFunction.

I'm not sure if this is the right place to report this. If it is not, I apologize.

@odow
Copy link
Member

odow commented Nov 29, 2024

Hi there @haansn08, no need to apologize 😄

In future, a better place to ask questions is the community forum: https://discourse.julialang.org/c/domain/opt/13

I'm closing this issue because this is the expected behavior.

Convex implements disciplined convex programming. It can reformulate nonlinear programs into conic form if and only if they use the built-in atoms and satisfy the axioms of DCP. The problem you pass to Convex is reformulated into conic form before being passed to Hypatia.

JuMP does not implement DCP. It does not reformulate nonlinear expressions into conic form. Hypatia does not support scalar nonlinear functions, so it errors. If you want to use Hypatia with JuMP you must manually reformulate the problem into conic form.

@odow odow closed this as completed Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants