def calc_cost(self): cost = sum(self.E[key] * self.E[key] for key in self.E) cost += self.l*(np.vdot(self.B, self.B) + np.vdot(self.C, self.C)) return cost