applications.runtime_certlin

Runtime of Certlin

Runtime of Certlin

We demonstrate how to test the runtime of the package certlin:

sage: from certlin import *

To define a linear inequality system, we consider an (m x n) matrix and m intervals over a ring:

sage: m = 10
sage: n = 5
sage: ring = ZZ
sage: # ring = AA # algebraic real numbers

We define a random linear inequality system:

sage: M = random_matrix(ring, m, n)
sage: I = Intervals.random(m, ring=ring)
sage: S = LinearInequalitySystem(M, I)

There are different commands for certifying the solvability of the system:

sage: S.certify() # random
(False, (0, 0, -264, 0, -186, 182, 190, 0, -178, 38))
sage: S.certify(random=True) # random
(False, (0, 0, 240, 60, 120, -180, -120, 240, 0, 0))

Consult the documentation of the package for the other commands. Use the timeit command to test the runtime of the different commands. Since a system keeps the maximal minors it has computed, we time the commands for a new system:

sage: timeit("LinearInequalitySystem(M, I).certify()") # long time, random
5 loops, best of 3: 87.5 ms per loop

To compare the runtime with polyhedral computations, we need to translate the system into a polyhedron:

sage: from applications.runtime_certlin import polyhedron_from_general_system
sage: P = polyhedron_from_general_system(S)
sage: P # random
The empty polyhedron in QQ^6
sage: P = polyhedron_from_general_system(S, backend="polymake") # optional - polymake

We consider the polyhedron of the dual system:

sage: P = polyhedron_from_general_system(S.dual())
sage: P # random
A 12-dimensional polyhedron in QQ^18 defined as the convex hull of 30 vertices and 30 rays

Use the method an_element to compute an element of the polyhedron.

Functions

polyhedron_from_general_system(system[, backend])

Return a polyhedron that is nonempty if and only if the system has a solution.

applications.runtime_certlin.polyhedron_from_general_system(system: certlin.LinearInequalitySystem, backend: str | None = None) → sage.geometry.polyhedron.constructor.Polyhedron

Return a polyhedron that is nonempty if and only if the system has a solution.

INPUT:

  • system – a linear inequality system

  • backend – a backend for polyhedra (default: None)

To use backends like "normaliz" and "polymake", see the documentation of the Polyhedron class.

OUTPUT:

The polyhedron is given by the homogeneous form of the system, where each strict inequality a z > 0 is replaced by a z >= 1. For a homogeneous system, its points are solutions. Otherwise, it has one more coordinate t, and y / t is a solution for each point (y, t).

EXAMPLES:

sage: from certlin import *
sage: from applications.runtime_certlin import polyhedron_from_general_system
sage: M = matrix([[1, 0], [0, 1], [1, 1], [0, 1]])
sage: I = Intervals.from_bounds([2, 5, 0, -oo], [5, oo, 8, 5], [True, True, False, False], [False, False, False, True])
sage: S = LinearInequalitySystem(M, I)
sage: P = polyhedron_from_general_system(S)
sage: P
A 2-dimensional polyhedron in QQ^3 defined as the convex hull of 1 vertex and 2 rays
sage: y = P.an_element()
sage: y
(-7, -15, -3)
sage: x = y[:2] / y[2]
sage: x
(7/3, 5)
sage: S.is_solution(x)
True