メインコンテンツへスキップ

Modeling Gini Coefficient

回答済み

コメント

2件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • Jaromił Najman
    • Gurobi Staff

    Hi Murat,

    It is possible to model your constraint. However, you will need to introduce a couple of auxiliary variables and constraints. Ultimately, what you have to model is the following

    \[\begin{align*}
    GUK \cdot 2\cdot n \cdot \sum_i x_i &= \sum_i \sum_j w_{ij}\\
    w_{ij} &= |z_{ij}| \quad \forall i,j \\
    z_{ij} &= x_i - x_j \quad \forall i,j
    \end{align*}\]

    The first constraint is a reformulation of the division by a variable similar to what is described in How do I divide by a variable in Gurobi? Note that you have to make sure that \(2\cdot n \cdot \sum_i x_i \neq 0\) to make this reformulation mathematically valid. If \(GUK\) is an optimization variable, then, your model is very likely nonconvex and you have to set the NonConvex parameter to 2.

    To model the absolute values, you have to use the AddGenConstrAbs method. The reason for the auxiliary constraints is that the AddGenConstrAbs method accepts only single variables as input and output meaning that it is not allowed to directly provide the \(x_i - x_j\) expression as input.

    Note that you have to explicitly state that the auxiliary variables \(z_{ij}\) can be negative, because the default lower bound for variables in Gurobi is \(0\), i.e., you have to do something similar to

    z = model.addVars(I,J,lb=-GRB.INFINITY,name="z")

    Best regards, 
    Jaromił

    0

投稿コメントは受け付けていません。