Skip to content

Commit

Permalink
fix: adding non-linear constraint template
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Oct 5, 2021
1 parent 1be8a45 commit 03b9e73
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions LoopStructural/interpolators/discrete_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, support):
self.eq_const_col = []
self.eq_const_d = []
self.eq_const_c_ = 0
self.non_linear_constraints = []
self.constraints = {}
self.interpolation_weights= {}
logger.info("Creating discrete interpolator with {} degrees of freedom".format(self.nx))
Expand Down Expand Up @@ -177,15 +178,18 @@ def add_constraints_to_least_squares(self, A, B, idc, name='undefined'):
rows += self.c_
constraint_ids = rows.copy()

if name in self.constraints:
if name in self.constraints:
count = 0
if '_' in name:
count = int(name.split('_')[0])+1
name = name + '_{}'.format(count)

self.constraints[name]['A'] = np.vstack([self.constraints[name]['A'],A])
self.constraints[name]['B'] = np.hstack([self.constraints[name]['B'], B])
self.constraints[name]['idc'] = np.vstack([self.constraints[name]['idc'],
idc])
# self.constraints[name]['A'] = A#np.vstack([self.constraints[name]['A'],A])
# self.constraints[name]['B'] = B#np.hstack([self.constraints[name]['B'], B])
# self.constraints[name]['idc'] = idc#np.vstack([self.constraints[name]['idc'],
# idc])

if name not in self.constraints:
self.constraints[name] = {'node_indexes':constraint_ids,'A':A,'B':B.flatten(),'idc':idc}
self.constraints[name] = {'node_indexes':constraint_ids,'A':A,'B':B.flatten(),'idc':idc}
rows = np.tile(rows, (A.shape[-1], 1)).T

self.c_ += nr
Expand Down Expand Up @@ -272,8 +276,11 @@ def add_equality_constraints(self, node_idx, values):
self.eq_const_row.extend((np.arange(0, idc[outside].shape[0])))
self.eq_const_d.extend(values[outside].tolist())
self.eq_const_c_ += idc[outside].shape[0]

def add_non_linear_constraints(self, nonlinear_constraint):
self.non_linear_constraints.append(nonlinear_constraint)

def add_tangent_ctr_pts(self, w=1.0):
def add_tangent_constraints(self, w=1.0):
"""
Parameters
Expand Down

0 comments on commit 03b9e73

Please sign in to comment.