model fingerprint is different in the log and when queried
回答済みHi Gurobi community,
I am finding that the fingerprint attribute of the model is different when Gurobi prints the log file and when the fingerprint is queried directly in the model object.
This is an easy script to run a model:
import gurobipy as gp
from gurobipy import GRB
# Create a new model
m = gp. Model (" mip1 ")
# Create variables
x = m. addVar ( vtype =GRB.BINARY , name ="x")
y = m. addVar ( vtype =GRB.BINARY , name ="y")
z = m. addVar ( vtype =GRB.BINARY , name ="z")
# Set objective
m. setObjective (x + y + 2 * z, GRB. MAXIMIZE )
# Add constraint : x + 2 y + 3 z <= 4
m. addConstr (x + 2 * y + 3 * z <= 4, "c0")
# Add constraint : x + y >= 1
m. addConstr (x + y >= 1, "c1")
# Optimize model
m. optimize ()
model_fingerprint = m.fingerprint
print("query_finger_print")
print(model_fingerprint)
This is the log that is printed:
....
Model fingerprint: 0xf43f5bdf
...
query_finger_print
-197174305
-197174305 is different from 0xf43f5bdf
Am I doing something wrong or is this the expected behaviour of the model fingerprint attribute?
-
正式なコメント
This post is more than three 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 why not try our AI Gurobot?. -
Hi Juan,
In Python, the fingerprint attribute is reported as a signed int. In order to match the fingerprint reported in the log, you have to convert it to an unsigned hex value via
print(hex(model.fingerprint & 0xFFFFFFFF))
This is a bit inconvenient but seems to be common practice in Python when converting integer with arbitrary length into their hexadecimal form.
Best regards,
Jaromił1 -
Thanks so much, Jaromil
0
投稿コメントは受け付けていません。
コメント
3件のコメント