How to resolve ladder constraints with pulp

54 Views Asked by At

We now have a scenario where the cost of sending SMS channels is optimal. There are hundreds of channels, which support different types of SMS messages, different suppliers, and multiple operators. In addition, each channel has different prices and its daily sending volume is limited. I have substituted these constraints into the objective function, but what troubles me now is how to substituted the step-like conditions, such as the cost of sending a single message in different intervals is different.Currently using the linear programming package pulp

I'm just substituting the first ladder now, but it's obviously inappropriate

##TODO minimum price expression
    sentPrice=None
    SHlinkNum=None
    SZMoveNum=None
    for dictType in channel_vars:
        for typeKeys in dictType.keys():
            if supplier["SHlink"].__contains__(typeKeys):
                SHlinkNum+=dictType[typeKeys]
            elif  supplier["SZmove"].__contains__(typeKeys):
                SZMoveNum+=dictType[typeKeys]
            chanPrice=round(cost.get(typeKeys,0),2)
            sentPrice+=chanPrice*dictType[typeKeys]
    SHsuppNum=supplierSent.get("SHlink",0)
    SZsuppNum=supplierSent.get("SZmove",0)

##TODO Channel Minimum Cost Constraints
    prob+=SHlinkNum==int((supplierTarget["SHlink"]-SHsuppNum)/date_diff),"SHlinkLimitNum"
    prob+=SZMoveNum==int((supplierTarget["SZmove"]-SZsuppNum)/date_diff),"SZmoveLimitNum"
    prob+=(lpSum(sentPrice+SHsuppNum*0.0+SZMoveNum*0.0),
           "Total cost of channels per chan"
           )
0

There are 0 best solutions below