Skip to main content

Iterative Approach change the optimal result

Answered

Comments

3 comments

  • Maliheh Aramon
    • Gurobi Staff Gurobi Staff

    Hi Muhamad,

    As explained by my colleague, Jaromił, in your previous post, the guarantee of an integral optimal solution provided by totally unimodular constraint matrices applies strictly to linear programming. It does not carry over to quadratic programming problems.

    The optimal solution to the model implemented in function \(\texttt{qp_allocation}\) does not lie at a vertex of the feasible region and therefore is not integral.

    If you need an integral solution, you must formulate your problem as an integer quadratic programming problem by forcing the decision variables to take integral values.

    In your iterative approach, you initially solve the same model as implemented in function \(\texttt{qp_allocation}\). You then update the objective function to a constant value in the next iteration. In this iteration, the updated model is a linear programming model with an unimodular constraint matrix and constant objective. This is guaranteed to give you an integral optimal solution. The optimal solution to this LP is just a feasible solution to the original QP.

    Best regards,

    Maliheh

    0
  • Muhamad Fikri
    • Gurobi-versary
    • Curious
    • Conversationalist

    Hi Maliheh,

    Thanks for your answer.
    I have some questions, especially regarding your comment. Let me highlight it first.

    "If you need an integral solution, you must formulate your problem as an integer quadratic programming problem by forcing the decision variables to take integral values"

    Does it mean, I have to set x to be GRB.INTEGER?

    " In this iteration, the updated model is a linear programming model with an unimodular constraint matrix and constant objective"

    Even I define the updated model is the same QP it is a linear programming? It is interesting because I thought it will still as QP.

    " This is guaranteed to give you an integral optimal solution. The optimal solution to this LP is just a feasible solution to the original QP."
    What does it mean by just a feasible solution? If the solution is lying on a vertex doesn't it make the solution is optimal even for QP?
    This part I still don't understand, I hope to get some insight from you

    Thank you

    Best regards
    Muhamad

    0
  • Maliheh Aramon
    • Gurobi Staff Gurobi Staff

    Does it mean, I have to set x to be GRB.INTEGER?

    Yes, you need to set the decision variables to either binary or integer, depending on your application.

    Even I define the updated model is the same QP it is a linear programming? It is interesting because I thought it will still as QP.

    You are setting the objective function in your iterative loop (see below) where \(\texttt{x_new}\) is a numpy ndarray, not a Gurobi MVar object. This is why the expression evaluates to a constant rather than a Gurobi quadratic expression. You can query the objective function expression by calling the method model.getObjective() after optimizing it to verify this.

    model.setObjective(0.5 * x_new @ Q @ x_new + p @ x_new, GRB.MINIMIZE)

    What does it mean by just a feasible solution? If the solution is lying on a vertex doesn't it make the solution is optimal even for QP?

    The new model has a constant objective function and a set of linear constraints, making it a feasibility LP problem since there is no objective function to optimize. This solution is feasible for the QP because it shares the same constraints as the QP model.

    As mentioned several times, the optimal solution to a QP with a totally unimodular constraint matrix does not necessarily lie at a vertex of the feasible region. I am not sure why you still expect a feasible vertex solution to be optimal.

    Best regards,

    Maliheh

    0

Please sign in to leave a comment.