I am implementing a NLP problem in pyomo, and I am getting some issues for this constraint:
\begin{equation} \forall i \in \lbrace 1, N \rbrace , \forall j \in \left\{1, M \right\}: Y_{i,j} \cdot S_{i,j} = \max_{k} \big(p_{i,k} \cdot S_{i,k} \big) \end{equation}
where:
$Y_{i,j}$ is a binary decision variable equal to 1 if element j is a match to i, 0 otherwise.
$S_{i,j}$ is a continous decision variable such as $0 \leq S_{i,j} \leq 1$.
$p_{i,j}$ is a binary parameter equal to 1 if j is a candidate of i, 0 otherwise.
Basically, this constraint is to select j for i such as $S_{i,j}$ is the maximum value. Eventually, I have another constraint to ensure the unicity of the selected match:
\begin{equation} \forall i \in \lbrace 1, N \rbrace : \sum_{j=1}^M Y_{i,j} = 1 \end{equation}
Now to implement the former constraint in pyomo, I have tried this code:
def pred_selection_rule(model, i, j):
return (model.Yij[i,j] * model.Sij[i,j] == max(model.pij[i,k] * model.Sij[i,k] for k in model.M))
model.pred_selection = Constraint(model.N, model.M, rule=pred_selection_rule)
Then I got this error:
ERROR: Rule failed when generating expression for constraint pred_selection
with index (1, 1): TypeError: Cannot create a compound inequality with
identical upper and lower
bounds using strict inequalities: constraint infeasible: 0.0 <
Sij[1,40] and Sij[1,40] < 0.0
ERROR: Constructing component 'pred_selection' from data=None failed:
TypeError: Cannot create a compound inequality with identical upper
and lower
bounds using strict inequalities: constraint infeasible: 0.0 <
Sij[1,40] and Sij[1,40] < 0.0
I have also tried to replace the constraint coding (i.e. second line) by:
return inequality(0.0, (model.pij[i,k] * model.Sij[i,k] for k in model.M), model.Yij[i,j] * model.Sij[i,j])
This is even worse as the problem cannot be instantiated.
any suggestion on how to fix it?