Пример #1
0
    polyListOptim)
pyOptimUtil.direct.plotDirectPolygon(polyListOptim, potentialIndex, lb - 0.5,
                                     ub + 0.5)

## Testing the triangulation

lb = numpy.array([-2., -2.], float)
ub = numpy.array([2., 2.], float)

A, b = polyOperation.addBoxToInequalityLBUB(lb, ub)

polyObj = polyOperation.PolygonObj(optimTestFun.rosen, A, b)
polyObj.getMaxDistanceToVertices()

V, dualHull, G, h, x0 = polyOperation.constraintToVertices(A,
                                                           b,
                                                           full_output=True)

tri = scipy.spatial.Delaunay(V)

points = V
plt.triplot(points[:, 0], points[:, 1], tri.simplices.copy())
plt.plot(points[:, 0], points[:, 1], 'o')
plt.show()

for simplex in tri.simplices:
    plt.plot(points[simplex, 0], points[simplex, 1], 'k-')

plt.ylim([-2.5, 2.5])
plt.xlim([-2.5, 2.5])
plt.show()
Пример #2
0
primalD = mul(matrix(primalDistance)[:, [0, 0]] ** -1, matrix(newA))

primalHull = scipy.spatial.ConvexHull(primalD)
primalPoints = numpy.array(primalD)


plt.plot(primalPoints[:, 0], primalPoints[:, 1], "o")
# plt.plot(x[0], x[1], 'ro')
for simplex in primalHull.simplices:
    plt.plot(primalPoints[simplex, 0], primalPoints[simplex, 1], "k-")

plt.show()

## testing inequality <=> verticies operations

V, hull, A, b, x0 = polyOperation.constraintToVertices(G[0:5, :], h[0:5], full_output=True)

points = hull.points
plt.plot(points[:, 0], points[:, 1], "o")
plt.plot(x[0], x[1], "ro")
for simplex in hull.simplices:
    plt.plot(points[simplex, 0], points[simplex, 1], "k-")

plt.show()


ATest, bTest = polyOperation.verticesToConstraint(V)

polyOperation.constraintToVertices(ATest, bTest)

polyOperation.findAnalyticCenter(ATest, bTest)
Пример #3
0
primalD = mul(matrix(primalDistance)[:, [0, 0]]**-1, matrix(newA))

primalHull = scipy.spatial.ConvexHull(primalD)
primalPoints = numpy.array(primalD)

plt.plot(primalPoints[:, 0], primalPoints[:, 1], 'o')
#plt.plot(x[0], x[1], 'ro')
for simplex in primalHull.simplices:
    plt.plot(primalPoints[simplex, 0], primalPoints[simplex, 1], 'k-')

plt.show()

## testing inequality <=> verticies operations

V, hull, A, b, x0 = polyOperation.constraintToVertices(G[0:5, :],
                                                       h[0:5],
                                                       full_output=True)

points = hull.points
plt.plot(points[:, 0], points[:, 1], 'o')
plt.plot(x[0], x[1], 'ro')
for simplex in hull.simplices:
    plt.plot(points[simplex, 0], points[simplex, 1], 'k-')

plt.show()

ATest, bTest = polyOperation.verticesToConstraint(V)

polyOperation.constraintToVertices(ATest, bTest)

polyOperation.findAnalyticCenter(ATest, bTest)
Пример #4
0
potentialIndex = polyOperation.identifyPotentialOptimalPolygonPareto(polyListOptim)
pyOptimUtil.direct.plotDirectPolygon(polyListOptim,potentialIndex,lb-0.5,ub+0.5)



## Testing the triangulation

lb = numpy.array([-2.,-2.],float)
ub = numpy.array([2.,2.],float)

A,b = polyOperation.addBoxToInequalityLBUB(lb,ub)

polyObj = polyOperation.PolygonObj(optimTestFun.rosen,A,b)
polyObj.getMaxDistanceToVertices()

V, dualHull, G, h, x0 = polyOperation.constraintToVertices(A,b,full_output=True)

tri = scipy.spatial.Delaunay(V)

points = V
plt.triplot(points[:,0], points[:,1], tri.simplices.copy())
plt.plot(points[:,0], points[:,1], 'o')
plt.show()


for simplex in tri.simplices:
    plt.plot(points[simplex,0], points[simplex,1], 'k-')

plt.ylim([-2.5,2.5])
plt.xlim([-2.5,2.5])
plt.show()