Skip to content

Commit 931d3c7

Browse files
committed
poly_con_rel class update
1 parent 51321c3 commit 931d3c7

4 files changed

Lines changed: 73 additions & 29 deletions

File tree

pplite/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
)
3434

3535
from .polyhedron import (
36-
NNC_Polyhedron
36+
NNC_Polyhedron, Polyhedron_Constraint_Rel
3737
)

pplite/polyhedron.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ cdef class Polyhedron_Constraint_Rel(object):
1313
cdef class Polyhedron_Generator_Rel(object):
1414
cdef Poly_Gen_Rel* thisptr
1515

16-
17-
1816
# cdef class Constraint_Proxy(object):
1917
# cdef Cons_Proxy c_proxy

pplite/polyhedron.pyx

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ from .constraint cimport Constraint
1010
from .generators cimport PPliteGenerator
1111
from .linear_algebra cimport Variable, Linear_Expression, Affine_Expression
1212
from .intervals cimport Interval
13+
from cysignals.signals cimport sig_on, sig_off
1314

1415
cdef class NNC_Polyhedron(object):
1516
r"""
@@ -677,18 +678,48 @@ cdef class Polyhedron_Constraint_Rel(object):
677678
def __cinit__(self):
678679
self.thisptr = NULL
679680
def __dealloc__(self):
681+
# assert self.thisptr!=NULL
680682
del self.thisptr
681-
def __init__(self):
682-
pass
683-
def nothing(self):
684-
pass
685-
def is_disjoint(self):
683+
def __repr__(self):
684+
rel = []
685+
if self.implies(Polyhedron_Constraint_Rel.is_disjoint()):
686+
rel.append('is_disjoint')
687+
if self.implies(Polyhedron_Constraint_Rel.strictly_intersects()):
688+
rel.append('strictly_intersects')
689+
if self.implies(Polyhedron_Constraint_Rel.is_included()):
690+
rel.append('is_included')
691+
if self.implies(Polyhedron_Constraint_Rel.saturates()):
692+
rel.append('saturates')
693+
if rel:
694+
return ', '.join(rel)
695+
else:
696+
return 'nothing'
697+
698+
@classmethod
699+
def nothing(cls):
700+
"""
701+
TESTS::
702+
>>> from pplite import Polyhedron_Constraint_Rel
703+
>>> Polyhedron_Constraint_Rel.nothing()
704+
nothing
705+
"""
706+
cdef Poly_Con_Rel rel = PPlite_NOTHING
707+
cdef Poly_Con_Rel * rel_pointer
708+
sig_on()
709+
try:
710+
rel_pointer = &rel
711+
relation = Polyhedron_Constraint_Rel()
712+
relation.thisptr = rel_pointer
713+
finally:
714+
sig_off()
715+
return relation
716+
def is_disjoint(cls):
686717
pass
687-
def strictly_intersects(self):
718+
def strictly_intersects(cls):
688719
pass
689-
def is_included(self):
720+
def is_included(cls):
690721
pass
691-
def saturates(self):
722+
def saturates(cls):
692723
pass
693724
def implies(self, other):
694725
pass
@@ -714,7 +745,7 @@ cdef Topol string_to_Topol(t):
714745
if t == "nnc":
715746
tt = Topol.NNC
716747
return tt
717-
raise ValueError("Topology type conversion failed.")
748+
raise ValueError("Unrecognized string {0}.".format(t))
718749

719750
cdef Spec_Elem string_to_Spec_Elem(s):
720751
cdef Spec_Elem ss
@@ -724,4 +755,24 @@ cdef Spec_Elem string_to_Spec_Elem(s):
724755
if s == "universe":
725756
ss = Spec_Elem.UNIVERSE
726757
return ss
727-
raise ValueError("Spec_Elem type conversion failed.")
758+
raise ValueError("Unrecognized string {0}.".format(s))
759+
760+
761+
762+
763+
cdef Poly_Con_Rel _new_Poly_Con_Rel(s):
764+
if s == "nothing":
765+
return PPlite_NOTHING
766+
767+
raise ValueError("Unrecognized string {0}.".format(s))
768+
769+
# cdef _new_Poly_Con_Rel_Nothing():
770+
# cdef Poly_Con_Rel rel = Polyhedron_Constraint_Rel()
771+
# rel.thisptr = new NOTHING
772+
# return rel
773+
774+
775+
# cdef _new_Poly_Gen_Rel():
776+
# rel = Polyhedron_Generator_Rel()
777+
# rel.thisptr = new Poly_Gen_Rel()
778+
# return rel

pplite/pplite_decl.pxd

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ cdef extern from "flint/fmpq.h":
5151
void fmpq_get_mpz_frac(mpz_t a, mpz_t b, fmpq_t c)
5252
void fmpq_set_si(fmpq_t res, slong p, ulong q)
5353

54-
# Starting pplite definitons
54+
# Starting pplite definitions
5555

5656
cdef extern from "pplite/pplite.hh" namespace "pplite":
5757

@@ -415,7 +415,6 @@ cdef extern from "pplite/pplite.hh" namespace "pplite":
415415

416416
# "pplite/Bits.hh"
417417

418-
419418
# "pplite/BBox.hh"
420419
# Note: We are explicitly defining the two possible Box classes.
421420

@@ -489,7 +488,6 @@ cdef extern from "pplite/pplite.hh" namespace "pplite":
489488
cppbool inf_ub(dim_type i)
490489
const FLINT_Rational& lb(dim_type i)
491490
const FLINT_Rational& ub(dim_type i)
492-
493491
# Itvs itvs
494492
# Volume_Info volume
495493

@@ -573,7 +571,7 @@ cdef extern from "pplite/pplite.hh" namespace "pplite":
573571
# MINIMIZED
574572
# PENDING
575573
# cdef struct Sys "Sys<Cons>"
576-
# struct Sys_
574+
577575
ctypedef struct cs "Sys<Cons>":
578576
pass
579577

@@ -630,7 +628,7 @@ cdef extern from "pplite/pplite.hh" namespace "pplite":
630628
cppbool max(const Affine_Expr& ae, FLINT_Rational& value, cppbool* included_ptr, Gen* g_ptr)
631629
Itv get_bounds(Var var)
632630
Itv get_bounds(Affine_Expr& ae)
633-
# # Itv get_bounds(Itv_Expr& ie)
631+
# Itv get_bounds(Itv_Expr& ie)
634632
# Index_Set get_unconstrained()
635633
size_t hash()
636634
Cons_Proxy cons() # not directly used.
@@ -684,7 +682,7 @@ cdef extern from "pplite/pplite.hh" namespace "pplite":
684682
void remove_higher_space_dims(dim_type new_dim)
685683
void expand_space_dim(Var var, dim_type m)
686684
# void fold_space_dims(const Index_Set& vars, Var dest)
687-
## semantically const, but may affect syntactic reper
685+
## semantically const, but may affect syntactic representation
688686
void minimize()
689687

690688
cppbool operator==(const Poly& x, const Poly& y)
@@ -713,7 +711,12 @@ cdef extern from "pplite/pplite.hh" namespace "pplite":
713711
Poly_Gen_Rel subsumes()
714712
cppbool implies(const Poly_Gen_Rel& y)
715713

716-
714+
Poly_Con_Rel PPlite_NOTHING "pplite::Poly_Con_Rel::nothing()"
715+
# Poly_Con_Rel IS_DISJOINT "Poly::Impl::IS_DISJOINT"
716+
# Poly_Con_Rel STRICTLY_INTERSECTS "Poly::Impl::STRICTLY_INTERSECTS"
717+
# Poly_Con_Rel IS_INCLUDED "Poly::Impl::IS_INCLUDED"
718+
# Poly_Con_Rel SATURATES "Poly::Impl::SATURATES"
719+
# Poly_Con_Rel EVERYTHING "Poly::Impl::EVERYTHING"
717720
# PPLite/U_Poly.hh
718721

719722
# cdef cppclass U_Wrap:
@@ -725,12 +728,4 @@ cdef extern from "pplite/pplite.hh" namespace "pplite":
725728

726729
# "pplite/mater_iterator.hh"
727730
# cdef struct[Sys, Impl] Mater_Sys:
728-
# pass
729-
730-
731-
732-
#to do define Sys<Cons>
733-
#define Sys<Gens>
734-
# this is in Poly_Impl
735-
# where is cons?
736-
# general question, in C++ code, how do you quickly find the names of things/backtrace this.
731+
# pass

0 commit comments

Comments
 (0)