ABS Function may not work
AnsweredGurobi outputs x=0 and y=-1 for the given straightforward model, contrary to the expected values of x=-1 and y=0. It appears that the ABS function might be malfunctioning. I seek clarification to determine if this discrepancy stems from ABS-related issues or a potential misunderstanding in my model formulation. Any insights or comments on this matter would be greatly appreciated.
----
Minimize
2 x + y
Subject To
diff: - x + y + diff1 = 0
abs_condition: absx >= 1
Bounds
-1 <= x <= 3
-1 <= y <= 3
Generals
x y
General Constraints
abs_value: absx = ABS ( diff1 )
End
------
# Objective value = -1
x 0
y -1
diff1 1
absx 1
------
-
Official comment
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi,
The issue is the lower bound of diff1. By default, variables have a lower bound of 0. Your solution x=-1 and y=0 is infeasible since it would require diff1=-1. If allow negative values for for diff1, you get the solution you expect.
Silke
0 -
Thank you.
I understand.
I can achieve the expected result by adding '-Inf <= diff1 <= Inf'.0
Post is closed for comments.
Comments
3 comments