Ask Your Question
0

Compute intersection of cone with lattice?

asked 2024-12-04 18:11:20 +0100

xion3582 gravatar image

updated 2024-12-12 16:46:07 +0100

My question: Consider a full dimension cone and a full rank lattice in $\mathbb{R}^d$ (so the cone and lattice each have $d$ generators, with potentially non-integer coordinates). Does Sage have functions to compute their intersection?

For me, a cone $C$ with generators $v_1, \ldots, v_d$ is the set of all combinations $\sum_{i} c_i v_i \text{ with } c_i \in \mathbb{R}_{>0}$.

Meanwhile, a lattice $L$ with generators $v_1, \ldots, v_d$ is the set of all combinations $\sum_{i} n_i v_i \text{ with } n_i \in \mathbb{Z}$.

I want the intersection of $C$ and $L$ (modulo positive translates of the cone generators). As such, it might suffice to compute the intersection between a "fundamental parallelpiped" for $C$ and the lattice $L$... Perhaps with a condition on the relationship between the generators of $C$ and $L$?

I am currently constructing my cones with the "convex rational polyhedral cones" module. And I couldn't find a class for a lattice with non-integer coordinates (I only found the "Integral lattices" module). When $d = 2$, I might write

cone_generators = [[1.1, 2.3], [3, 0.2]]
cone = Cone(cone_generators).interior()
lattice_generators = [[1, 0], [0.2, 0.3]]
lattice = ??
intersection = ?? (modulo positive translates of the cone generators)

Context of question, in case helpful: The problem arises from algebraic number theory. I am regarding (fractional) ideals in number fields as lattices via the embeddings of the number field. See Conrad's "The Different Ideal" for some pictures/examples -- pdf available online, my karma is insufficient to include a link.

I'd like to determine the intersection between those lattices and various cones.

edit retag flag offensive close merge delete

Comments

1

Unless there is a better solution, you can construct lattice as a cone with original generators and their negations:

lattice = Cone( lattice_generators + [-vector(v) for v in lattice_generators] )
Max Alekseyev gravatar imageMax Alekseyev ( 2024-12-04 20:59:08 +0100 )edit

Would that generate a lattice? My understanding of Cone is that it uses non-negative real combinations of vectors, while a lattice uses integer combinations.

And I would still remain at a loss for the intersection. When I try code like

cone1.intersection(cone2.lattice())

I get an error "no common canonical parent for objects with parents Polyhedra and ToricLattice".

xion3582 gravatar imagexion3582 ( 2024-12-06 19:04:07 +0100 )edit

Indeed, I thought about integer cones, which is not the case with Cone(). In what form you expect to see the result of intersection of a cone and a lattice?

Max Alekseyev gravatar imageMax Alekseyev ( 2024-12-07 14:41:44 +0100 )edit

Mmmm thank you for asking, I've edited my question with some discussion. I want the intersection of $C$ and $L$ modulo positive translates of the cone generators (and then I can add linear combos of cone generators to get other lattice points in the cone).

xion3582 gravatar imagexion3582 ( 2024-12-07 16:12:55 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2024-12-07 18:31:41 +0100

Max Alekseyev gravatar image

updated 2024-12-07 20:05:09 +0100

Perhaps, your best shot would be using Normaliz either as a backend of Polyhedron(), or directly via PyNormaliz. A sample code via MILP construction:

cone_generators = [vector(QQ,v) for v in [[1.1, 2.3], [3, 0.2]]]
lattice_generators = [vector(QQ,v) for v in [[1, 0], [0.2, 0.3]]]
L = len(lattice_generators)

def get_backend_index(mip_var):
    return int(str(mip_var)[2:])

milp = MixedIntegerLinearProgram(solver='ppl')
c = milp.new_variable(real=True,nonnegative=True)
n = milp.new_variable(integer=True)
Eq = sum(c[i]*v for i,v in enumerate(cone_generators)) - sum(n[i]*v for i,v in enumerate(lattice_generators))
for e in Eq: milp.add_constraint( e == 0 )
P = milp.polyhedron(backend='normaliz')

# computing projection on n-plane
V = [vector(v[get_backend_index(n[i])] for i in range(L)) for v in P.vertices()]
R = [vector(v[get_backend_index(n[i])] for i in range(L)) for v in P.rays()]
projP = Polyhedron(backend='normaliz', vertices=V, rays=R)
print( projP.integral_points_generators() )

which prints:

(((0, 0),), 
((-13, 230), (-10, 177), (-7, 124), (-4, 71), (-1, 18), (0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (17, 4), (30, 7), (43, 10)), 
())

See docs for integral_points_generators() . It may be more straightforward to use PyNormaliz without MILP.

edit flag offensive delete link more

Comments

Thank you for the thorough suggestion! I will work through this carefully sometime this week, and respond.

xion3582 gravatar imagexion3582 ( 2024-12-08 21:57:21 +0100 )edit

Thanks again Max! I'm seeing that the code doesn't quite produce what I need.

For illustrative purposes, I graphed an example with simpler generators:

cone_generators = [vector(QQ,v) for v in [[1, 2], [2, 1]]]
lattice_generators = [vector(QQ,v) for v in [[1/5,0], [0, 1/2]]]

I had intended to add the graph to my question, but I am not allowed to add one. Either way, the code produces the lattice points

lattice_points_in_cone = [(0, 0), (2/5, 1/2), (3/5, 1/2), (3/5, 1), (4/5, 1/2), (4/5, 3/2), (1, 1/2), (1, 2)]

(obtained by interpreting the pairs produced by integral_points_generators() as coordinates in the basis lattice_generators).

But I would expect lattice_points_in_cone to include, for example, the point (4/5, 1).

xion3582 gravatar imagexion3582 ( 2024-12-12 16:53:38 +0100 )edit

You seem to misinterpret the result of integral_points_generators(). In its second component we have Hilbert basis for the $(n_1,n_2)$ coefficients. In particular, it generates coefficients 2 * (2,1) = (4,2), which gives you point 4 * [1/5,0] + 2 * [0, 1/2] = [4/5, 1] in the intersection.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-12-12 18:03:04 +0100 )edit

Ah, that makes sense! It remains for me to find an efficient way to go from the Hilbert basis to the intersection within a fundamental parallelpiped of the cone. I believe this solution elegantly answers my stated question -- I'll accept, and say thanks again! .... I guess I can't upvote your answer either -- sorry about that!

xion3582 gravatar imagexion3582 ( 2024-12-13 18:49:13 +0100 )edit

Just beware about extraneous solutions that may appear as a result of projection. With this approach we catch all solutions, but may be a bit more.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-12-13 20:10:00 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-12-04 18:11:20 +0100

Seen: 103 times

Last updated: yesterday