I'm trying to implement a Python script that finds the distance between two ellipses using CPLEX. An ellipse is defined as a quadric: the set of points (x,y) that satisfy the equation: ax2 +bxy+cy2 +dx+ey+f =0, where b2 − 4ac < 0. The distance between two ellipses is the minimum distance between two points (i.e., (x1, y1) and (x2, y2)) within these two ellipses (i.e., (a1,b1,c1,d1,e1,f1) and (a2,b2,c2,d2,e2,f2)) can be found using the following optimization problem:
minimize z = (x1 − x2)^2 + (y1 − y2)^2
subject to: a1x21 + b1x1y1 + c1y12 + d1x1 + e1y1 + f1 ≤ 0
a2x2 + b2x2y2 + c2y2 + d2x2 + e2y2 + f2 ≤ 0
I have to represent it by using a .txt file ellipse.txt which contains the coefficients of two ellipses in two rows: ellipse.txt:
9 0 25 -18 100 -116
16 0 9 160 -72 400
I guess I have to define a function first such as but I couldn't figure out where to start. What do you guys think? Thanks.
