Invalid argument to QuadExpr multiplication for product of more than 2 variables
Awaiting user inputHi, I am trying to optimize the following:
Objective:
$$ \text{minimize} \quad ||B - PC||_1 $$
Here, matrix \(B\) is known, matrix \(P\) is entirely unknown, and matrix \(C\) is only partially known. The dimensions of both matrix \(P\) and \(C\) are known. \(||\cdot||_1\) denotes the \(L^1\) norm, which is the sum of the absolute values of the elements of the matrix \(B - PC\).
However, it appears that QuadExpr does not support absolute values.
I have also tried changing the objective function to the following:
$$ \text{minimize} \quad ||B - PC||^2_F $$
But because some of the elements in matrix \(B - PC\) already contain products of two variables, getting its \(L^2\) norm results in the product of 4 variables, which I saw from other posts is not supported in gurobi.
I would appreciate any suggestions on how to circumvent the limitations!
-
To optimize an objective function involving the 1-norm (sum of absolute values) of a matrix in Gurobi, you can linearize the absolute values. For each element aij of your matrix, introduce two non-negative variables uij and vij, and set aij=uij−vij and ∣aij∣=uij+vij. Add constraints to ensure uij≥0 and vij≥0. This approach converts the absolute values into a linear form, which Gurobi can handle.
0
Please sign in to leave a comment.
Comments
1 comment