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

Different solutions for different modelling approaches

回答済み

コメント

3件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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 Paul,

    Could you please provide a minimal reproducible example of both formulations? You can use the write method to generate human-readable LP files by calling

    model.write("myModel.lp")

    You can open the file \(\texttt{myModel.lp}\) in any standard text editor to analyze whether the formulations who are comparing are indeed equivalent.

    Best regards, 
    Jaromił

    0
  • Paul-Niklas Kandora
    • Gurobi-versary
    • First Comment
    • First Question

    Jaromił Najman thanks for the response! I was actually able to solve the problem by myself with introducing a support variable (support_quad_expr):

    factor_obj = {
    c: m.addVar(name=f"factor_obj_{c}") for c in C
    }
    support_quad_expr = m.addVar(1)
    quad_expr_c = {
    c: m.addVar(name=f"quad_expr_{c}") for c in C
    }

    m.setObjective((1 / C) * gp.quicksum(factor_obj[c]
    for c in C), GRB.MINIMIZE)

    for c in C:
    m.addConstr(
    quad_expr_c[c] == gp.quicksum(z_c_r[c, r] * mu_c_r[c, r] for r in R_c[c])
    )
    m.addConstr(
    quad_expr_c[c] == support_quad_expr
    )
    m.addConstr(
    gp.quicksum(z_c_r[c, r] for r in R_c[c]) * factor_obj[c]
    == support_quad_expr
    )

    I assume that gurobi had difficulties to understand the following:

    quad_expr_c[c] == gp.quicksum(z_c_r[c, r] * mu_c_r[c, r] for r in R_c[c])

    Best

    Paul

    0

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