def PPNM_model(a,E, beta):
p = E.shape[1]
x = E*a
x = sum(x,beta*cp.square(x))
return x
def PPNM_model_cvxpy(a,E,beta):
first = E*a
second = beta*cp.square(first)
third = sum(first,second)
return third
def construct_ppnm_model(x_in,A,E, x_LMM, a_lmm):
p = E.shape[1]
d = E.shape[0]
N = A.shape[0]
x = np.zeros(shape=(N,d), dtype=np.float64)
a_ppnm = np.zeros(shape=(N,p), dtype=np.float64)
beta_ppnm = np.zeros(shape=(N,1), dtype=np.float64)
current_lmm = cp.Variable(p)
current_beta = cp.Variable()
b_min = 0
b_max = 100
all_zeros = np.squeeze(np.zeros(shape=(N,1), dtype=np.double))
sum_to_one_vector=np.ones(shape=(1,p),dtype=np.double)
for i in np.arange(0, N):
x_in_temp = x_in[i,:].astype(np.double)
current_lmm.value=a_lmm[i,]
objective =
cp.Minimize(cp.sum_squares((PPNM_model_cvxpy(current_lmm,
E, current_beta)) - x_in_temp))
constraints = [current_lmm >= 0,
current_lmm <= 1,
current_beta >= b_min,
current_beta <= b_max,
sum_to_one_vector*current_lmm == 1]
prob = cp.Problem(objective, constraints)
result = prob.solve()
a_ppnm[i,:]=current_lmm.value
beta_ppnm[i] = current_beta.value
current_vector = PPNM_model(a_ppnm[i,:], E, current_beta.value)
x[i,:]=current_vector
return x, a_ppnm, beta_ppnm
In this problem, matrix A
is of shape (10000, 4) which is (total pixels, endmembers), E
is of shape (198, 4) :(spectral bands, endmembers)
and x
is of shape (10000, 198) :( pixels, spectral bands)
When I call the construct_ppnm_model like this:
x_ppnm, a_ppnm, beta_ppnm = construct_ppnm_model(hsi_2d, A, E, x_LMM, a_lmm)
I get the following error message:
NotImplementedError: Strict inequalities are not allowed.