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

Algorithm

回答済み

コメント

4件のコメント

  • 正式なコメント
    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 Vida,

    Note that the addConstr method already adds the given constraint to the model. This means that you add all constraints twice except for the last one. You first add constraints in the first \(\texttt{for}\)-loop

    for ro in range(eta+1):
            cut = model.addConstr(constraint)
            constraints.append(cut)

    and then you add all those constraints again except for the last one

    for prev_constraint in constraints[:-1]:
            model.addConstr(prev_constraint)

    Could you explain what exactly are you trying to achieve in those \(\texttt{for}\)-loops? You can always use the write method to write the model you construct to a human-readable LP file

    model.write("myModel.lp")

    You can open the \(\texttt{myModel.lp}\) file in any standard text editor.

    Best regards, 
    Jaromił

    0
  • Vida Yousefinezhad
    • Gurobi-versary
    • Curious
    • Conversationalist

    Hi again, 

    Thank you for your time. 

    A small part of the loop is here:

    eta = 0
    while True:
       pi_n  = solve_subproblem(mu0_0, mu1_0, mu2_0, f_star, C, G, o, f, M, p, m, b, a, d)
        gamma_tilde, mu0_tilde, mu1_tilde, mu2_tilde = solve_masterproblem(pi_n, f_star, eta, C, G, o, f, M, p, m, b, a, d)
      eta +=1
    .
    .
    .

    Also, the constraint_90 is added internally within the solve_masterproblem function. In each iteration, new pi_n is obtained. What I want is to ensure that the master problem contains all the constraint_90 from past iterations along with the new one added in the current iteration. 

    Regards,

    Vida

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Vida,

    Also, the constraint_90 is added internally within the solve_masterproblem function. In each iteration, new pi_n is obtained. What I want is to ensure that the master problem contains all the constraint_90 from past iterations along with the new one added in the current iteration. 

    As long as you do not rebuild the master problem from scratch or use the remove method, old constraints will not be removed from the master problem. To verify this, you can use the write method after each iteration

    model.write("myModel.lp")

    You can open the \(\texttt{myModel.lp}\) file in any standard text editor.

    I think this is the best way to make sure that your algorithm behaves as expected and your model looks what it should look like.

    Best regards, 
    Jaromił

    0

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