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

Stochastic Optimizationproblem with 3 Stages

回答済み

コメント

2件のコメント

  • 正式なコメント
    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?.
  • Alison Cozad
    • Gurobi Staff

    It looks like this was answered in Optimizationproblem with Exception Unable to convert argument to an expression – Gurobi Support Portal: there is a parenthesis error causing this problem. 

    If you wind up with a similar issue, I recommend making sure each quicksum's final end parenthesis is in the right spot.  

    To troubleshoot, it may help to create each term one at a time.  Once you know that each is written correctly, you can combine them. 

    For example, you can start with the first term in your objective.  Try setting an objective with only this term.  Then make sure your code executes properly in model.setObjective().  Then you can do the same for term 2. Here is how it should look:

    # Test for term 1
    model.setObjective( quicksum(Prob[s] *quicksum(c[k,j,p]*x[k,j,p,t,s] for k in K for j in J for p in P for t in range(1,len(T)+1)) for s in range(0,len(S)))
    , GRB.MINIMIZE)

    # Test for term 2
    model.setObjective( quicksum(Prob[s]* quicksum(f*y[j] for j in J )for s in range(0,len(S)))
    , GRB.MINIMIZE)

    If those two terms run without error, then you have their parenthesis correct.  Now, you can combine them as follows:

    # Test with term 1 + term 2
    model.setObjective( quicksum(Prob[s] *quicksum(c[k,j,p]*x[k,j,p,t,s] for k in K for j in J for p in P for t in range(1,len(T)+1)) for s in range(0,len(S)))
    + quicksum(Prob[s]* quicksum(f*y[j] for j in J )for s in range(0,len(S)))
    , GRB.MINIMIZE)

    Next, you can do this for the remainder of your objective.

     

    0

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