Skip to main content

Different solutions for different modelling approaches

Answered

Comments

2 comments

  • Jaromił Najman
    Gurobi Staff 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
    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

Please sign in to leave a comment.