Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining work #19

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions gfosd/components/equality_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,34 @@ def _make_B(self):
def _make_c(self):
self._c = np.concatenate([np.atleast_1d(self._c[-1]),
[self._last_val]])


class ValsEqual(GraphComponent):
def __init__(self, indices=0, value=0, *args, **kwargs):
self.indices = np.atleast_1d(indices)
self._val = value
super().__init__(*args, **kwargs)
# always retain helper variable
self._has_helpers = True

def _make_A(self):
super()._make_A()
super()._make_B()
super()._make_c()
self._A = sp.bmat([
[self._A.tocsr()[-1]],
[sp.dok_matrix((len(self.indices), self._A.shape[1]))]
])

def _make_B(self):
self._B = sp.bmat([
[self._B.tocsr()[-1]], #XXXXX got to here! need to update this matrix generating function to identify all indices that are to be set equal
[sp.coo_matrix(([1], ([0], [self._B.shape[1]-1])), shape=(len(self.indices), self._B.shape[1]))]
])

def _make_c(self):
self._c = np.concatenate([np.atleast_1d(self._c[-1]),
[self.val] * len(self.indices)])

class AverageEqual(GraphComponent):
def __init__(self, value=0, period=None, *args, **kwargs):
Expand Down
Loading