Skip to content

unexpected behaivour with polytope package, ( probably a bug , but not sure ) #93

Description

@mvnayagam

Dear Developers and users,

recently I have been facing an issue with using the polytope package. I have A and b matrixes,

import polytope as PC
import numpy as np
a=np.array([ [-1.0 , -0.  ,-0. , -0.],
                     [ 0. ,  1.  , 0. ,  0. ],
                     [ 0.5, -0.5 , 0.5, -0.5],
                     [ 0.5, -0.5 ,-0.5,  0.5],
                     [ 0.5,  0.5 , 0.5, -0.5],
                    [-0. , -0.  ,-1. , -0. ] ])

b=np.array([-0.33333, 0.3125 , 0.05724, -0.01478, 0.3566 , -0.16667]) 

and create a polytope 'p' as

p=pc.Polytope(a, b)

For this polytope, I get some unwanted numbers when I calculate extreme points as

print(f'pc.extreme(p): \n{pc.extreme(p)}')

This gives

pc.extreme(p): 
[[3.34187e-01 3.00251e-01 3.31721e+13 3.31721e+13]
 [3.33330e-01 2.90870e-01 1.66670e-01 9.46500e-02]
 [3.41820e-01 2.99360e-01 1.66670e-01 9.46500e-02]
 [3.33330e-01 2.99360e-01 1.66670e-01 8.61600e-02]
 [3.33201e-01 3.12896e-01 4.97582e+13 4.97582e+13]
 [3.33330e-01 3.12500e-01 1.66670e-01 1.16280e-01]
 [3.41820e-01 3.12500e-01 1.66670e-01 1.07790e-01]
 [3.33330e-01 3.12500e-01 1.66670e-01 9.93000e-02]]

The polytope seems to be exploding along some directions ( so the values along the 3rd and 4th columns of pc.extreme(p) are 3.31721e+13 ). If I redo the calculation, sometimes the pc.extreme returns

pc.extreme(p): 
[[ 3.33330e-01  3.12500e-01  1.66670e-01  9.93000e-02]
 [ 3.33330e-01  2.99360e-01  1.66670e-01  8.61600e-02]
 [        -inf         -inf          inf          inf]
 [ 3.41820e-01  3.12500e-01  1.66670e-01  1.07790e-01]
 [ 3.41820e-01  2.99360e-01  1.66670e-01  9.46500e-02]
 [ 3.37299e-01  2.97482e-01 -9.95164e+13 -9.95164e+13]
 [ 3.33330e-01  3.12500e-01  1.66670e-01  1.16280e-01]
 [ 3.33330e-01  2.90870e-01  1.66670e-01  9.46500e-02]
 [         inf         -inf          inf          inf]]

In my view pc.extreme(p) contains unwanted or unexpected numbers.

  1. Has anyone faced such an issue with the polytope package?
  2. How to be sure that the polytope is correct or valid?

because doing

print(f'pc.is_convex(p) :  {pc.is_convex(p)}')
print(f'pc.is_fulldim(p): {pc.is_fulldim(p)}\n')

returns

pc.is_convex(p) :  True
pc.is_fulldim(p): True

But the

print(f'p.bounding_box: \n  {np.array(p.bounding_box)}')

returns

p.bounding_box:
 [[[0.33333]
  [0.29087]
  [0.16667]
  [0.08616]]

 [[0.34182]
  [0.3125 ]
  [    inf]
  [    inf]]]

some weird things are happening with this polytope p or polytope package. Any leads or suggestions are highly appreciated

Thank you for your time on this question


Best regards
Muthu Vallinayagam
Research, Institute of Experimental Physics
TU Freiberg
Germany

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions