@@ -276,7 +276,7 @@ cdef class NNC_Polyhedron(object):
276276 raise TypeError (" other_poly needs to be of :class:`NNC_Polyhedron`" )
277277
278278 def get_bounding_box (self ):
279- pass
279+ raise NotImplementedError
280280
281281 def boxed_contains (self , other_poly ):
282282 cdef Poly* yy
@@ -372,7 +372,7 @@ cdef class NNC_Polyhedron(object):
372372 return i
373373
374374 def _get_boundes_itv (self , itv_expr ):
375- pass
375+ raise NotImplementedError
376376
377377 def get_bounds (self , variable_or_affine_expr ):
378378 if isinstance (variable_or_affine_expr, Variable):
@@ -382,27 +382,31 @@ cdef class NNC_Polyhedron(object):
382382 raise TypeError (" A :class:`Variable` or a :class:`Affine_Expression` should be passed into this method." )
383383
384384 def get_unconstrainted (self ):
385- pass
385+ raise NotImplementedError
386386
387+
388+ # For both the constraints and generators methods should be implemented via cons_sys and gens_sys.
389+ # At the moment, we use the copy constructor because it was easier to write.
387390 def constraints (self ):
388- # Access constraints indirectly via copy_cons()
389- # TODO: Properly implement via sys and Cons_Proxy in Poly_Impl
391+ """
392+ Returns a list of :class:`Constraint` of the polyhedron.
393+
394+ Note: the constraints space dim is not necessarily the ambient space dim of the poly.
395+ """
390396 cdef Cons constraint_vector
391397 constraint_vector = self .thisptr[0 ].copy_cons()
392398 result = []
393399 cdef unsigned int index = constraint_vector.size() # hacky way to iterate over vectors
394400 for i in range (index):
395- c = Constraint()
401+ c = Constraint(i )
396402 c.thisptr = new Con(constraint_vector[i])
397403 result.append(c)
398404 return result
399405
400406 def generators (self ):
401407 """
402- Returns a list of :class:`PPliteGenerator`.
408+ Returns a list of :class:`PPliteGenerator`of the polyhedron .
403409 """
404- # Access constraints indirectly via copy_cons()
405- # TODO: Properly implement via sys and Cons_Proxy in Poly_Impl
406410 cdef Gens generator_vector
407411 generator_vector = self .thisptr[0 ].copy_gens()
408412 result = []
@@ -414,8 +418,7 @@ cdef class NNC_Polyhedron(object):
414418 return result
415419
416420 def normalized_constraints (self ):
417- # TODO implement once Cons_Proxy is implemented.
418- pass
421+ raise NotImplementedError
419422
420423 def num_min_constrains (self ):
421424 return self .thisptr[0 ].num_min_cons()
@@ -461,6 +464,9 @@ cdef class NNC_Polyhedron(object):
461464 self .thisptr[0 ].set_empty()
462465
463466 def set_topology (self , topology ):
467+ """
468+ Sets the topology of the NNC polyhedron as either "closed" or "nnc".
469+ """
464470 cdef Topol tt
465471 tt = string_to_Topol(topology)
466472 self .thisptr[0 ].set_topology(tt)
@@ -585,8 +591,9 @@ cdef class NNC_Polyhedron(object):
585591 v = (< Variable> variable).thisptr
586592 self .thisptr[0 ].unconstrain(v[0 ])
587593
588- def unconstain_many (self , iter_of_var_or_index_set ):
589- pass
594+ def unconstain_many (self , iter_of_vars ):
595+ for var in iter_of_vars:
596+ self .unconstain(var)
590597
591598 def intersection_assign (self , other_poly ):
592599 if isinstance (other_poly, NNC_Polyhedron):
@@ -640,20 +647,32 @@ cdef class NNC_Polyhedron(object):
640647 den = Python_int_to_FLINT_Integer(denominator)
641648 self .thisptr[0 ].affine_preimage(var[0 ], expr, inhomo, den)
642649
643- # TODO: Implement these
644- def parallel_affine_image (self , args ):
645- pass
650+ def parallel_affine_image (self ):
651+ raise NotImplementedError
646652
647653 def widing_assign (self , args ):
648- pass
654+ raise NotImplementedError
649655
650656 def time_elapse_assign (self , other_poly ):
651657 if isinstance (other_poly, NNC_Polyhedron):
652658 y = (< NNC_Polyhedron> other_poly).thisptr
653659 self .thisptr[0 ].time_elapse_assign(y[0 ])
654660
655- def minimize (self ):
656- self .thisptr[0 ].minimize()
661+ def split (self , constraint , topology ):
662+ if isinstance (constraint, Constraint):
663+ con = (< Constraint> constraint).thisptr
664+ cdef Topol tt
665+ tt = string_to_Topol(topology)
666+ new_poly = NNC_Polyhedron()
667+ new_poly.thisptr = new Poly(self .thisptr[0 ].split(con[0 ], tt))
668+ return new_poly
669+
670+ def integral_split (self , constraint ):
671+ if isinstance (constraint, Constraint):
672+ con = (< Constraint> constraint).thisptr
673+ new_poly = NNC_Polyhedron()
674+ new_poly.thisptr = new Poly(self .thisptr[0 ].integral_split(con[0 ]))
675+ return new_poly
657676
658677 def add_space_dimensions (self , dim_to_add , projection ):
659678 cdef cppbool project
@@ -668,6 +687,26 @@ cdef class NNC_Polyhedron(object):
668687 else :
669688 raise TypeError (" dim_to_add needs to be an ``int``." )
670689
690+ def concatenate_assign (self , poly ):
691+ if isinstance (poly, NNC_Polyhedron):
692+ p = (< NNC_Polyhedron> poly).thisptr
693+ self .thisptr[0 ].concatenate_assign(p[0 ])
694+
695+ def remove_higher_space_dims (self , new_dim ):
696+ cdef dim_type d
697+ d = Python_int_to_FLINT_Integer(new_dim)
698+ self .thisptr[0 ].remove_higher_space_dims(d)
699+
700+ def expand_space_dim (self , variable , dim_m ):
701+ cdef dim_type d
702+ d = Python_int_to_FLINT_Integer(dim_m)
703+ if isinstance (variable, Variable):
704+ var = (< Variable> variable).thisptr
705+ self .thisptr[0 ].expand_space_dim(var[0 ], d)
706+
707+ def minimize (self ):
708+ self .thisptr[0 ].minimize()
709+
671710# ####################################
672711# ## Poly_Con_Rel and Poly_Gen_Rel ###
673712# ####################################
@@ -774,9 +813,6 @@ cdef class Polyhedron_Generator_Rel(object):
774813 def implies (self , Polyhedron_Generator_Rel y ):
775814 return self .thisptr.implies(y.thisptr[0 ])
776815
777-
778- # TODO Migrate helper functions to a helper function module.
779-
780816# ########################
781817# ## Helper Functions ###
782818# ########################
@@ -799,24 +835,4 @@ cdef Spec_Elem string_to_Spec_Elem(s):
799835 if s == " universe" :
800836 ss = Spec_Elem.UNIVERSE
801837 return ss
802- raise ValueError (" Unrecognized string {0}." .format(s))
803-
804-
805-
806-
807- # cdef Poly_Con_Rel _new_Poly_Con_Rel(s):
808- # if s == "nothing":
809- # return PPlite_NOTHING
810-
811- # raise ValueError("Unrecognized string {0}.".format(s))
812-
813- # cdef _new_Poly_Con_Rel_Nothing():
814- # cdef Poly_Con_Rel rel = Polyhedron_Constraint_Rel()
815- # rel.thisptr = new NOTHING
816- # return rel
817-
818-
819- # cdef _new_Poly_Gen_Rel():
820- # rel = Polyhedron_Generator_Rel()
821- # rel.thisptr = new Poly_Gen_Rel()
822- # return rel
838+ raise ValueError (" Unrecognized string {0}." .format(s))
0 commit comments