0

Given a set of points in 3D space S and a set of vectors V where each point s_i can translate along vector v_i, I want to find the minimum total displacement of the points required to guarantee that no two points are within a distance r of each other. Denote the new locations of the points as X.

I'm very new to optimization, but this is my attempt to formulate this problem in Python using cvxpy:

def optimize(S, V):

    # new coordinates of each point
    X = cp.Variable(S.shape)

    # objective function: minimize total displacement of all points
    obj = cp.Minimize(sum(cp.norm(x_i - s_i) for x_i, s_i in zip(X, S)))

    constraints = []

    # constraint 1: all pairs of points must have distance of at least r between them
    constraints += [cp.norm(x_i - x_j) >= r for i, x_i in enumerate(X) for x_j in X[i+1:]]

    # constraint 2: magnitude of translation of a point is at most the magnitude of its vector
    constraints += [cp.norm(x_i - s_i) <= cp.norm(v_i) for x_i, s_i, v_i in zip(X, S, V)]
 
    # constraint 3: direction of translation of a point is same as direction of its vector
    constraints += [v_i.T @ (x_i - s_i) == 1 for x_i, s_i, v_i in zip(X, S, V)]

    prob = cp.Problem(obj, constraints)
    prob.solve()

    return X

Constraint 1 causes a DCP error:

cvxpy.error.DCPError: Problem does not follow DCP rules.

Is this an issue with the problem itself or am I just formulating it incorrectly? Can the problem be reformulated as a convex QCQP, or as some other form (e.g. NLP, SOCP)? If necessary, I can switch to a different solver in either Python or Matlab. Any advice would be appreciated.

Also, I tried using the QCQP package for cvxpy (https://github.com/cvxgrp/qcqp), but it's only compatible with cvxpy 0.4, which has a bunch of other deprecated dependencies.

  • 2
    This is a non-convex problem, so CVXPY cannot be used (CVXPY is only for convex problems). – Erwin Kalvelagen Aug 11 '22 at 15:02
  • @ErwinKalvelagen Ah, ok. Are there any solvers in Python or Matlab that would be able to solve this? Which would you say is best for this problem? – anirudhc1229 Aug 11 '22 at 16:27
  • I would use a global solver such as Gurobi, Baron, Octeract. or Antigone. – Erwin Kalvelagen Aug 11 '22 at 16:40
  • Can you give an example of a point and the vector it can "translate" along as you say? – thomaskeefe Aug 12 '22 at 20:21
  • @thomaskeefe Sure. If we have the point (1, 1, 1) and its vector is (0, 1, 2), then that point's final location can be anywhere between (1, 1, 1) and (1, 2, 3). A line segment drawn between these two points would define all possible final locations. – anirudhc1229 Aug 12 '22 at 21:44
  • Ok, perhaps you can simplify it by having your decision variables be weights `w_i`, (Make `w` a cvxpy Variable) and then you can use linear constraints 0 <= w_i <= 1, and define X = S + w * V. – thomaskeefe Aug 15 '22 at 00:53
  • But yes more importantly the constraint norm(...) >= r is not convex so it is not suitable for CVX. – thomaskeefe Aug 15 '22 at 01:00
  • I understand. Thanks for the suggestion though, I’ll incorporate this – anirudhc1229 Aug 15 '22 at 03:18

0 Answers0