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

Adding Constraints

回答済み

コメント

5件のコメント

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

    Hi - Can you send a minimal example and explain more what doesn't work? Thanks.

    0
  • Swapnil Brahmankar
    • Gurobi-versary
    • First Question
    • Conversationalist

    Thank you Gwyneth!

     

    I am new to Gurobi and based on all the examples I have gone through so far, my main struggle on the issue here is my ability to formulate that constraint.

    I have tried something like this:

    hc = m.addConstr(gp.quicksum(x[f,c] * highballoans[f] for f in highballoans for c in spechbname if str.isnumeric(c) == False)
     <= 0.10 * gp.quicksum(x[f,c] * loans[f] for f in loans for c in spechbname if str.isnumeric(c) == False))

    and 

    hc = m.addConstr(h.sum(c,'*') <= 0.10 * r.sum(c,'*') for c in specname)

    but keep running into Gurobi/Syntax errors, thank you

     

     

     

    0
  • Gwyneth Butera
    • Gurobi Staff

    Can you try breaking the constraints down into smaller pieces and then post a simple example along with the error message that you get? Thanks!

    0
  • Swapnil Brahmankar
    • Gurobi-versary
    • First Question
    • Conversationalist

    I was able to add the constraint as following:

    hcfn = m.addConstrs((x.prod(highballoanamt,'*', s) <= 0.10 * x.prod(loanamt,'*', s) for s in spechbname 
    if (str.isnumeric(s) == False
    and s.find('FN') != -1
    and maxhighbalamt[s] > 0)), "_")

    hcfg = m.addConstrs((x.prod(highballoanamt,'*', s) <= 0.12 * x.prod(loanamt,'*', s) for s in spechbname
    if (str.isnumeric(s) == False
    and s.find('FG') != -1
    and maxhighbalamt[s] > 0)), "_")

    Thank you

    0

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