Skip to content

Commit

Permalink
fix: adding node inequality constraints
Browse files Browse the repository at this point in the history
add_inequality_feature allows for a function to specify
a value for an inequality constraint to be added to an interpolator
  • Loading branch information
Lachlan Grose committed Feb 7, 2022
1 parent 247b3ff commit de33914
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions LoopStructural/interpolators/discrete_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,31 @@ def add_inequality_constraints_to_matrix(self, A, l, u, idc, name="undefined"):
}
self.ineq_const_c+=idc.shape[0]

def add_inequality_feature(self,feature,lower=True,mask=None):

# add inequality value for the nodes of the mesh
# flag lower determines whether the feature is a lower bound or upper bound
# mask is just a boolean array determining which nodes to apply it to

value = feature(self.support.nodes)
if mask is None:
mask = np.ones(value.shape[0],dtype=bool)
l=np.zeros(value.shape[0])-np.inf
u=np.zeros(value.shape[0])+np.inf
if lower:
l[mask] = value[mask]
if not lower:
u[mask] = value[mask]

self.add_inequality_constraints_to_matrix(
np.ones((value.shape[0],1)),
l,
u,
np.arange(0, self.nx,dtype=int),

)


def add_tangent_constraints(self, w=1.0):
"""
Expand Down
3 changes: 3 additions & 0 deletions LoopStructural/modelling/features/geological_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def __getitem__(self, key):
def __setitem__(self, key, item):
self._attributes[key] = item

def __call__(self, xyz):
return self.evaluate_value(xyz)

def set_model(self, model):
self.model = model

Expand Down

0 comments on commit de33914

Please sign in to comment.