Closed mvnayagam closed 9 months ago
Hi Muthu. I am not sure what you mean by "combine". Is this a mathematical operation like union, convex hull, minkovski sum? In our package, "+" is used for polytope unions and in general union of two polytopes is no more a polytope (i.e., polytopes are not closed under union operation). Therefore, union operation generally returns a region.
Hi necozay, Thank you for your comment. by the word combine I meant to form a new closed polytope by the union of two polytopes.
assume a region with many polytopes (all are convex) and some of them intersect with each other. so I can reduce the length of the region [ i.e. reducing the number of polytopes within the region] as follows
now the region should have less number of polytopes. In my project, the reduction of the length of the region helps to make a solid conclusion about the possible solution space for the given problem
your further suggestions would be greatly appreciated
Thank you
Best regards, Muthu Vallinayagam Researcher, Inst. of Experimental physics TU Freiberg, Germany
A similar functionality exists inside union. You can try: r = pc.union(p1, p2, True)
instead of the + operator.
Please see: https://github.com/tulip-control/polytope/issues/82#issuecomment-1668745947 for more details.
thank you for your comments. I have already seen the referred discussion. But still, I have an issue with this method. let me explain what I do. I have a Region containing three polytopes as shown in the following plot.
the red polytope is in contact with two other polytopes. So in our problem, we define these three polytopes as possible solutions. In the end, we want to combine them and create a single polytope. The H representation of these polytopes are
0 Single polytope ( blue polytope ) [[ 0.57735 0.57735 0.57735] | [[ 0.27189] [-0.57735 0.57735 -0.57735] | [-0.11722] [ 0.57735 -0.57735 -0.57735] x <= [ 0.01637] [-0.57735 -0.57735 -0.57735] | [-0.26141] [ 0. 1. 0. ] | [ 0.125 ] [-0.57735 -0.57735 0.57735]]| [-0.15292]]
1 Single polytope ( red polytope ) [[ 0.57735 0.57735 0.57735] | [[ 0.27466] [ 0.57735 -0.57735 0.57735] | [ 0.12755] [ 1. 0. 0. ] | [ 0.25 ] [ 0.57735 -0.57735 -0.57735] | [ 0.01637] [-0.57735 0.57735 0.57735] x <= [-0.00429] [-0.57735 0.57735 -0.57735] | [-0.11707] [-0. -1. -0. ] | [-0.125 ] [-0.57735 -0.57735 0.57735] | [-0.15292] [ 0.57735 0.57735 -0.57735]]| [ 0.16319]]
2 Single polytope ( green polytope ) [[-0.57735 0.57735 0.57735] | [[-0.01401] [ 0.57735 -0.57735 -0.57735] | [ 0.01637] [ 0.57735 0.57735 0.57735] x <= [ 0.27958] [-0.57735 -0.57735 0.57735] | [-0.16113] [-1. -0. -0. ] | [-0.25 ] [ 0.57735 0.57735 -0.57735]] | [ 0.16319]]
I tried to combine the first two polytops as >r = pc.union(p1, p2, True). I expected that "r" would be a single polytope. but it is a Region again, the screen shot of execution is here.
just curious to know why the union is not able to combine given polytopes and return Region.
thank you
Dear Users and developers, I try to combine two different polytopes. I assumed that the input is two polytopes and the output would be a single polytope. In fact, the polytopes I deal with are very close to each other or sometimes they partially overlap.
import polytope as PC
creating polytopes
p1 = pc.Polytope(p1A, p1b) p2 = pc.Polytope(p2A, p2b)
combining them
r = p1 + p2
I expected that " r " is a polytope. but it is a Region in the end. and just it contains the given polytopes.
is there any faster method to combine given polytopes into a single polytope?
Now i follow the following method
p1_exetrem = pc.extreme(p1) p2_exetrem = pc.extreme(p2)
new_exetrem =np.array(p1_exetrem , p2_exetrem ) ### should be done over row of each rows in p1_exetrem and p2_exetrem
new_polytope = pc.qhull ( new_exetrem )
however, I feel it is not a safer method. since with this method, we included the space where p1_exetrem and p2_exetrem overlap with each other. Also when I try to plot new_polytope I get an error message.
Any suggestions would be greatly appreciated
Thank you
Best regards, Muthu Vallinayagam Researcher, Inst. of Experimental physics TU Freiberg, Germany