def test_Vertices_Nonsym(self): """Tests the vertices of a nonsymetric space.""" self.k = numpy.matrix([[6], [12], [2], [10]]) self.p = polytope.HPolytope(self.H, self.k) vertices = self.p.Vertices() self.AreVertices(self.p, vertices) self.HasSamePoints( numpy.matrix([[6., 2.], [6., -10.], [-12., -10.], [-12., 2.]]), vertices)
def test_Skewed_Nonsym_Vertices(self): """Tests the vertices of a severely skewed space.""" self.H = numpy.matrix([[10, -1], [-1, -1], [-1, 10], [10, 10]]) self.k = numpy.matrix([[2], [2], [2], [2]]) self.p = polytope.HPolytope(self.H, self.k) vertices = self.p.Vertices() self.AreVertices(self.p, vertices) self.HasSamePoints( numpy.matrix([[0., 0.2], [0.2, 0.], [-2., 0.], [0., -2.]]), vertices)
def setUp(self): """Builds a simple box polytope.""" self.H = numpy.matrix([[1, 0], [-1, 0], [0, 1], [0, -1]]) self.k = numpy.matrix([[12], [12], [12], [12]]) self.p = polytope.HPolytope(self.H, self.k)
def MakePWithDims(self, num_constraints, num_dims): """Makes a zeroed out polytope with the correct size.""" self.p = polytope.HPolytope( numpy.matrix(numpy.zeros((num_constraints, num_dims))), numpy.matrix(numpy.zeros((num_constraints, 1))))