Skip to content

Adding constants to parameters in the objective #125

@bnarum

Description

@bnarum

Hi

I found an issue when trying out this package. It seems an error occurs when trying to add a constant to a parameter in the objective.

Here is an example:

using JuMP, ParametricOptInterface, Gurobi
const POI = ParametricOptInterface
optimizer = () -> POI.Optimizer(Gurobi.Optimizer())

mdl = Model(optimizer)
@variable(mdl, p in POI.Parameter(1.0))
@variable(mdl, 0 <= x <= 1)
@objective(mdl, Max, (p + 0.5) * x)
optimize!(mdl)
@show objective_value(mdl)
@show value(objective_function(mdl))

objective_value(mdl) = 0.5

value(objective_function(mdl)) = 1.5

The optimal solution should be 1.5, but it becomes 0.5. It is as if the parameter goes to zero when added to a constant. This seems to only happen in the objective, not for constraints.

Using JuMP v1.3.0, ParametricOptInterface v0.4.3 and Gurobi v0.11.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions