---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [79], in <cell line: 26>()
22 m.d[j] = m.z[j] == sum([m.a[i] for i in range(n)])
24 return m
---> 26 svm_conic(X_train, y_train, 1)
Input In [79], in svm_conic(X, y, c)
20 m.d = pmo.constraint_dict()
21 for j in range(p + 1):
---> 22 m.d[j] = m.z[j] == sum([m.a[i] for i in range(n)])
24 return m
File ~/opt/anaconda3/lib/python3.9/site-packages/pyomo/core/kernel/dict_container.py:78, in DictContainer.__setitem__(self, key, item)
77 def __setitem__(self, key, item):
---> 78 if item.ctype is self.ctype:
79 if item._parent is None:
80 if key in self._data:
AttributeError: 'EqualityExpression' object has no attribute 'ctype'
import pyomo.kernel as pmo
def svm_conic(X, y, c):
n, p = X.shape
F = np.append(np.ones((n, 1)), X.to_numpy(), axis=1)
m = pmo.block()
m.r = pmo.variable()
m.a = pmo.variable_dict()
for i in range(n):
m.a[i] = pmo.variable(domain_type=pmo.RealSet)
m.z = pmo.variable_dict()
for j in range(p + 1):
m.z[j] = pmo.variable(domain_type=pmo.RealSet)
m.d = pmo.constraint_dict()
for j in range(p + 1):
m.d[j] = m.z[j] == sum([m.a[i] for i in range(n)])
return m
svm_conic(X_train, y_train, 1)