When trying to minimise an objective through CVXPY, I have two different optimisation problems. When a parameter alpha is set to 0, both these objectives should give the same minimisation results. But for me it gives two different results.
These are the two problems Problem 1 :
w = cp.Variable(shape = m)
alpha = cp.Parameter(nonneg=True)
w_sb = w[some_edge_indices]
w_ob = w[other_edge_indices]
MKw = MK @ w
MKsbwb = MK_sb @ w_sb
MKobwb = MK_ob @ w_ob
MKswm = MK_some @ w_some
MKowm = MK_other @ w_other
alpha.value = alph
obj1 = cp.sum_squares(MKw)
obj2 = cp.sum_squares(MKsbwb - MKswm)
obj3 = cp.sum_squares(MKobwb - MKowm)
reg = obj2 + obj3
objective = cp.Minimize(obj1 + alpha*(reg))
constraints = [AK@w >= np.ones((n,))]
prob = cp.Problem(objective, constraints)
result = prob.solve()
Consider all the unknows variables to be some given matrices. Also alph is a given value.
Problem 2:
w = cp.Variable(shape = m)
MKw = MK @ w
obj1 = cp.sum_squares(MKw)
objective = cp.Minimize(obj1)
constraints = [AK@w >= np.ones((n,))]
prob = cp.Problem(objective, constraints)
result = prob.solve()
Here, as we can see when alpha = 0, both the objectives should return the same w. But it is giving different w values. What could be the reason?