def test_2_efm_intersection(self): V = np.array([[1, 1, 1], [1, 0, 0], [-1, -5, -3], [0, 10, 0]]) i2r_id = {0: 'r1', 1: 'r2', 2: 'r3', 3: 'r4'} r_id2direction = get_2_efm_intersection(get_support(V), 0, 1, i2r_id) self.assertDictEqual({'r1': 1, 'r3': -1}, r_id2direction, 'Intersection was supposed to be r1, -r3 reactions, got %s' % str(r_id2direction))
def get_efm_intersection(self, efm_ids=None, r_ids=None): V = self.pws.get_support_V() if efm_ids and len(efm_ids) == 1: return self.pws.get_r_id2coeff(next(iter(efm_ids)), r_ids) r_ids = sorted(r_ids if r_ids else self.r_ids) i2r_id = dict(enumerate(r_ids)) V = V[[self.r_id2i[r_id] for r_id in r_ids], :] if efm_ids and len(efm_ids) == 2: return get_2_efm_intersection(V, self.efm_id2i[efm_ids[0]], self.efm_id2i[efm_ids[1]], i2r_id) if efm_ids: V = V[:, [self.efm_id2i[efm_id] for efm_id in efm_ids]] return get_efm_intersection(V, i2r_id)