-
-
Notifications
You must be signed in to change notification settings - Fork 411
Closed
Labels
Status: Help WantedHelp is welcome on this issueHelp is welcome on this issueType: Feature requestgood first issueThis issue is recommended for new users, it does not require a thorough understanding of the packageThis issue is recommended for new users, it does not require a thorough understanding of the package
Description
I would like to access the objective coefficients yet it just possible to access the function as an expression.
My solution would be:
"""
objective_coefficient(model::Model, variable::VariableRef)
Return the coefficient associated with `variable` in the objective function. See
also [`set_objective_coefficient`](@ref).
Note: this function will throw an error if a nonlinear objective is set.
"""
function objective_coefficient(model::Model, variable::VariableRef)
return get(objective_function(model).terms, variable, 0.0)
endYet, I have no idea how quadratic objective functions should be handled and what to do if someone tries the following
model_1 = Model()
@variable(model_1, x >= 0)
@objective(model_1, Min, x)
model_2 = Model()
@variable(model_2, y >= 0)
@objective(model_2, Min, y)
objective_coefficient(model_1, y)Metadata
Metadata
Assignees
Labels
Status: Help WantedHelp is welcome on this issueHelp is welcome on this issueType: Feature requestgood first issueThis issue is recommended for new users, it does not require a thorough understanding of the packageThis issue is recommended for new users, it does not require a thorough understanding of the package