I'm trying to write an optimization model using an open-source solver's Python API. I'm new to use Python. The model objective function is as follows:
\begin{equation} \sum_{k=1}^{K} \sum_{j=1}^{n}\left(f_{k}+c_{0, j}^{k}\right) x_{0, j}^{k}+\sum_{k=1}^{K} \sum_{i=1}^{n} \sum_{j \in\{0, \ldots, n\} \backslash\{i\}} c_{i j}^{k} x_{i j}^{k} \end{equation}
where $(i, j, k)$ are indices, $x$ is a variable and $c,f$ are given parameters. In the second term of the objective function, there is a specific filter on the $j$ index. Doing this filter using C++/Java is easy. I was wondering, how can I do that in Python?
The snippet Python code is:
minimize (sum(c(k,i,j)*x[k][i][j] for k in range(K) for i in range(n) for j in range(n)))