My goal is to minimize the norm between the solution and a given matrix, I figured the best way to express it is via np.linalg.norm(x - ref_matrix). Essentially I want the solution matrix to deviate the least possible from a given matrix.
However, the command x - ref_matrix is not valid and I don't know how to implement such logic
ref_matrix = np.random.rand(79,682)
m = gp.Model()
x = m.addMVar(ref_matrix.shape, lb=0.0, ub=1.0)
for i in range(x.shape):
m.addConstr(x[i, :].sum() <= 1, name='date' + str(i))
m.setObjective(np.linalg.norm(x - ref_matrix), sense=gp.GRB.MINIMIZE)
This will yield the following error:
gurobipy.GurobiError: Variable is not a 1D MVar object
Please sign in to leave a comment.