1 | initial version |
If you want to consider all the points satisfying some properties, i guess the best way it to consider those points as forming a set. In your case, the set of points is a polytope. By convenience, you can construct it from a linear program as follows:
sage: p = MixedIntegerLinearProgram()
sage: x = p.new_variable(real=True, nonnegative=True)
sage: p.add_constraint(sum(x[i] for i in range(31)) == 1)
sage: P = p.polyhedron() ; P
A 30-dimensional polyhedron in RDF^31 defined as the convex hull of 31 vertices
Then you can do things like:
sage: P.contains([1/2,1/2,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
True
sage: P.contains([1/2,1/3,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
False
sage: P.random_integral_point()
(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
sage: P.integral_points_count()
31
sage: P.dim()
30
sage: P.is_simplex()
True
sage: P.vertices_list()
...