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

How to retrieve 2D variables in multi-objective solutions?

回答済み

コメント

3件のコメント

  • 正式なコメント
    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 why not try our AI Gurobot?.
  • Eli Towle
    • Gurobi Staff

    The Xn variable attribute (not X) is used in conjunction with the SolutionNumber parameter to query suboptimal solutions. So \( \texttt{x.Xn} \), \( \texttt{y.Xn} \), and \( \texttt{z.Xn} \) together will give you the solution corresponding to the current value of the SolutionNumber parameter. The X attribute queries only variable values from Gurobi's best solution.

    To create a list containing all of the different solutions (like your \( \texttt{solutions} \) list), you must loop over the different solutions via the SolutionNumber parameter and query each solution individually. This is true regardless of whether or not your problem has multiple objectives. Is there a reason you don't want to use a \( \texttt{for} \) loop to query all of the solutions?

    1
  • Jason Uen
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you so much for your comments Eli.

    x.Xn, y.Xn, and z.Xn are exactly what I want corresponding to the SolutionNumber parameter.

    I was looking for a way to retrieve variables in the same dimension as I defined in the model.

    My solutions list do give the values of all decision variables, but it converts the dimension from 3 by 3 into 1 by 9... and I think a for loop for each variable will take too much time to run once the dimension increases.

    But with Xn, I only have to use a for loop over all solutions which takes much less time.

    Thank you again for your help.

     

    0

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