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

Handling constant in objective for max problems v0.18 #1390

Closed
GillesBareilles opened this issue Aug 2, 2018 · 2 comments
Closed

Handling constant in objective for max problems v0.18 #1390

GillesBareilles opened this issue Aug 2, 2018 · 2 comments

Comments

@GillesBareilles
Copy link

Hi there,

I'm having some trouble when solving maximisation problems with a non null constant with JuMP; here is a small example, along with the output.

using JuMP, SCS

function run_SDPpb(cst, optsense)
    # m = Model(solver=MosekSolver(LOG=0))
    m = Model(solver=SCSSolver(verbose=0))

    @variable(m, Xs1[1:3,1:3], SDP)
    @variable(m, Xs2[1:1,1:1], SDP)
    @variable(m, Xs3[1:1,1:1], SDP)

    @constraint(m, Xs1[1,1] == 1)
    @constraint(m, Xs2[1,1] + Xs1[2,2] + Xs1[3,3] == 4)
    @constraint(m, Xs3[1,1] - Xs1[2,1] - Xs1[3,1] == 0)

    # Find upper bound
    @objective(m, optsense, -Xs1[1,3]+cst)
    solve(m)
    return getobjectivevalue(m)
end

@show run_SDPpb(0., :Min)
@show run_SDPpb(0.5, :Min)

@show run_SDPpb(0., :Max)
@show run_SDPpb(0.5, :Max)

Which gives the following output:

run_SDPpb(0.0, :Min) = -2.000000252312453
run_SDPpb(0.5, :Min) = -1.5000002523124532
run_SDPpb(0.0, :Max) = 1.4141624244050313
run_SDPpb(0.5, :Max) = 0.9141624244050313

When solving maximization problems max (f(x) + c), it seems value returned by getobjectivevalue is max(f(x)) - c.

More precisely, JuMP seems to only pass minimzation problems to solvers (at least for SDP), so the objective should be max (f(x) + c) = - min (-f(x)-c) = (-min -f(x) ) + c, while it seems to be (-min -f(x) + c) = (-min -f(x) ) - c.

I am working with

  • JuMP 0.18.2
  • MathProgBase 0.7.2
@mlubin
Copy link
Member

mlubin commented Aug 2, 2018

Yes, this looks like a bug. Thanks for reporting!

@mlubin
Copy link
Member

mlubin commented Jan 5, 2019

Fixed on the release-0.18 branch by #1727. The bug does not apply to master.

@mlubin mlubin closed this as completed Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants