Gurobi add constraint which two variables cant be zero at the same time

I'm currently using Gurobi in python and trying to add a constraint that the variable will not equal to 0 at the same time, say a != 0 or b != 0, both a and b can be negative or positive. But I can't find a proper way to add this constraint. Does anyone have idea about this?

Edit: The problem I'm trying to solve is to find the proper plane that has the smallest distances in summation for a list of points. The equation I used is $$\sum_{i=0}^n \frac{|Ax_{i} + By_{i} + Cz_{i} + D|}{\sqrt{A^2 + B^2 + C^2}}$$ where $$x_{i}, y_{i}, z_{i}$$ refer to the point, A,B,C,D refer to the plane equation Ax + By + Cz + D = 0, and thus A,B,C cant be 0 at the same time.

• Can you post your mathematical equation that you have tried to cater above requirement? Jan 28 at 10:20
• Hi, I just edited my post with the equation, do you have any idea about this? Jan 28 at 11:53
• Are the decision variables $a$ and $b$ continuous or binary? Jan 28 at 13:25
• A small denominator yields a bad objective value, so you might not need to explicitly impose constraints to avoid it. What happens when you try to solve the unconstrained problem? Jan 28 at 13:50
• they are continuous. And when I apply with no constraints, the value of A,B,C,D are just stuck at 0, and each point put into the equation has the result 0. Jan 28 at 14:05

There's a trick I sometimes use in situations like this. First, you need to confirm that for any optimal solution $$(A, B, C, D)$$ and any scalar $$\lambda \neq 0$$, $$\lambda\cdot (A, B, C, D)$$ is also optimal. It obviously selects the same plane, so chances are good this will hold.
Assuming it does, generate a random vector $$\alpha$$ distributed uniformly over $$[-1, 1]^3$$ and add the constraint $$\alpha_1 A + \alpha_2 B + \alpha_3 C = 1$$ to the model. This obviously rules out $$A = B = C = 0$$. For any optimal $$(A, B, C)$$ for which the left side is not zero, we can by assumption multiply by a constant to get another optimal solution that sums to 1. So the only potential issue is whether the optimal solution might have inner product 0 with $$\alpha$$. Since we chose $$\alpha$$ using a continuous distribution over a region with positive volume, that has probability zero of occurring. So unless you are living under a curse, this ought to work.