I have a question regarding accessing infeasible optimization results.

For example, the following optimization does not have a feasible solution. However, despite the infeasibility, it is still able to give the value of x and y.

model = Model()
set_optimizer(model, GLPK.Optimizer)
@variable(model, x >= 6.0)
@variable(model, y >= 6.0)
@objective(model, Max, 2* x + y )
@constraint(model, x+y <= 11.0)
@constraint(model, x >= 1.0)
optimize!(model)
value.(x)

When there is a semicontinuous variable, it returns the following errors when I was trying to get the variable value.

model = Model()
set_optimizer(model, GLPK.Optimizer)
@variable(model, x in MOI.Semicontinuous(6.0, 12.0))
@variable(model, y >= 6.0)
@objective(model, Max, 2* x + y )
@constraint(model, x >= 1.0)
@constraint(model, x+y <= 11.0)
optimize!(model)
value.(y)

Can someone help me to understand why I am able to get â€ścomprisedâ€ť results when there is no feasible solution? However, when I use semicontinuous variables, I cannot get the value of those variables?

It depends on the solvers, but some revert to minimizing the constraint violation when they detect that the problem is infeasible. In this case, the point that you retrieve may be a minimizer of the constraint violation.

To be clear, you should never rely on a solver returning an infeasible point, or that the infeasible point represents some minimal constraint violation.

The correct way to handle this is to use the status reporting mechanisms.

if termination_status(model) == MOI.INFEASIBLE
if primal_status(model) == MOI.NO_SOLUTION
# No solution is available. Calling `value(x)` may thrown an error or return arbitrary values.
elseif primal_status(model) == MOI.INFEASIBLE_POINT
# We know only that the point is infeasible. There are no guarantees of quality.
end
end

Thank you very much for your explanation. Despite the infeasibility, it sometimes is helpful to be able to get points where minimize the constraint violation. However, when I use semicontinuous variables, it seems that I cannot get the values.

I understand that we should not rely on infeasible results, however, it sometimes really helpful to be able to obtain minimal constraint violation points. It really helps me to further analyze the problem.

Is there any way I can obtain the â€śminimal constraint violation pointâ€ť when I have semicontinuous variables?