Hi! I’m pretty new to julia and optimization, and I’m trying to set up a optimization problem over a decision variable X \in \mathbb{R}^{m \times n} that would semantically capture assignment of “targets” in the rows of the matrix to “candidates” in the columns. One objective in this problem is based on maximization of “similarity” (encoded by symmetric matrix T \in \mathbb{R}^{m \times m}) of targets assigned to the same candidate. I am currently using an indicator variable Y \in \mathbb{R}^{m \times m \times n}, where Y_{ijk} indicates whether targets i and j are assigned to candidate k.
The working version of this objective is below:
\max_{X \in \{0,1\}^{m \times n}} \sum_{k=1}^n \sum_{i=1}^m \sum_{j=1}^m Y_{ijk} * T_{ij}
However, I am struggling to modify the above objective to address the bias in the assignment of all targets to one candidate. I want to somehow normalize each candidate’s “reward” by the number of targets assigned to that candidate:
\max_{X \in \{0,1\}^{m \times n}} \sum_{k=1}^n \cfrac{\sum_{i=1}^m \sum_{j=1}^m Y_{ijk} * T_{ij}}{(\sum_{i=1}^m X_{ik}) + 1}
However, an implementation of this modified objective gives me the error:
The solver does not support an objective function of type MathOptInterface.ScalarNonlinearFunction
Any feedback would be very much appreciated! For reference, my code is below:
# Define the decision variable
@variable(model, 0 <= X[1:m, 1:n] <= 1)
# Construct indicator variable
@variable(model, 0 <= Y[1:m, 1:m, 1:n] <= 1)
# Construct variable for column sums of X
@variable(model, c[1:n])
# Add constraints: Y_ijk <= X_ik and Y_ijk <= X_jk
for i in 1:m, j in 1:m, k in 1:n
@constraint(model, Y[i, j, k] <= X[i, k])
@constraint(model, Y[i, j, k] <= X[j, k])
end
# Add constraint: column sums of c
for j in 1:n
@constraint(model, c[j] == sum(X[i, j] for i in 1:m) + 1)
end
# Add constraints: row sums over X == 1
@constraint(model, [i=1:m], sum(X[i, j] for j in 1:n) == 1)
first_objective = 0.0
for k in 1:n
sum_Y_T = sum(Y[i, j, k] * T[i, j] for i in 1:m, j in 1:m)
# Note: non-normed objective that does not divide by c[k] works here
first_objective += sum_Y_T / c[k]
end
@objective(model, Max, first_objective)