Formulation of a multivariate piecewise linear constraints
回答済みI have the following problem: 
How can I model the function p(y) and use it within my big-M constraint with Gurobi in Python?
I already have something like this, but the solution of the model seems to be incorrect:
eps = 0.0001
M1 = 10000 + eps
M2 = 10000
for subspace in subspaces:
z_binaries = []
for hyperplane in subspace:
z_bin = self.model.addVar(vtype=GRB.BINARY)
append(z_bin)
A = LinExpr(hyperplane.a + [-M1], y + [z_bin])
rhs = hyperplane.b - M1
model.addLConstr(A, GRB.GREATER_EQUAL, rhs)
rhs2 = hyperplane.b
model.addLConstr(A, GRB.LESS_EQUAL, rhs2)
delta = model.addVar(vtype=GRB.INTEGER)
model.addGenConstrAnd(delta, z_binaries)
A = LinExpr(subspace.a + [-M2, -1.0], y + [z] + [r])
rhs = subspace.b - M2
model.addGenConstrIndicator(delta, True, A, GRB.GREATER_EQUAL, rhs)
0
-
Hi Patrick,
One approach would be to construct m disjoint convex regions:
\[\mathcal{S}'_i = \{(p,y) : y \in \mathcal{S}_i, p = a^T_i - b_i\}\]
over completely separate sets of variables, eg \((p_i, y_i)\), then introduce binary variables \(x_1, \ldots, x_m\) and the constraint \(\sum_i x_i = 1\)
and use indicator constraints of the form
(x_i == 1) >> (p == p_i)
(or the big M equivalent).
- Riley
0
サインインしてコメントを残してください。
コメント
1件のコメント