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

something wrong with my MILP model

回答済み

コメント

7件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff 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?.
  • Silke Horn
    • Gurobi Staff Gurobi Staff

    The error message says that you are accessing the key ('Delta', 25) which does not exist. How did you define a?

    0
  • XINYUE HU
    • Gurobi-versary
    • First Comment
    • First Question

    I define the model like

    Line means the name of line,Type represents 6 kinds of product.

    and these are my variables alpha and belta.range(1,25)means 24 hours.

    is there something wrong?

    0
  • Silke Horn
    • Gurobi Staff Gurobi Staff

    You create a (and b) variables with indices from 1 to 24. In the problematic constraint, however, you are trying to access a['Delta', 25] (which does not exist).

    Where you create the problematic constraint, your t ranges from 2 to 24 and then your t1 from t to t+5 (in the 'Delta' case).

    I don't know your model or the problem you are modeling, but you need to make sure that you do not access non-existing keys. So you may want e.g. a larger range for a, a smaller range for t and/or t1 or (if your schedule is supposed to be periodic) you could have your t1 roll over after 24 hours (and use something like t1 modulo 24).

    1
  • XINYUE HU
    • Gurobi-versary
    • First Comment
    • First Question

    oh,thank you very much.I never thought about this before.Yes,my t1 must stay in24 hours. I try it like this.

    then it can't stop,it works all the time and can't give me the result.like this.

    I can't write the code like that?

    0
  • Silke Horn
    • Gurobi Staff Gurobi Staff

    I am glad you could figure it out. From what I have seen, your code looks all right now.

    The last screenshot shows a Gurobi log, which means that the solver is running and optimizing your model. Depending on the size and complexity of the model, this may, however, take a while. I can also see that at the time of the screenshot, the solver is close to an optimal solution since the MIP gap is already quite small (0.04%).

    If this takes too long, you could try setting a termination criterion such as a TimeLimit or MIPGap and then see if the solution is good enough for your application.

    1
  • XINYUE HU
    • Gurobi-versary
    • First Comment
    • First Question

    I already find the way out.Thanks,dear Silke.

    0

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