メインコンテンツへスキップ

Minimum Covering Sphere problem

回答済み

コメント

2件のコメント

  • Eli Towle
    • Gurobi Staff

    Yes, Gurobi can solve this problem. In Python, the most straightforward implementation uses Gurobi's matrix-friendly interface. Here is some example Python code:

    import gurobipy as gp
    from gurobipy import GRB
    import numpy as np

    m = 200
    n = 21

    # Generate m random vectors in [0,ub]^n
    ub = 10
    a = ub * np.random.rand(m, n)

    model = gp.Model()

    s = model.addMVar(shape=(1,), name="s")
    x = model.addMVar(shape=(n,), ub=ub, name="x")

    for i in range(m):
        model.addConstr(s >= (x - a[i]) @ (x - a[i]), name=f"cover[{i}]")

    model.setObjective(s, GRB.MINIMIZE)

    model.optimize()

    print("s^2 =", s.X)
    print("x =", x.X)

    This problem has a \(m\) second-order cone constraints, which sometimes poses numerical challenges for solvers. If Gurobi encounters numerical issues while solving, you could try playing with parameters like NumericFocus and BarHomogeneous. Setting PreDual to 1 (\(\texttt{model.params.PreDual = 1}\)) seems to work well for this problem.

    For additional matrix-friendly Python API examples, see matrix1.py and matrix2.py.

    1
  • Mehmet Fide
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Eli,

     

    This is really great, I will look at it closer.

     

    Thank you very much,

    Fide.

    0

サインインしてコメントを残してください。