ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 20 Nov 2023 16:31:33 +0100values of variables from points in the polyhedron defined by a linear programhttps://ask.sagemath.org/question/55520/values-of-variables-from-points-in-the-polyhedron-defined-by-a-linear-program/SageMath provides a [function](https://doc.sagemath.org/html/en/reference/numerical/sage/numerical/mip.html#sage.numerical.mip.MixedIntegerLinearProgram.polyhedron) for constructing the polyhedron defined by a linear program. Given a point in such a polyhedron, how can I tell which coordinate of the point corresponds to which variable of the linear program?
**ADDED:** The documentation suggests that "the polyhedron is built from the variables stored by the LP solver" and that "they usually match the ones created explicitly when defining the LP", except possibly for Gurobi solver. So, the question seems to reduce to finding the order number of each variable in LP (or an accurate bookkeeping of their creations). Things are even more fuzzy for Gurobi, which one of the best solvers out there.Max AlekseyevSun, 31 Jan 2021 19:51:48 +0100https://ask.sagemath.org/question/55520/What is the algorithm used for polyhedra intersection?https://ask.sagemath.org/question/74396/what-is-the-algorithm-used-for-polyhedra-intersection/ What is the algorithm used for polyhedra intersection and what is its time complexity?
Is the algorithm based on a research paper? If so, which one?muha123Mon, 20 Nov 2023 16:31:33 +0100https://ask.sagemath.org/question/74396/polyhedron pbhttps://ask.sagemath.org/question/72794/polyhedron-pb/Hi
It seems that the polyhedron function does not appreciate having a point too close to [0,0,0]
edited:16h36 20/08/2023 remove variable shiftv in textToPlt which was not set in my code snippet below,sorry.
def addAxis(plt,textToPlt,xBound,yBound,zBound) :
# add axis for real part
plt += arrow3d((0, 0, 0), (xBound, 0, 0), color='blue',width=1,radius=0.01)
plt += text3d("X", (xBound, 0, 0), fontsize='200%', color='blue')
plt += arrow3d((0, 0, 0), (0, yBound, 0), color='green',width=1,radius=0.01)
plt += text3d("Y", (0, yBound, 0), fontsize='200%', color='green')
plt += arrow3d((0, 0, 0), (0, 0, zBound), color='red',width=1,radius=0.01)
plt += text3d("Z", (0,0, zBound), fontsize='200%', color='red')
plt+=textToPlt
return plt
xBound=1 ;yBound=1 ;zBound=1
textToPlt = text3d("triangle",vector( (xBound, yBound, zBound)), fontsize='300%', fontweight=800)
# this one is ok
PL=[[-0.01850472408517678, -0.0001969154774790170-0.1, 0],
[0.528252049962465, 0.518079657915348, 1],
[0.700606532965328, -0.1802168993960041, 0]]
# but this one is KO
PL=[[-0.01850472408517678, -0.0001969154774790170, 0],
[0.528252049962465, 0.518079657915348, 1],
[0.700606532965328, -0.1802168993960041, 0]]
plt=Graphics()
plt+= point3d(PL, color='black',size=20)
plt=addAxis(plt,textToPlt,xBound,yBound,zBound)
show(plt)
P=Polyhedron(PL)
Pc=P.centroid()ortolljSun, 20 Aug 2023 13:55:11 +0200https://ask.sagemath.org/question/72794/how can I find the distance between a point and a polyhedron?https://ask.sagemath.org/question/70097/how-can-i-find-the-distance-between-a-point-and-a-polyhedron/ I have a point and a polyhedron(defined by vertices) in same space($\mathbb{R}^n$, maybe $n=32$), how can I find the distance between them?house_fzFri, 14 Jul 2023 21:45:27 +0200https://ask.sagemath.org/question/70097/How to obtain the vertices of the faces of a polyhedron in the cycling order ?https://ask.sagemath.org/question/57483/how-to-obtain-the-vertices-of-the-faces-of-a-polyhedron-in-the-cycling-order/ I wanted to transfer informations from sagemath to Asymptote and draw the faces of a dodecahedron. So according to the documentation I code
Dodec=polytopes.dodecahedron()
F1 = Dodec.faces(2)
fa=[f.ambient_V_indices() for f in F1]
fa
Vdodec=Dodec.Vrepresentation()
Sdodec=[(round(Vdodec[i][0],2),round(Vdodec[i][1],2),round(Vdodec[i][2],2)) for i in range(len(Vdodec))]
show("fa= ",fa)
show("points = ",Sdodec)
If I have understood the documentation `fa` gives the vertices implied in a face. Those vertices are numbered according to the order of the `Vrepresentation()` of `Dodec` as written in the doc :
` "The faces are printed in shorthand notation where each integer is the index of a vertex/ray/line in the same order as the containing Polyhedron’s Vrepresentation()"`. So (15,16,17,18,19) is a face composed of the points :
p15=(-0.76, 0.76, -0.76),
p16=(-0.76, -0.76, -0.76),
p17=(-1.24, 0.47, 0.0),
p18=(-1.24, -0.47, 0.0),
p19=(-0.47, 0.0, -1.24),
And this is true. But here comes the problem : as I understand it, the face should be the closed cycle `p15--p16--p17--p18--p19`. But transfered in Asymptote, I discovered that the true order should be
`p15--p19--p16--p18--p17`. The same type of error seems to be the case for each face (good composition but bad order).
So here is my question : is there a command which gives the good order of the vertices which define a face or is it an error because the vertices should be given in the good order ?
(Hope that this time there is no element missing in the code)
CyrilleTue, 08 Jun 2021 16:21:24 +0200https://ask.sagemath.org/question/57483/A polyhedron little problemhttps://ask.sagemath.org/question/53468/a-polyhedron-little-problem/I do not know if I make a mistake On the following problem. I have the polygon
var('x_1') # toute variable utilisée doit être préalablement définie
p1 = plot((9 - (3/2)*x_1),(x_1,0,6.5),color='red',axes_labels=['$x_1$','$x_2$'], thickness=2,zorder=2)
l0 = line([(0,0),(0,4)],color='magenta', thickness=2)
l1 = line([(0,4),(10/3,4)],color='yellow', thickness=2)
l2 = line([(0,0),(4,0)],color='green', thickness=2)
l3 = line([(4,0),(4,3)],color='cyan', thickness=2)
c1=point((0,0),pointsize=25, rgbcolor=hue(0.75),aspect_ratio='automatic',zorder=1)
c2=point((0,4),pointsize=25, rgbcolor=hue(0.75),aspect_ratio='automatic',zorder=1)
c3=point((4,0),pointsize=25, rgbcolor=hue(0.75),aspect_ratio='automatic',zorder=1)
c4=point((10/3,4),pointsize=25, rgbcolor=hue(0.75),aspect_ratio='automatic',zorder=1)
c5=point((4,3),pointsize=25, rgbcolor=hue(0.75),aspect_ratio='automatic',zorder=1)
pol=polygon([(0,0),(0,4),(10/3,4),(4,3),(4,0)],rgbcolor=(0.025,0.25,0.5),alpha=0.2)
D=text(r"$Domaine\,\, faisable$",(2,2),fontsize=8)
show(pol+l0+l1+l2+l3+p1+c1+c2+c3+c4+c5+D)
( Incidently I am oblige to plot an horizontal line through `line` not as an equality. Is there an other way ?) Now if I ask directly to plot the polygon by
var('x_1') # toute variable utilisée doit être préalablement définie
pol1=Polyhedron(ieqs=[(18,-2,-1),(42,-2,-3),(24,-3,-1),(0,1,0),(0,0,1)])
S=[s for s in pol1.Vrepresentation()]
SS=[(S[i][0],S[i][1]) for i in range(len(S))]
C = [circle(SS[i],.1,fill=True,edgecolor='#2f974a',facecolor='#2f974a') for i in range(len(SS))]
PC = [plot(C[i])for i in range(len(SS))]
gon=polygon(SS,fill=True,color='#d2def1',edgecolor="#0e56ad")
lab=plot(0,(x,0,9), color='black',axes_labels=['$x_1$','$x_2$'],thickness=0.0001)#ligne fictive d'où l'épaisseur pour obtenir les labels des axes
I obtain a simple rectangle which is not the case.
show(lab+gon+sum(PC[i] for i in range(len(SS))))
CyrilleWed, 16 Sep 2020 13:58:42 +0200https://ask.sagemath.org/question/53468/