Consider the following ILP problem:
Min Σ|ai * xi|
s.t. xi = {-1, 0, 1} for all i,
max{|xi|} = 1.
I use pulp to solve it:
import pulp
myilp = pulp.LpProblem("ILP", pulp.LpMinimize)
c = np.array(df.iloc[0].values) #coefficients array
x = {i: pulp.LpVariable(name=f"x{i}", lowBound=-1, upBound=1, cat=pulp.LpInteger) for i in range(0, len(c))}
x_l = [x[i] for i in range(0, len(c))]
#Objective function
myilp += abs(c.T @ x_l)
#Constriants
myilp += (max(abs(x_l)) == 1)
But it seems that pulp doesn't support abs() and max() operator, so how can I convert my objective function and constriants?
Could anybody rewrite the codes to make it works in python?