Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to transform a derived set of inequation in the good polyhedron format

Applying this code

def One_dimension_loss(representationH) :
x = list(var('x_%i' % i) for i in (0..2))
sol=[solve_ineq(ieq,[x[0]]) for ieq in Ineq]
sol_r=flatten([x[1] for x in sol])
ineq_ge=[z for z in sol_r if z.rhs() == x[0]]
ineq_le=[z for z in sol_r if z.lhs() == x[0]]
ineq_a=[z for z in sol_r if z.lhs() != x[0] and z.rhs() != x[0]]
ineq_aa=[(z.lhs()).full_simplify()>=0 for z in ineq_a]
result=flatten(ineq_aa+[[(ineq_le[j].rhs()-ineq_ge[i].lhs()).full_simplify() >= 0 for i in range(len(ineq_ge))] 
           for  j in range(len(ineq_le))])
#result1=[result[i].factor() for i in range(len(result))]
return result

to

D = polytopes.dodecahedron()
DH = D.Hrepresentation()

with

PD1=One_dimension_loss(DH)
show(PD1)

I can eliminate one variable and obtain a set of inequalities defining a polyhedron in a lower dimension (here I go from 3 to 2 but it can be higher.

For each x in PD1, I can isolate it's right hand side but I don't know how to isolate the parameters in such a way to write it as

Polyhedron(ieqs=[(0,1,0),(0,0,1),(1,-1,-1)]).Hrepresentation() (An inequality (-1, -1) x + 1 >= 0, An inequality (1, 0) x + 0 >= 0, An inequality (0, 1) x + 0 >= 0)

the lists needed to feed ieqsin Polyhedron. How to do that ?

How to transform a derived set of inequation in the good polyhedron format

Applying this code

def One_dimension_loss(representationH) :
one_dimension_less(representationH):
    x = list(var('x_%i' % i) for i in (0..2))
sol=[solve_ineq(ieq,[x[0]])     sol = [solve_ineq(ieq, [x[0]]) for ieq in Ineq]
sol_r=flatten([x[1]     sol_r = flatten([x[1] for x in sol])
ineq_ge=[z     ineq_ge = [z for z in sol_r if z.rhs() == x[0]]
ineq_le=[z     ineq_le = [z for z in sol_r if z.lhs() == x[0]]
ineq_a=[z     ineq_a = [z for z in sol_r if z.lhs() != x[0] and z.rhs() != x[0]]
ineq_aa=[(z.lhs()).full_simplify()>=0     ineq_aa = [(z.lhs()).full_simplify() >= 0 for z in ineq_a]
result=flatten(ineq_aa+[[(ineq_le[j].rhs()-ineq_ge[i].lhs()).full_simplify() >= 0     result = flatten(ineq_aa + [
            [(ineq_le[j].rhs()-ineq_ge[i].lhs()).full_simplify() >= 0
             for i in range(len(ineq_ge))] 
range(len(ineq_ge))]
            for  j in range(len(ineq_le))])
#result1=[result[i].factor()     # result1 = [result[i].factor() for i in range(len(result))]
 return result

to

D = polytopes.dodecahedron()
DH = D.Hrepresentation()

with with

PD1=One_dimension_loss(DH)
PD1 = one_dimension_less(DH)
show(PD1)

I can eliminate one variable and obtain a set of inequalities inequalities defining a polyhedron in a lower dimension dimension (here I go from 3 to 2 but it can be higher.

For each x in PD1, I can isolate it's its right hand side but I don't don't know how to isolate the parameters in such a way to write it as

Polyhedron(ieqs=[(0,1,0),(0,0,1),(1,-1,-1)]).Hrepresentation() as

sage: Polyhedron(ieqs=[(0, 1, 0), (0, 0, 1), (1, -1, -1)]).Hrepresentation()
(An inequality (-1, -1) x + 1 >= 0,
 An inequality (1, 0) x + 0 >= 0,
 An inequality (0, 1) x + 0 >= 0)

0)`

the lists needed to feed ieqs in Polyhedron. How to do that ?that?

How to transform a derived set of inequation in the good polyhedron format

This is a follow-up to:

Applying this code

def one_dimension_less(representationH):
    x = list(var('x_%i' % i) for i in (0..2))
    sol = [solve_ineq(ieq, [x[0]]) for ieq in Ineq]
    sol_r = flatten([x[1] for x in sol])
    ineq_ge = [z for z in sol_r if z.rhs() == x[0]]
    ineq_le = [z for z in sol_r if z.lhs() == x[0]]
    ineq_a = [z for z in sol_r if z.lhs() != x[0] and z.rhs() != x[0]]
    ineq_aa = [(z.lhs()).full_simplify() >= 0 for z in ineq_a]
    result = flatten(ineq_aa + [
            [(ineq_le[j].rhs()-ineq_ge[i].lhs()).full_simplify() >= 0
             for i in range(len(ineq_ge))]
            for  j in range(len(ineq_le))])
    # result1 = [result[i].factor() for i in range(len(result))]
    return result

to

D = polytopes.dodecahedron()
DH = D.Hrepresentation()

with

PD1 = one_dimension_less(DH)
show(PD1)

I can eliminate one variable and obtain a set of inequalities defining a polyhedron in a lower dimension (here I go from 3 to 2 but it can be higher.

For each x in PD1, I can isolate its right hand side but I don't know how to isolate the parameters in such a way to write it as

sage: Polyhedron(ieqs=[(0, 1, 0), (0, 0, 1), (1, -1, -1)]).Hrepresentation()
(An inequality (-1, -1) x + 1 >= 0,
 An inequality (1, 0) x + 0 >= 0,
 An inequality (0, 1) x + 0 >= 0)`

the lists needed to feed ieqs in Polyhedron. How to do that?