I made a model and added binary decision variables into a data structure like the following in Python:
model = grb.Model()
x[i,j] = model.addVar(......)
y[i,j] = model.addVar(......)
model._data = x, y
Then in another function I can extract those groups of variables, i.e. x, y, like
x, y = model._data
Now I want to make a copy of the original model and manipulate the copy and solve it again. the code is something like
copy = model.copy()
This is a good copy of the original model but it does not copy my data structure of x, y. When I call the following function
x, y = copy._data
for i in y:
y[i].ub = 0
The line of 'x, y = copy._data' will throw an error of 'AttributeError: 'gurobipy.Model' object has no attribute '_data''. then I cannot manipulate y with their upper bounds.
Can anyone give me some suggestions about how to copy a model and its data structures of decision variables simultaneously?
Please sign in to leave a comment.